Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IPython progress bar in notebook versions >= 4 #1088

Merged
merged 1 commit into from
Jun 23, 2016
Merged

Conversation

jgosmann
Copy link
Collaborator

@jgosmann jgosmann commented Jun 10, 2016

Description:
Updates the Jupyter notebook extension to be compatible with notebook and ipywidget versions >= 4, including notebook 4.2 and ipywidgets 5. Also gives a better exception when ipywidgets is not installed.

Motivation and context:
They keep changing their API. 馃槨
Fixes #1085. Adresses discussion in #1084 (but not the issue itself).

How has this been tested?
Manually by creating virtualenvs with different IPython/Jupyter/ipywidgets versions.

Where should a reviewer start?
The single file that has been changed. duh

How long should this take to review?

  • Average (neither quick nor lengthy)

Types of changes:

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the CONTRIBUTING.rst document.
  • I have updated the documentation accordingly.
  • I have included a changelog entry.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@jgosmann
Copy link
Collaborator Author

  • As said in Document nengo.ipynb聽#1084 there should be some more documentation, but I don't think it needs to be part of this PR.
  • I don't see a good way to do automated testing of this.
  • Waiting for the tests to pass on Travis (don't expect them to fail).

@jgosmann jgosmann mentioned this pull request Jun 11, 2016
12 tasks
@tbekolay tbekolay self-assigned this Jun 11, 2016
@tbekolay tbekolay removed their assignment Jun 22, 2016
@tbekolay
Copy link
Member

Looked this over and tested it in the newest version of jupyter. Doesn't work in master, works in this branch, so this looks good to me! Will merge on second review... nominating @drasmuss as this is pretty small code-wise and would be good to ensure it works in Windows.

@drasmuss
Copy link
Member

drasmuss commented Jun 23, 2016

When I run this I don't get any progress bar, and this error shows up in the console:

[W 12:47:44.292 NotebookApp] 403 GET /static/widgets/js/widget.js?v=20160623124723 (::1): widgets\js\widget.js is not in root static directory
[W 12:47:44.298 NotebookApp] 403 GET /static/widgets/js/widget.js?v=20160623124723 (::1) 6.52ms referer=http://localhost:8888/notebooks/spa/convolution.ipynb

Note: that is if I use the version of the notebook from the repo. If I convert the notebook to 4.0 (by saving it) and then run it, there is no error message but still no progress bar.

@jgosmann
Copy link
Collaborator Author

Can you give me your pip freeze output?

@jgosmann jgosmann self-assigned this Jun 23, 2016
@drasmuss
Copy link
Member

>pip freeze
backports.shutil-get-terminal-size==1.0.0
colorama==0.3.6
cycler==0.10.0
decorator==4.0.10
flake8==2.5.4
ipykernel==4.3.1
ipython==4.2.0
ipython-genutils==0.1.0
ipywidgets==4.1.1
Jinja2==2.8
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.3.0
jupyter-console==4.1.1
jupyter-core==4.1.0
MarkupSafe==0.23
matplotlib==1.5.1
mccabe==0.4.0
mistune==0.7.2
nbconvert==4.2.0
nbformat==4.0.1
-e git+https://github.com/nengo/nengo@6ba0aa91ac1ef5ee1ee7ef470f0e25a4418ab012#egg=nengo
-e git+https://github.com/nengo/nengo_gui@f5958e56919b5d13278059993014e2ec2bebcef1#egg=nengo_gui
notebook==4.2.1
numpy==1.10.4
path.py==0.0.0
pep8==1.7.0
pickleshare==0.7.2
py==1.4.31
pyflakes==1.0.0
Pygments==2.1.3
pyparsing==2.1.0
pyreadline==2.1
pytest==2.8.7
python-dateutil==2.5.0
pytz==2015.7
pyzmq==15.2.0
qtconsole==4.2.1
simplegeneric==0.8.1
six==1.10.0
Sphinx==1.3.1
tornado==4.3
traitlets==4.2.1
wheel==0.29.0

This is python 3.5, anaconda

@jgosmann
Copy link
Collaborator Author

Does it work if you execute jupyter nbextension enable --py --sys-prefix widgetsnbextension and restart the notebook server?

@drasmuss
Copy link
Member

That command gives ImportError: No module named 'widgetsnbextension'

@jgosmann
Copy link
Collaborator Author

Install widgetsnbextension. Then try if it works. If not try the jupyter nbextension ... command and see if that then works.

@drasmuss
Copy link
Member

Still doesn't work, but new error now:

[IPKernelApp] ERROR | No such comm target registered: jupyter.widget.version
[IPKernelApp] ERROR | No such comm target registered: jupyter.widget.version

@jgosmann
Copy link
Collaborator Author

I can't reproduce the problem (using an Anaconda install on Windows 8). How did you install your Python etc?

@drasmuss
Copy link
Member

All just standard virtualenv setup through Anaconda. It's Windows 10, but I'd be surprised if that made a difference.

@drasmuss
Copy link
Member

drasmuss commented Jun 23, 2016

Here's the steps that reproduce the error for me:

> conda create -n tmp2 python=3.5 numpy jupyter matplotlib
> activate tmp2
> python setup.py develop  # (installing nengo)
> pip install widgetsnbextension
> jupyter nbextension enable --py --sys-prefix widgetsnbextension
> jupyter notebook

@hunse
Copy link
Collaborator

hunse commented Jun 23, 2016

Can we pull this out of 2.1.1? I'd like to get that released, since it helps me with some Nengo OCL stuff a lot.

@jgosmann
Copy link
Collaborator Author

Might as well put it in and do another fix in a later release?
I think this should fix most problems, just not all problems. Or is the progress bar working with master for @drasmuss ?

@drasmuss
Copy link
Member

No, doesn't work in master either.

@hunse
Copy link
Collaborator

hunse commented Jun 23, 2016

Ok, yeah, that makes sense to put it in then.

@jgosmann
Copy link
Collaborator Author

@drasmuss: Can you update ipywidgets to version >= 5?

@drasmuss
Copy link
Member

That did the trick, works with ipywidgets 5. Is there a reason that the standard jupyter install uses version 4 instead of 5, or just waiting on them to update their requirements?

Anyway, I think this is good to merge, as it's at least >= to the behaviour in master. Just two possible comments come to mind:

  1. Should we add widgetsnbextension and ipywidgets>=5 to requirements-optional.txt? I'm not really clear whether these are actually requirements, or just requirements on my system.
  2. Is it possible to automate whatever jupyter nbextension enable --py --sys-prefix widgetsnbextension is doing?

@drasmuss
Copy link
Member

Actually it looks like widgetsnbextension comes with ipywidgets>=5, so ipywidgets>=5 is the only requirement. Here are the working install steps, for posterity:

> conda create -n tmp2 python=3.5 numpy jupyter matplotlib
> activate tmp2
> python setup.py develop
> pip install ipywidgets --upgrade
> jupyter nbextension enable --py --sys-prefix widgetsnbextension
> jupyter notebook

@jgosmann
Copy link
Collaborator Author

I'm not sure if the combination of ipywidgets 4.1.1 and notebook 4.2 is actually supported by Jupyter in any way. The say what notebook version is required by which ipywidgets version, but not the other way around. Anyways, I don't think it is worth making the code more complicated trying to get those particular versions to work. Maybe we can print a warning if we detect these specific version and instruct the user to update ipywidgets.

Is there a reason that the standard jupyter install uses version 4 instead of 5, or just waiting on them to update their requirements?

I will investigate this, but probably they don't state a version and the it fetches the newest version? All my installs end up with version 5 at least.

  1. Should we add widgetsnbextension and ipywidgets>=5 to requirements-optional.txt? I'm not really clear whether these are actually requirements, or just requirements on my system.

These are actual requirements for the IPython progress bar.

  1. Is it possible to automate whatever jupyter nbextension enable --py --sys-prefix widgetsnbextension is doing?

I don't think so because otherwise Jupyter would already do it? At least it usually prints a warning telling you to execute that command (given you versions match up). Also, if you install jupyter via a package manager this tends to happen automatically by means of the package manager (but that doesn't apply to pip installs like in a virtualenv).

