jupyter / dashboards

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

404 GET ..../bower_components.... #181

Closed aiguofer closed 8 years ago

aiguofer commented 8 years ago

I installed this using pip as explained in the README. Unfortunately, when I load a notebook I get some messages like:

[W 11:05:35.364 NotebookApp] 404 GET /nbextensions/jupyter_dashboards/notebook/bower_components/requirejs-text/text.js.js (10.13.49.2) 4.69ms referer=<path_to_notebook>.ipynb
[W 11:22:10.794 NotebookApp] 404 GET /nbextensions/jupyter_dashboards/notebook/bower_components/lodash/lodash.js.js (10.13.49.2) 4.61ms referer=<path_to_notebook>.ipynb
[W 11:22:10.814 NotebookApp] 404 GET /nbextensions/jupyter_dashboards/notebook/bower_components/gridstack/dist/gridstack.min.js.js (10.13.49.2) 4.31ms referer=<path_to_notebook>.ipynb

Changing some lines in .local/share/jupyter/nbextensions/jupyter_dashboards/notebook/dashboard-view/dashboard-view.js to:

        paths: {
            Gridstack: require.toUrl('../bower_components/gridstack/dist/gridstack.min'),
            lodash: require.toUrl('../bower_components/lodash/lodash'),
            text: require.toUrl('../bower_components/requirejs-text/text')
            // jquery-ui is already loaded by Notebook, as 'jqueryui' in 4.0.x and 'jquery-ui' in 4.1.x
        },

seems to fix the problem (I just removed the .js extensions).

I'm not sure why I have to do this? I imagine it's working as is for others.

parente commented 8 years ago

Hi @aiguofer. Can you confirm that you ran the jupyter dashboards commands after the pip too to activate the extension?

aiguofer commented 8 years ago

@parente I ran jupyter dashboards activate

parente commented 8 years ago

And the jupyter dashboards install before that? There's 2 commands after the pip. (Sorry if this is a dumb question.)

aiguofer commented 8 years ago

@parente yep, ran jupyter dashboards install --user --overwrite

parente commented 8 years ago

OK. Something going on. Can you share a bit more about your environment? What version of Jupyter Notebook for instance?

I just tried here in a fresh conda environment and didn't hit the issue. So I suspect it's something in the environment:

  565  ~/miniconda3/bin/conda create -n dashboards python=3
  568  source activate dashboards
  569  pip install jupyter
  571  pip install jupyter_dashboards
  572  jupyter dashboards install
  573  jupyter dashboards activate
  574  jupyter notebook

Here's my pip freeze:

dashboards)~ ❯❯❯ pip freeze
appnope==0.1.0
decorator==4.0.6
gnureadline==6.3.3
ipykernel==4.2.2
ipython==4.1.1
ipython-genutils==0.1.0
ipywidgets==4.1.1
Jinja2==2.8
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.1.1
jupyter-console==4.1.0
jupyter-core==4.0.6
jupyter-dashboards==0.4.0
MarkupSafe==0.23
mistune==0.7.1
nbconvert==4.1.0
nbformat==4.0.1
notebook==4.1.0
path.py==8.1.2
pexpect==4.0.1
pickleshare==0.6
ptyprocess==0.5.1
Pygments==2.1
pyzmq==15.2.0
qtconsole==4.1.1
simplegeneric==0.8.1
terminado==0.6
tornado==4.3
traitlets==4.1.0
wheel==0.26.0
aiguofer commented 8 years ago

I have this all installed with pyenv locally:

$ pyenv versions
  system
