jupyter / dashboards

[RETIRED] See Voilà as a supported replacement
https://github.com/voila-dashboards
Other
984 stars 209 forks source link

urth-core-function no longer works with installed dashboard extension #268

Closed osdf closed 8 years ago

osdf commented 8 years ago

Hi,

the following minimal working example works with declarativewidgets installed. As soon as the dashboard extension is installed, the html part loads indefinitely (a blue bar running below the cell). What am I doing wrong?

import declarativewidgets
declarativewidgets.init()

def load_selection(items, abc, lmn, xyz):
    print("Loading {}".format(items))
    print(abc)
%%html
<template is="urth-core-bind">
    <urth-core-function id="_slct", ref="load_selection" arg-items="[[select]]", arg-abc="[[abc]]",
    arg-lmn="[[lmn]]", arg-xyz="[[xyz]]">
    </urth-core-function>
</template>

Thank you!!!

dalogsdon commented 8 years ago

What do you mean by "working"? Is this all your code, or do you have select, abc, lmn, and xyz defined somewhere?

When I run your code as is, I get no output. When I add an auto attribute and remove the square brackets to make the arguments constant strings I see the function print. This is working for me without and with the dashboard extension installed.

Here is my modification of your template:

%%html
<template is="urth-core-bind">
    <urth-core-function id="_slct", ref="load_selection" arg-items="select", arg-abc="abc",
    arg-lmn="lmn", arg-xyz="xyz" auto>
    </urth-core-function>
</template>

If this still doesn't work, can you post the output of pip freeze to help us debug?

osdf commented 8 years ago

By 'working' I mean that there is no 'indicator' (the blue bar, see screenshot below) that the html part somehow stalls. There are supposed to be more html cells coming later, but these also show the blue bar, stalling.

This is what I see, using your modification (actually, simplified load_selection to one argument). The idea is that later html blocks have {{select}} entries that fill the select variable.

Screenshot: selection_001

Addon: I can run python code in the subsequent cells, even though this blue bar is there, stalling. However, other html blocks won't execute. This does not happen when I deactivate (uninstall) the dashboard extension.