@drasmuss
Copy link
Member

I will investigate this, but probably they don't state a version and the it fetches the newest version? All my installs end up with version 5 at least.

Not mine

> conda create -n tmp2 python=3.5 jupyter
> activate tmp2
> pip show ipywidgets
---
Metadata-Version: 1.1
Name: ipywidgets
Version: 4.1.1
...

@tbekolay
Copy link
Member

tbekolay commented Jun 23, 2016

Seems like conda's jupyter recipe is lagging behind jupyter... I'm inclined not to add anything to requirements as it won't be necessary once conda updates its recipes. Also, worst case is just no progress bar, nothing breaks. So... okay for me to merge then?

@jgosmann
Copy link
Collaborator Author

The [Anaconda package list] still lists notebook 4.1.1. Maybe @drasmuss somehow updated notebook without updating ipywidgets?

@drasmuss
Copy link
Member

You can see all the steps I'm following above, I promise I didn't leave anything out. It's just the standard anaconda jupyter installation.

@tbekolay
Copy link
Member

The current ipywidgets recipe; note the 4.1.1.

@jgosmann
Copy link
Collaborator Author

Indeed, should we create an upstream issue?

@tbekolay
Copy link
Member

Will merge when @jgosmann removes his assignment 馃憤 (squash commit looks good to me btw)

@jgosmann jgosmann removed their assignment Jun 23, 2016
@jgosmann
Copy link
Collaborator Author

Sorry, forgot to unassign myself. Go ahead. :)

The extension will warn when incompatible notebook and ipywidgets
versions are installed.

Fixes #1085. Addresses #1084.
@tbekolay tbekolay merged commit c0643d5 into master Jun 23, 2016
@tbekolay tbekolay deleted the fix-ipy-progress branch June 23, 2016 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Notebook progress bar does not show up in most recent Jupyter version.
4 participants