* 2.7.10 (set by /home/custard/.pyenv/version)
* 3.4.3 (set by /home/custard/.pyenv/version)
$ pip freeze
adhoc==0.1
backports-abc==0.4
backports.ssl-match-hostname==3.5.0.1
bokeh==0.9.3
certifi==2015.11.20.1
colorama==0.3.3
custard==0.1
cx-Oracle==5.2
decorator==4.0.6
docopt==0.4.0
easywebdav==1.2.0
ecdsa==0.11
email==4.0.2
Fabric==1.10.1
fastavro==0.7.9
Flask==0.10.1
funcsigs==0.4
functools32==3.2.3.post2
greenlet==0.4.9
importlib==1.0.3
ipykernel==4.2.2
ipython==4.1.0rc1
ipython-genutils==0.1.0
ipywidgets==4.1.1
itsdangerous==0.24
Jinja2==2.8
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.1.1
jupyter-cms==0.4.0
jupyter-console==4.0.3
jupyter-core==4.0.6
jupyter-dashboards==0.4.0
jupyter-dashboards-bundlers==0.2.1
Lasagne==0.1.dev0
mailchimp==2.0.9
mandrill==1.0.57
Markdown==2.6.2
MarkupSafe==0.23
matplotlib==1.4.3
matplotlib-venn==0.11
mistune==0.7.1
mock==1.3.0
MySQL-python==1.2.5
nbconvert==4.1.0
nbformat==4.0.1
nose==1.3.7
notebook==4.1.0
numpy==1.9.1
oursql==0.9.3.1
pandas==0.16.2
paramiko==1.15.2
path.py==8.1.2
patsy==0.4.0
pbr==1.4.0
pexpect==4.0.1
pickleshare==0.6
plotly==1.8.3
powerline-status==2.2
psutil==3.2.2
psycopg2==2.6.1
ptyprocess==0.5
pycountry==1.14
pycrypto==2.6.1
Pygments==2.1
pymongo==2.7.2
pyparsing==2.0.3
pystache==0.5.4
python-dateutil==2.4.0
pytz==2014.10
PyYAML==3.11
pyzmq==15.2.0
qtconsole==4.1.1
redshift-sqlalchemy==0.4.1
renewal-analytics==0.1
requests==2.5.1
requests-toolbelt==0.4.0
rpy2==2.6.1
scandir==1.2
scikit-learn==0.16.1
scipy==0.16.0
seaborn==0.6.0
simplegeneric==0.8.1
simplejson==3.5.3
singledispatch==3.4.0.3
six==1.9.0
SQLAlchemy==0.9.7
statsmodels==0.6.1
terminado==0.6
Theano==0.7.0
tornado==4.3
traitlets==4.1.0
unicodecsv==0.9.4
urllib3==1.10
Werkzeug==0.10.4
Whoosh==2.7.0
aiguofer commented 8 years ago

Possibly related, jupyter_dashboards_bundlers is also not working for me. I did:

pip install jupyter_dashboards_bundlers
jupyter dashboards_bundlers activate

but the options don't show up under the File menu.

parente commented 8 years ago

Did you build the source/dist bundle yourself and install that? Or did you install the latest stable version released on PyPI?

parente commented 8 years ago

Not able to reproduce with a fresh pyenv either. :/

  665  pyenv local 3.4.3
  666  which python
  667  python
  668  pip install jupyter
  669  pip install jupyter_dashboards
  670  jupyter dashboards install --user --symlink --overwrite
  671  jupyter dashboards activate
  672  cd /tmp
  673  jupyter notebook

It seems like a requirejs with a different behavior for require.toUrl is getting picked up from somewhere. It's 2.1.22 in the latest stable release. A fresh checkout and make js pulls the same version. And we're both on 4.1 of the notebook, so even requirejs is getting pulled from there, it would match.

I'm stumped.

aiguofer commented 8 years ago

I'm installing latest from PyPI with pip... this is really strange, tracing the code in the browser shows me it's using 2.1.22 require.js. I'll try to find more from the browser console and report what I find.

parente commented 8 years ago

To get stranger: what browser are you using?

aiguofer commented 8 years ago

This happens in both firefox 44 and chrome 48 on Fedora 23.

So I think I've found where the problem lies. Could you help to see if you get the same?

Debugging in a notebook page with Chrome, if I set a conditional breakpoint in line 1667 of require.js (the line is url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));) with condition url.indexOf('requirejs-text') > -1, I see this function getting called multiple times.

The first time, it's called by context.makeRequire.mixin.toUrl with ext='.js' and skipExt=true, which I seems like the correct behavior.

The following times, it's called by makeModuleMap without ext and skipExt, causing it to add .js again to the url.

Could you please see if you experience the same behavior?

aiguofer commented 8 years ago

hmmm, from reading their documentation it seems like the right way to do it is excluding the extension, although I've never used require.js myself. It's still strange that we're getting different behaviors.

parente commented 8 years ago