osdf commented 8 years ago
~> pip freeze
abstract-rendering==0.5.1
affine==1.2.0
alabaster==0.7.8
anaconda-client==1.4.0
anaconda-navigator==1.2.1
argcomplete==1.0.0
astropy==1.1.2
awscli==1.6.2
Babel==2.3.3
backports-abc==0.4
backports.shutil-get-terminal-size==1.0.0
backports.ssl-match-hostname==3.4.0.2
bcdoc==0.12.2
beautifulsoup4==4.4.1
bitarray==0.8.1
blaze==0.10.1
bokeh==0.12.0
boto==2.40.0
botocore==0.73.0
Bottleneck==1.0.0
cdecimal==2.3
certifi==2015.4.28
cffi==1.6.0
chest==0.2.3
click==6.6
cligj==0.2.0
cloudpickle==0.2.1
clyent==1.2.2
colorama==0.2.5
conda==4.1.8
conda-build==1.21.5
conda-env==2.5.0a0
conda-manager==0.4.0
configobj==5.0.6
configparser==3.5.0b2
contextlib2==0.5.3
cryptography==1.4
cycler==0.10.0
Cython==0.24
cytoolz==0.8.0
dask==0.10.0
datashape==0.5.2
decorator==4.0.10
dill==0.2.5
docopt==0.6.2
docutils==0.12
dynd==0.7.3.dev1
enum34==1.1.6
et-xmlfile==1.0.1
fastcache==1.0.2
flake8==2.5.1
Flask==0.11.1
Flask-Cors==2.1.2
funcsigs==1.0.2
functools32==3.2.3.post2
futures==3.0.5
gevent==1.1.0
gevent-websocket==0.9.5
greenlet==0.4.10
grin==1.2.1
grip==4.1.0
h5py==2.6.0
HeapDict==1.0.0
holoviews==1.4.3
idna==2.1
imagesize==0.7.1
ipaddress==1.0.16
ipykernel==4.3.1
ipython==5.0.0
ipython-genutils==0.1.0
ipython-memwatcher==0.2.1
ipywidgets==4.1.1
itsdangerous==0.24
jdcal==1.2
jedi==0.9.0
Jinja2==2.8
jmespath==0.5.0
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.3.0
jupyter-console==5.0.0
jupyter-core==4.1.0
jupyter-dashboards==0.6.0
jupyter-declarativewidgets==0.6.0
lancet-ioam==0.9.0
llvmlite==0.11.0
locket==0.2.0
lxml==3.6.0
Markdown==2.6.5
MarkupSafe==0.23
matplotlib==1.5.1
mccabe==0.3.1
memory-profiler==0.41
mistune==0.7.2
mixpanel-py==3.1.1
mock==2.0.0
mpmath==0.19
multipledispatch==0.4.8
nbconvert==4.2.0
nbformat==4.0.1
networkx==1.11
nltk==3.2.1
nose==1.3.7
notebook==4.2.1
numba==0.26.0
numexpr==2.5.2
numpy==1.11.0
odo==0.5.0
openpyxl==2.3.2
pandas==0.18.1
pandas-datareader==0.2.1
param==1.3.2
partd==0.3.4
path-and-address==1.0.0
path.py==0.0.0
pathlib2==2.1.0
patsy==0.4.1
pbr==1.9.1
pep8==1.7.0
pexpect==4.2.0
pickleshare==0.7.2
Pillow==3.3.0
ply==3.8
prettytable==0.7.2
prompt-toolkit==1.0.3
protobuf==3.0.0b2
psutil==4.3.0
ptyprocess==0.5.1
py==1.4.31
pyasn1==0.1.9
pycairo==1.10.0
pycosat==0.6.1
pycparser==2.14
pycrypto==2.6.1
pycurl==7.19.5.3
pyflakes==1.2.3
pyfolio==0.4.0
Pygments==2.1.3
pymongo==3.0.3
pyOpenSSL==16.0.0
pyparsing==2.0.3
pytest==2.9.2
python-dateutil==2.5.3
pytz==2016.4
PyYAML==3.11
pyzmq==15.2.0
QtAwesome==0.3.3
qtconsole==4.2.1
QtPy==1.0.2
rasterio==0.25.0
redis==2.10.5
requests==2.3.0
requests-file==1.4
rope==0.9.4
rsa==3.1.2
ruamel-yaml===-VERSION
scikit-image==0.12.3
scikit-learn==0.17.1
scipy==0.17.1
seaborn==0.7.0
SFrame==1.8
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
snowballstemmer==1.2.1
snuggs==1.3.1
sockjs-tornado==1.0.3
Sphinx==1.4.1
sphinx-rtd-theme==0.1.9
spyder==2.3.8
SQLAlchemy==1.0.13
statsmodels==0.6.1
sympy==1.0
tables==3.2.2
tensorflow==0.8.0rc0
terminado==0.6
-e git+https://github.com/Theano/Theano@68290a96e5ef0d4b7d05abdeb4ad2cb4db4a4ec0#egg=Theano
toolz==0.8.0
tornado==4.3
tqdm==3.8.0
traitlets==4.2.2
ujson==1.35
unicodecsv==0.14.1
wcwidth==0.1.7
Werkzeug==0.11.10
xgboost==0.4
xlrd==1.0.0
XlsxWriter==0.9.2
xlwt==1.1.2
yapf==0.10.0
parente commented 8 years ago

@osdf thanks for the report. You've definitely got something unique happening in your environment that we haven't seen before.

The dashboards extension is pure JavaScript so I expect the bad interaction to be somewhere on the frontend in your browser. What browser are you using? If you're familiar with the developer tools for your browser, can you share what appears in the console view when you clear all cells, restart the kernel, refresh the notebook page, and run all?

osdf commented 8 years ago

@parente Thank you for your reply. Should have though about the browser myself ...

Build identifier: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0

EDIT: I don't observe the above in Chrome, ie there is no blue bar stalling. However, nothing else happens after executing the cell (something should happen, correct? There is this auto parameter). Running the bigger notebook the above is actually part of also has no blue bars in Chrome, but none of the functionality works (e.g. pressing a button, which should execute load_selection has no effect, channel.set() has no effect on widgets, etc.).

EDIT2: Hmm, quickly uninstalled the dashboard to test Chrome, and there nothing happens at all. That is, the widgets I know working now in Firefox do not work in Chrome.

