Skip to content

Commit

Permalink
Jupyter fix (#1489)
Browse files Browse the repository at this point in the history
Co-authored-by: Tal Ben-Nun <[email protected]>
  • Loading branch information
phschaad and tbennun authored Feb 16, 2024
1 parent 15c1fe8 commit 47ef29a
Show file tree
Hide file tree
Showing 10 changed files with 400 additions and 412 deletions.
21 changes: 6 additions & 15 deletions dace/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def _connected():
try:
urllib.request.urlopen('https://spcl.github.io/dace/webclient2/dist/sdfv.js', timeout=1)
urllib.request.urlopen('https://spcl.github.io/dace-webclient/dist/sdfv.js', timeout=1)
return True
except urllib.error.URLError:
return False
Expand All @@ -31,31 +31,22 @@ def isnotebook():
def preamble():
# Emit javascript headers for SDFG renderer
sdfv_js_deps = ['sdfv.js']
sdfv_css_deps = ['sdfv.css']
offline_sdfv_js_deps = ['sdfv_jupyter.js']

result = ''

# Rely on internet connection for Material icons
result += '<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">'

# Try to load dependencies from online sources
if _connected():
for dep in sdfv_js_deps:
result += '<script src="https://spcl.github.io/dace/webclient2/dist/%s"></script>\n' % dep
for dep in sdfv_css_deps:
result += '<link href="https://spcl.github.io/dace/webclient2/%s" rel="stylesheet">\n' % dep
result += '<script src="https://spcl.github.io/dace-webclient/dist/%s"></script>\n' % dep
return result

# Load local dependencies
root_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'dace', 'viewer', 'webclient')
for dep in sdfv_js_deps:
root_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'viewer', 'webclient')
for dep in offline_sdfv_js_deps:
file = os.path.join(root_path, 'dist', dep)
with open(file, 'r') as fp:
with open(file) as fp:
result += '<script>%s</script>\n' % fp.read()
for dep in sdfv_css_deps:
file = os.path.join(root_path, dep)
with open(file, 'r') as fp:
result += '<style>%s</style>\n' % fp.read()

# Run this code once
return result
Expand Down
4 changes: 4 additions & 0 deletions dace/sdfg/sdfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1429,9 +1429,13 @@ def _repr_html_(self):