@aiguofer I think I tried excluding the extension and got the opposite error, that gridstack.min could not be found for example. But I'll try it again.

Agreed it's strange that the behavior is different regardless.

parente commented 8 years ago

Re-confirmed that if I remove the .js extensions:

screen shot 2016-02-14 at 8 38 59 pm

Exactly the opposite behavior of @aiguofer.

I went to reproduce the debugging steps but found that line 1667 is not the same as the one reported above. Deepens my suspicion that a "wrong" requirejs is being picked up from somewhere.

screen shot 2016-02-14 at 8 40 38 pm
parente commented 8 years ago

When I do break on line 1655 in my clean master branch, I see exactly one call for the require-text/text module with ext=true and skipExt=true.

aiguofer commented 8 years ago

hmm, do you have IPython Notebook Extensions installed? that might have something to do with it.

parente commented 8 years ago

I'm testing this in a clean jupyter profile and clean browser with no other extensions for Jupyter or Chrome running. Do you have anything else installed? Could be we have a bad interaction.

aiguofer commented 8 years ago

I just tried running it with a fresh pyenv, clean jupyter profile, only jupyter and jupyter_dashboards installed, and opening it in an incognito chrome window with all extensions disabled and I'm still getting the same error. I'm stumped....

The only 2 require.js files in that pyenv are:

 ~/jupyter_test $ find ~/.pyenv/versions/2.7.10 -iname require.js
~/.pyenv/versions/2.7.10/lib/python2.7/site-packages/notebook/static/components/requirejs/require.js
~/.pyenv/versions/2.7.10/lib/python2.7/site-packages/jupyter_dashboards/nbextension/notebook/bower_components/requirejs/require.js

Both files are the same, and I still see that same line at line 1667

 ~/jupyter_test $ grep -n "url +=" ~/.pyenv/versions/2.7.10/lib/python2.7/site-packages/notebook/static/components/requirejs/require.js
1667:                    url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));
 ~/jupyter_test $ grep -n "url +=" ~/.pyenv/versions/2.7.10/lib/python2.7/site-packages/jupyter_dashboards/nbextension/notebook/bower_components/requirejs/require.js
1667:                    url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));
aiguofer commented 8 years ago

When you're looking in your browser console, what version is listed on the comments at the top of require.js?

parente commented 8 years ago

