Skip to content

Commit

Permalink
Migration to latest jupyter version
Browse files Browse the repository at this point in the history
  • Loading branch information
Mani-D committed Jun 9, 2024
1 parent f99242f commit 9420fdf
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 49 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ Due to this, sampling profilers typically end up profiling the least interesting

## Building <a name="building"></a>

To build xpedite, you will need [cmake](http://cmake.org/) 3.4 or later, [GNU gcc](https://gcc.gnu.org/) 5.2 or later, and a version 2.5 or later Linux kernel.
To build xpedite, you will need a linux machine (kernel 2.5 or later) running on intel hardware with the following packages.
1. [cmake](http://cmake.org/) (3.4 or later)
2. [GNU gcc](https://gcc.gnu.org/) (5.2 or later)
3. [python 3](https://www.python.org/downloads/)
4. [pybind11](https://github.com/pybind/pybind11)
5. [python 3 venv](https://docs.python.org/3/library/venv.html)

With cmake and g++ installed, to use xpedite, clone this repository and run the following from xpedite source dir:

Expand Down
1 change: 1 addition & 0 deletions include/xpedite/probes/Probe.H
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <xpedite/util/Util.H>
#include <xpedite/probes/CallSite.H>
#include <xpedite/probes/RecorderCtl.H>
#include <cstdint>

namespace xpedite { namespace probes {

Expand Down
1 change: 1 addition & 0 deletions include/xpedite/probes/RecorderCtl.H
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma once
#include <xpedite/probes/CallSite.H>
#include <xpedite/probes/Recorders.H>
#include <cstdint>

using XpediteRecorder = void (*)(const void*, uint64_t);
using XpediteDataProbeRecorder = void (*)(const void*, uint64_t, __uint128_t);
Expand Down
1 change: 1 addition & 0 deletions include/xpedite/probes/Recorders.H
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once
#include <xpedite/platform/Builtins.H>
#include <array>
#include <cstdint>

extern "C" {

Expand Down
4 changes: 3 additions & 1 deletion scripts/lib/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
'cement',
'termcolor',
'py-cpuinfo',
'jupyter',
'nbclassic',
'six',
'setuptools'
'ipynbname',
],
zip_safe=False)
4 changes: 2 additions & 2 deletions scripts/lib/xpedite/jupyter/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""

import logging
from IPython.core.display import display, HTML
from IPython.display import display, HTML
from xpedite.jupyter.context import context
from xpedite.report.markup import ERROR_TEXT

Expand Down Expand Up @@ -241,7 +241,7 @@ def __repr__(self):
) if self.profile.current.isEventsEnabled() else ''
threshold = 1000
if len(self.profile.current) > threshold:
LOGGER.warn('too many transaction - showing only %d out of %d', threshold, len(self.profile.current))
LOGGER.warning('too many transaction - showing only %d out of %d', threshold, len(self.profile.current))
strRepr += str(ReportBuilder().buildTimelineTable(
self.profile.current, self.profile.probes, ResultOrder.Chronological, threshold, uid
))
Expand Down
12 changes: 6 additions & 6 deletions scripts/lib/xpedite/jupyter/data/config/custom/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
**
*******************************************************************************************/

@import 'flot.css';
@import 'notebook.css';
@import 'sunburst.css';
@import 'bipartite.css';
@import 'xpedite.css';
@import 'darkTheme.css';
@import '/static/flot.css';
@import '/static/notebook.css';
@import '/static/sunburst.css';
@import '/static/bipartite.css';
@import '/static/xpedite.css';
@import '/static/darkTheme.css';

body.notebook_app, body.notebook_app.command_mode {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
Expand Down
21 changes: 0 additions & 21 deletions scripts/lib/xpedite/jupyter/data/config/jupyter_notebook_config.py

This file was deleted.

18 changes: 18 additions & 0 deletions scripts/lib/xpedite/jupyter/data/config/jupyter_server_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Configuration file for jupyter-notebook.

# Add serverextension to sys.path for jupyter to load tornadoExtension module on startup
import os
import sys

currDir = os.path.dirname(__file__)
packagePath = os.path.join(currDir, '../config/serverextensions')
sys.path.insert(0, packagePath)
c = get_config()
c.ServerApp.jpserver_extensions = {
'tornadoExtension' : True,
}

staticPath = os.path.join(currDir, '../config/custom')
c.ServerApp.extra_static_paths = [os.path.join(currDir, '../js'), staticPath]
c.ServerApp.allow_origin = '*' #allow all origins
c.ServerApp.ip = '0.0.0.0' # listen on all IPs
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
Author: Dhruv Shekhawat, Morgan Stanley
"""

from notebook.utils import url_path_join
from notebook.base.handlers import IPythonHandler
#from notebook.utils import url_path_join
import jupyter_server
from jupyter_server.base.handlers import JupyterHandler
import tornado
from tornado import template
import tornado.web
import json
Expand All @@ -15,13 +17,14 @@
import os
import sys

class HtmlReportHandler(tornado.web.RequestHandler):
class HtmlReportHandler(JupyterHandler):
"""Class to serve html reports through links with
query params as notebook path and (cellId, reportId)
as indices to read metadata from notebook
"""
@tornado.web.authenticated
def get(self):
xpeditePath = os.path.normpath(os.path.join(__file__, '../../../../../..'))
xpeditePath = os.path.normpath(os.path.join(__file__, '../../../../../../..'))
sys.path.append(xpeditePath)

from xpedite.jupyter.xpediteData import XpediteDataReader
Expand Down Expand Up @@ -57,11 +60,16 @@ def get_init_cell(jsonReport):
if(('isInit' in metadata) and (metadata['isInit'] == '0xFFFFFFFFA5A55A5DUL')):
return cell

def load_jupyter_server_extension(nb_server_app):
"""Method called first to load the
server extension on jupyter startup
"""
web_app = nb_server_app.web_app
host_pattern = '.*$'
route_pattern = url_path_join(web_app.settings['base_url'], '/xpedite')
web_app.add_handlers(host_pattern, [(route_pattern, HtmlReportHandler)])
def _load_jupyter_server_extension(serverapp: jupyter_server.serverapp.ServerApp):
"""
This function is called when the extension is loaded.
"""
handlers = [('/xpedite', HtmlReportHandler)]
serverapp.web_app.add_handlers(".*$", handlers)

def _jupyter_server_extension_points():
"""
Returns a list of dictionaries with metadata describing
where to find the `_load_jupyter_server_extension` function.
"""
return [{"module": "tornadoExtension"}]
6 changes: 4 additions & 2 deletions scripts/lib/xpedite/jupyter/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,17 @@ def launchJupyter(homeDir):
LOGGER.info('')
pyPath = os.path.dirname(binPath('python')) + os.pathsep + os.environ['PATH']
initPath = os.path.dirname(__file__)
runtimePath = tempfile.mkdtemp(prefix=SHELL_PREFIX, dir='/tmp')
jupyterEnv = os.environ
jupyterEnv[Context.xpediteHomeKey] = os.path.abspath(homeDir)
jupyterEnv['JUPYTER_PATH'] = os.path.join(initPath, 'data/extensions/')
jupyterEnv['JUPYTER_CONFIG_DIR'] = os.path.join(initPath, 'data/config/')
jupyterEnv['JUPYTER_RUNTIME_DIR'] = runtimePath
jupyterEnv['HOME'] = runtimePath
jupyterEnv['XPEDITE_PATH'] = os.path.abspath(os.path.join(initPath, '../../'))
jupyterEnv['PATH'] = pyPath
jupyterEnv['HOME'] = tempfile.mkdtemp(prefix=SHELL_PREFIX, dir='/tmp')
jupyterBinary = binPath('jupyter')
os.execle(jupyterBinary, 'Xpedite', 'notebook', '--no-browser', '--notebook-dir='+homeDir, jupyterEnv)
os.execle(jupyterBinary, 'Xpedite', 'nbclassic', '--no-browser', '--notebook-dir='+homeDir, jupyterEnv)

def validatePath(homeDir, reportName):
"""Validates the path to store xpedite notebook and data files"""
Expand Down
4 changes: 2 additions & 2 deletions scripts/lib/xpedite/jupyter/templates/initCell.fmt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import os, sys
from IPython.display import display, HTML
sys.path.append(os.environ['XPEDITE_PATH'])
import xpedite
import ipynbname
from xpedite.jupyter.commands import routes, txns, plot, stat, filter, diff
from xpedite.analytics.timelineTree import buildTimelineTree
from xpedite.jupyter.templates.initCell import INTRO_FRMT
from xpedite.jupyter.context import Context, context

thismodule = sys.modules[__name__]
notebookPath = getattr(thismodule, Context.notebookPathKey)
notebookPath = ipynbname.path()
result = 'Failed to resolve jupyter notebook path'
if notebookPath:
context.initialize(notebookPath)
Expand Down
6 changes: 4 additions & 2 deletions scripts/lib/xpedite/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ netifaces>=0.10.4
numpy>=1.15.2
pygments>=2.0.2
rpyc>=4.0.1
cement==2.8.2
cement>=3.0.10
termcolor>=1.1.0
py-cpuinfo>=0.1.2
jupyter>=1.0.0
six>=1.12.0
nbclassic>=1.0.0
setuptools
ipynbname

0 comments on commit 9420fdf

Please sign in to comment.