Google Chrome   51.0.2704.106 (Official Build) (64-bit)
Revision    27e9e15b411edc75a2233a9ad11dc7ae86e243fd-refs/branch-heads/2704_103@{#3}
OS  Linux 
Blink   537.36 (@27e9e15b411edc75a2233a9ad11dc7ae86e243fd)
JavaScript  V8 5.1.281.65
Flash   22.0.0.192
User Agent  Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36
Command Line    /usr/bin/google-chrome --window-depth=24 --flag-switches-begin --flag-switches-end

How would I provide the console view, it is quite a lot of stuff there?

osdf commented 8 years ago

Restarting the kernel never changed this blue bar of stalling, the console view probably explains why:

Couldn't process kernel message TypeError: Urth.kernel.widget_manager is undefined
Stack trace:
Urth.JupyterWidgetBehaviorImpl._doCreateModel@http://localhost:8888/urth_components/urth-core-behaviors/jupyter-widget-behavior.html.js:39:17
Urth.JupyterWidgetBehaviorImpl.createModel@http://localhost:8888/urth_components/urth-core-behaviors/jupyter-widget-behavior.html.js:34:17
@http://localhost:8888/urth_components/urth-core-channel/urth-core-channel-broker.html.js:109:17
Urth.JupyterKernelObserver<.created/this.__kernelReadyCallback<@http://localhost:8888/urth_components/urth-core-behaviors/jupyter-kernel-observer.html.js:21:21
x.event.dispatch@http://localhost:8888/static/notebook/js/main.min.js?v=dda91b55a04855a1c133b176c7a48905:88:9954
x.event.add/y.handle@http://localhost:8888/static/notebook/js/main.min.js?v=dda91b55a04855a1c133b176c7a48905:88:6772
x.event.trigger@http://localhost:8888/static/notebook/js/main.min.js?v=dda91b55a04855a1c133b176c7a48905:88:9129
.trigger/<@http://localhost:8888/static/notebook/js/main.min.js?v=dda91b55a04855a1c133b176c7a48905:88:14828
.each@http://localhost:8888/static/notebook/js/main.min.js?v=dda91b55a04855a1c133b176c7a48905:87:4573
x.prototype.each@http://localhost:8888/static/notebook/js/main.min.js?v=dda91b55a04855a1c133b176c7a48905:87:1624
.trigger@http://localhost:8888/static/notebook/js/main.min.js?v=dda91b55a04855a1c133b176c7a48905:88:14807
Kernel.prototype._kernel_connected/<@http://localhost:8888/static/notebook/js/main.min.js?v=dda91b55a04855a1c133b176c7a48905:22683:13
Kernel.prototype._handle_shell_reply/promise<@http://localhost:8888/static/notebook/js/main.min.js?v=dda91b55a04855a1c133b176c7a48905:23205:55
parente commented 8 years ago

Thanks for the browser trace..

Is there anything in the log before that? I've seen https://github.com/jupyter/notebook/issues/1602 , a timing issue, prevent loading of some JS assets on startup. It could be the culprit. A copy/paste attachment of the full browser console when you do the clear/restart/refresh/run-all would help us pinpoint whether this is the case or not. Or even a screenshot of the full browser console.

I just tried to reproduce what you're seeing with:

jupyter-dashboards==0.6.0
jupyter-declarativewidgets==0.6.1
ipywidgets==5.1.5
notebook=4.2.0
ipykernel==4.3.1

and

Chrome Version 51.0.2704.103 (64-bit)
Firefox 45.0.2

but could not hit the problem using @dalogsdon's example. Here's what I get:

firefox-widgets

chrome-widgets

osdf commented 8 years ago

With the dashboard _un_installed, I see the same behaviour in Firefox as your Firefox screencast.

This is the console output:

Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead main.min.js:84:0
Default extension for cell metadata editing loaded. main.min.js:24135:9
Raw Cell Format toolbar preset loaded. main.min.js:24221:5
Slideshow extension for metadata editing loaded. main.min.js:24269:9
Use of Mutation Events is deprecated. Use MutationObserver instead. main.min.js:88:7259
Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. main.min.js:88:12747
actions jupyter-notebook:find-and-replace does not exist, still binding it in case it will be defined later... main.min.js:29057:17
load_extensions Arguments { , 4 more… } main.min.js:12154:9
Loading extension: declarativewidgets/js/main main.min.js:12131:21
Session: kernel_created (c524716a-184b-4b55-b1c2-bf51bc3af496) main.min.js:23423:13
Starting WebSockets: "ws://localhost:8888/api/kernels/5a0bcd37-5e85-4146-93f9-b4910af7446c" main.min.js:22709:9
Loading extension: widgets/notebook/js/extension main.min.js:12131:21
loaded widgets extension.js:81:9
loaded declarativewidgets main.js:50:17
Server extension is available! init.js:198:13
Components root is:  /urth_components init.js:34:9
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create data:(function%20()%20%7B%0Afunction%20resolve()%20%7B%0Adocument.body.removeAttribute('unresolved'):280:1
Kernel: kernel_connected (5a0bcd37-5e85-4146-93f9-b4910af7446c) main.min.js:22356:13
Kernel: kernel_ready (5a0bcd37-5e85-4146-93f9-b4910af7446c) main.min.js:22356:13
Declarative widgets connected. main.min.js:9:37
Use of attributes' nodeValue attribute is deprecated. Use value instead. data:%0A%20%20%20%20(function()%7B%0A%20%20%20%20'use%20strict'%3B%0A%0A%20%20%20%20%20%20%20%20var%:318:31
urth-core-function: Error while getting function signature: Invalid function name load_selection error-display-behavior.html.js:37:17

Declarative widgets connected. main.min.js:9:37

With the dashboard installed this is the console:

Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead main.min.js:84:0
Default extension for cell metadata editing loaded. main.min.js:24135:9
Raw Cell Format toolbar preset loaded. main.min.js:24221:5
Slideshow extension for metadata editing loaded. main.min.js:24269:9
Use of Mutation Events is deprecated. Use MutationObserver instead. main.min.js:88:7259
Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. main.min.js:88:12747
actions jupyter-notebook:find-and-replace does not exist, still binding it in case it will be defined later... main.min.js:29057:17
load_extensions Arguments { , 5 more… } main.min.js:12154:9
Loading extension: declarativewidgets/js/main main.min.js:12131:21
Session: kernel_created (b084ad05-40c2-467e-ae66-39373408311b) main.min.js:23423:13
Starting WebSockets: "ws://localhost:8888/api/kernels/7e762c60-a0d0-4438-b8cc-d97cefd43aa6" main.min.js:22709:9
Loading extension: jupyter_dashboards/notebook/main main.min.js:12131:21
jupyter_dashboards loaded main.js:16:13
loaded declarativewidgets main.js:50:17
Server extension is available! init.js:198:13
Kernel: kernel_connected (7e762c60-a0d0-4438-b8cc-d97cefd43aa6) main.min.js:22356:13
Kernel: kernel_ready (7e762c60-a0d0-4438-b8cc-d97cefd43aa6) main.min.js:22356:13
Components root is:  /urth_components init.js:34:9
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create data:(function%20()%20%7B%0Afunction%20resolve()%20%7B%0Adocument.body.removeAttribute('unresolved'):280:1
TypeError: Urth.kernel.widget_manager is undefined
 data:%0A%20%20%20%20(function()%20%7B%0A%20%20%20%20%20%20%20%20'use%20strict'%3B%0A%20%20%20%20%20%:39:17
TypeError: Urth.kernel.widget_manager is undefined
 data:%0A%20%20%20%20(function()%20%7B%0A%20%20%20%20%20%20%20%20'use%20strict'%3B%0A%20%20%20%20%20%:39:17
TypeError: Urth.kernel.widget_manager is undefined data:%0A%20%20%20%20(function()%20%7B%0A%20%20%20%20%20%20%20%20'use%20strict'%3B%0A%20%20%20%20%20%:39:17
TypeError: this.channelElement is undefined
 data:%0A%20%20%20%20(function()%20%7B%0A%20%20%20%20%20%20%20%20'use%20strict'%3B%0A%0A%20%20%20%20%:54:17
TypeError: Urth.kernel.widget_manager is undefined
 data:%0A%20%20%20%20(function()%20%7B%0A%20%20%20%20%20%20%20%20'use%20strict'%3B%0A%20%20%20%20%20%:39:17
Widgets are not available.  Please install widgetsnbextension or ipywidgets 4.0

Those Type Errors have more information underneath, about 20 or so lines each, do you need that, too?

dalogsdon commented 8 years ago

Out of curiosity, could you try updating ipywidgets and enabling it's notebook extension manually? I had to do this as part of my setup when looking at this yesterday.

pip install --upgrade ipywidgets
jupyter nbextension enable --py widgetsnbextension
osdf commented 8 years ago

@dalogsdon That did it!! That's so super awesome, really! Thank you some much, guys. It now also works with Chrome.

parente commented 8 years ago

Awesome. So I wonder if we have a weird regression with the older version of ipywidgets. I'll give it a look.

parente commented 8 years ago

I get a failure thats look similar, but perhaps not exactly the same, with ipywidgets 4.x and without installing the dashboard extension: https://github.com/jupyter-incubator/declarativewidgets/issues/442.