# Create renderer canvas and load SDFG
result += """
<div class="sdfv">
<div id="contents_{uid}" style="position: relative; resize: vertical; overflow: auto"></div>
</div>
<script>
var sdfg_{uid} = {sdfg};
</script>
<script>
var sdfv_{uid} = new SDFV();
var renderer_{uid} = new SDFGRenderer(sdfv_{uid}, parse_sdfg(sdfg_{uid}),
document.getElementById('contents_{uid}'));
Expand Down
2 changes: 1 addition & 1 deletion dace/viewer/webclient
Submodule webclient updated 100 files
93 changes: 1 addition & 92 deletions tutorials/benchmarking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,7 @@
{
"data": {
"text/html": [
"<link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\">\n",
" <script>\n",
" require.config({\n",
" paths: {\n",
" \"math\": \"https://spcl.github.io/dace/webclient/external_lib/math.min\"\n",
" },\n",
" waitSeconds: 40\n",
" });\n",
" require( [\"math\"], x => window.math = x);\n",
" </script><script src=\"https://spcl.github.io/dace/webclient/renderer_dir/dagre.js\"></script>\n",
"<script src=\"https://spcl.github.io/dace/webclient/renderer_dir/global_vars.js\"></script>\n",
"<script src=\"https://spcl.github.io/dace/webclient/context_menu.js\"></script>\n",
"<script src=\"https://spcl.github.io/dace/webclient/renderer_elements.js\"></script>\n",
"<script src=\"https://spcl.github.io/dace/webclient/sdfg_utils.js\"></script>\n",
"<script src=\"https://spcl.github.io/dace/webclient/overlay_manager.js\"></script>\n",
"<script src=\"https://spcl.github.io/dace/webclient/renderer.js\"></script>\n",
"<link href=\"https://spcl.github.io/dace/webclient/sdfv.css\" rel=\"stylesheet\">\n"
"<script src=\"https://spcl.github.io/dace-webclient/dist/sdfv.js\"></script>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
Expand Down Expand Up @@ -834,81 +818,6 @@
"446 ms ± 41.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"<ipython-input-35-c42936c82690>:4: NumbaWarning: \u001b[1m\n",
"Compilation is falling back to object mode WITH looplifting enabled because Function \"someforloop\" failed type inference due to: \u001b[1mUntyped global name 'element_update':\u001b[0m \u001b[1m\u001b[1mCannot determine Numba type of <class 'function'>\u001b[0m\n",
"\u001b[1m\n",
"File \"<ipython-input-35-c42936c82690>\", line 7:\u001b[0m\n",
"\u001b[1mdef someforloop(A):\n",
" <source elided>\n",
" for j in range(A.shape[1]):\n",
"\u001b[1m A[i, j] = element_update(A[i, j])\n",
"\u001b[0m \u001b[1m^\u001b[0m\u001b[0m\n",
"\u001b[0m\u001b[0m\n",
" def someforloop(A):\n",
"<ipython-input-35-c42936c82690>:4: NumbaWarning: \u001b[1m\n",
"Compilation is falling back to object mode WITHOUT looplifting enabled because Function \"someforloop\" failed type inference due to: \u001b[1m\u001b[1mCannot determine Numba type of <class 'numba.core.dispatcher.LiftedLoop'>\u001b[0m\n",
"\u001b[1m\n",
"File \"<ipython-input-35-c42936c82690>\", line 5:\u001b[0m\n",
"\u001b[1mdef someforloop(A):\n",
"\u001b[1m for i in range(A.shape[0]):\n",
"\u001b[0m \u001b[1m^\u001b[0m\u001b[0m\n",
"\u001b[0m\u001b[0m\n",
" def someforloop(A):\n",
"/home/user/anaconda3/envs/py38/lib/python3.8/site-packages/numba/core/object_mode_passes.py:151: NumbaWarning: \u001b[1mFunction \"someforloop\" was compiled in object mode without forceobj=True, but has lifted loops.\n",
"\u001b[1m\n",
"File \"<ipython-input-35-c42936c82690>\", line 5:\u001b[0m\n",
"\u001b[1mdef someforloop(A):\n",
"\u001b[1m for i in range(A.shape[0]):\n",
"\u001b[0m \u001b[1m^\u001b[0m\u001b[0m\n",
"\u001b[0m\n",
" warnings.warn(errors.NumbaWarning(warn_msg,\n",
"/home/user/anaconda3/envs/py38/lib/python3.8/site-packages/numba/core/object_mode_passes.py:161: NumbaDeprecationWarning: \u001b[1m\n",
"Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.\n",
"\n",
"For more information visit https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit\n",
"\u001b[1m\n",
"File \"<ipython-input-35-c42936c82690>\", line 5:\u001b[0m\n",
"\u001b[1mdef someforloop(A):\n",
"\u001b[1m for i in range(A.shape[0]):\n",
"\u001b[0m \u001b[1m^\u001b[0m\u001b[0m\n",
"\u001b[0m\n",
" warnings.warn(errors.NumbaDeprecationWarning(msg,\n",
"<ipython-input-35-c42936c82690>:4: NumbaWarning: \u001b[1m\n",
"Compilation is falling back to object mode WITHOUT looplifting enabled because Function \"someforloop\" failed type inference due to: \u001b[1mUntyped global name 'element_update':\u001b[0m \u001b[1m\u001b[1mCannot determine Numba type of <class 'function'>\u001b[0m\n",
"\u001b[1m\n",
"File \"<ipython-input-35-c42936c82690>\", line 7:\u001b[0m\n",
"\u001b[1mdef someforloop(A):\n",
" <source elided>\n",
" for j in range(A.shape[1]):\n",
"\u001b[1m A[i, j] = element_update(A[i, j])\n",
"\u001b[0m \u001b[1m^\u001b[0m\u001b[0m\n",
"\u001b[0m\u001b[0m\n",
" def someforloop(A):\n",
"/home/user/anaconda3/envs/py38/lib/python3.8/site-packages/numba/core/object_mode_passes.py:151: NumbaWarning: \u001b[1mFunction \"someforloop\" was compiled in object mode without forceobj=True.\n",
"\u001b[1m\n",
"File \"<ipython-input-35-c42936c82690>\", line 5:\u001b[0m\n",
"\u001b[1mdef someforloop(A):\n",
"\u001b[1m for i in range(A.shape[0]):\n",
"\u001b[0m \u001b[1m^\u001b[0m\u001b[0m\n",
"\u001b[0m\n",
" warnings.warn(errors.NumbaWarning(warn_msg,\n",
"/home/user/anaconda3/envs/py38/lib/python3.8/site-packages/numba/core/object_mode_passes.py:161: NumbaDeprecationWarning: \u001b[1m\n",
"Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.\n",
"\n",
"For more information visit https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit\n",
"\u001b[1m\n",
"File \"<ipython-input-35-c42936c82690>\", line 5:\u001b[0m\n",
"\u001b[1mdef someforloop(A):\n",
"\u001b[1m for i in range(A.shape[0]):\n",
"\u001b[0m \u001b[1m^\u001b[0m\u001b[0m\n",
"\u001b[0m\n",
" warnings.warn(errors.NumbaDeprecationWarning(msg,\n"
]
},
{
"name": "stdout",
"output_type": "stream",
Expand Down
34 changes: 12 additions & 22 deletions tutorials/codegen.ipynb

Large diffs are not rendered by default.

36 changes: 13 additions & 23 deletions tutorials/explicit.ipynb

Large diffs are not rendered by default.

114 changes: 57 additions & 57 deletions tutorials/getting_started.ipynb

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions tutorials/numpy_frontend.ipynb

Large diffs are not rendered by default.

124 changes: 65 additions & 59 deletions tutorials/sdfg_api.ipynb

Large diffs are not rendered by default.

318 changes: 208 additions & 110 deletions tutorials/transformations.ipynb

Large diffs are not rendered by default.

0 comments on commit 47ef29a

Please sign in to comment.