Using a fresh notebook server from the tmpnb site we run (http://jupyer.cloudet.xyz) as a reference instead of my local box this time.

Can you try using one of the samples there too if you haven't already, just to confirm it's an install problem not a browser problem at runtime? Here's a link directly to the notebook I used to test. When you visit it, tmpnb should assign you a new notebook server.

http://jupyter.cloudet.xyz/notebooks/dashboards/got_scotch_demo/scotch_dashboard.ipynb

Top of the require.js in the Jupyter Notebook 4.1.0 server running there.

/** vim: et:ts=4:sw=4:sts=4
 * @license RequireJS 2.1.22 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
 * Available via the MIT or new BSD license.
 * see: http://github.com/jrburke/requirejs for details
 */

Output of pip freeze with version of jupyter_dashboards shown:

backports-abc==0.4
conda==3.19.1
conda-env==2.4.5
cycler==0.9.0
decorator==4.0.6
futures==3.0.3
ipykernel==4.2.2
ipython==4.0.3
ipython-genutils==0.1.0
ipywidgets==4.1.1
Jinja2==2.8
jsonschema==2.4.0
jupyter==1.0.0
jupyter-client==4.1.1
jupyter-cms==0.4.0
jupyter-console==4.1.0
jupyter-core==4.0.6
jupyter-dashboards==0.4.1
jupyter-dashboards-bundlers==0.2.2
jupyter-declarativewidgets==0.3.1
MarkupSafe==0.23
matplotlib==1.5.1
mistune==0.7.1
nbconvert==4.1.0
nbformat==4.0.1
nose==1.3.7
notebook==4.1.0
numpy==1.10.4
pandas==0.17.1
path.py==0.0.0
pexpect==3.3
pickleshare==0.5
ptyprocess==0.5
pycosat==0.6.1
Pygments==2.1
pyparsing==2.0.3
python-dateutil==2.4.2
pytz==2015.7
PyYAML==3.11
pyzmq==15.2.0
qtconsole==4.1.1
requests==2.9.1
scandir==1.2
scikit-learn==0.16.1
scipy==0.17.0
seaborn==0.7.0
simplegeneric==0.8.1
six==1.10.0
terminado==0.5
tornado==4.3
traitlets==4.1.0
wheel==0.29.0
Whoosh==2.7.0

Lines 27-29 of dashboards-view.js after loading the /notebooks/dashboards/got_scotch_demo/scotch_dashboard.ipynb sample on the server:

            Gridstack: require.toUrl('../bower_components/gridstack/dist/gridstack.min.js'),
            lodash: require.toUrl('../bower_components/lodash/lodash.js'),
            text: require.toUrl('../bower_components/requirejs-text/text.js')

Console right after page load (no errors):

screen shot 2016-02-16 at 11 36 06 am

What I see in Layout Dashboard mode:

screen shot 2016-02-16 at 11 39 17 am

aiguofer commented 8 years ago

Interesting, that site is working just fine for me. The main difference I see when tracing through is that in my local version it's not appending ?v=<timestamp> to the text.js file.

Here's a diff of our pip freeze output:

diff --git a/local_freeze.txt b/external_freeze.txt
index 3ee53ef..5f79127 100644
--- a/local_freeze.txt
+++ b/external_freeze.txt
@@ -1,34 +1,53 @@
 backports-abc==0.4
-backports.ssl-match-hostname==3.5.0.1
-certifi==2015.11.20.1
-decorator==4.0.9
-functools32==3.2.3.post2
+conda==3.19.1
+conda-env==2.4.5
+cycler==0.9.0
+decorator==4.0.6
+futures==3.0.3
 ipykernel==4.2.2
-ipython==4.1.1
+ipython==4.0.3
 ipython-genutils==0.1.0
 ipywidgets==4.1.1
 Jinja2==2.8
-jsonschema==2.5.1
+jsonschema==2.4.0
 jupyter==1.0.0
 jupyter-client==4.1.1
+jupyter-cms==0.4.0
 jupyter-console==4.1.0
 jupyter-core==4.0.6
 jupyter-dashboards==0.4.1
+jupyter-dashboards-bundlers==0.2.2
+jupyter-declarativewidgets==0.3.1
 MarkupSafe==0.23
+matplotlib==1.5.1
 mistune==0.7.1
 nbconvert==4.1.0
 nbformat==4.0.1
+nose==1.3.7
 notebook==4.1.0
-path.py==8.1.2
-pexpect==4.0.1
-pickleshare==0.6
-ptyprocess==0.5.1
-Pygments==2.1.1
+numpy==1.10.4
+pandas==0.17.1
+path.py==0.0.0
+pexpect==3.3
+pickleshare==0.5
+ptyprocess==0.5
+pycosat==0.6.1
+Pygments==2.1
+pyparsing==2.0.3
+python-dateutil==2.4.2
+pytz==2015.7
+PyYAML==3.11
 pyzmq==15.2.0
 qtconsole==4.1.1
+requests==2.9.1
+scandir==1.2
+scikit-learn==0.16.1
+scipy==0.17.0
+seaborn==0.7.0
 simplegeneric==0.8.1
-singledispatch==3.4.0.3
 six==1.10.0
-terminado==0.6
+terminado==0.5
 tornado==4.3
 traitlets==4.1.0
+wheel==0.29.0
+Whoosh==2.7.0
jhpedemonte commented 8 years ago

@aiguofer Can you please try this:

        paths: {
            Gridstack: require.toUrl('../bower_components/gridstack/dist/gridstack.min').split('?')[0],
            lodash: require.toUrl('../bower_components/lodash/lodash').split('?')[0],
            text: require.toUrl('../bower_components/requirejs-text/text').split('?')[0]
            // jquery-ui is already loaded by Notebook, as 'jqueryui' in 4.0.x and 'jquery-ui' in 4.1.x
        },
aiguofer commented 8 years ago

that works! :+1:

parente commented 8 years ago

So it's the ?v=<timestamp> that was killing us (or the lack thereof). Ugh.

Thanks for bearing with us @aiguofer. Good catch @jhpedemonte. If you submit it as a PR, we'll get it into 0.4.2 along with that one other styling bug fix (if it's reasonable to do that one too).