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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JupyterLab 3 update #272

Merged
merged 1 commit into from
Jan 4, 2021
Merged

Conversation

martinRenou
Copy link
Member

@martinRenou martinRenou commented Oct 12, 2020

Fix #281, fix #276, fix #268, fix #265

@lgtm-com
Copy link

lgtm-com bot commented Oct 12, 2020

This pull request introduces 3 alerts and fixes 3 when merging 1a62135 into 3372f9b - view on LGTM.com

new alerts:

  • 3 for Unused import

fixed alerts:

  • 2 for Multiple calls to __init__ during object initialization
  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented Oct 12, 2020

This pull request fixes 3 alerts when merging 0d928b6 into 3372f9b - view on LGTM.com

fixed alerts:

  • 2 for Multiple calls to __init__ during object initialization
  • 1 for Module is imported with 'import' and 'import from'

@ianhi
Copy link
Collaborator

ianhi commented Oct 12, 2020

Any idea how/why this fixes the mysterious multiple calls to init alert that showed up in the examples PR?

Also, very excited for this

@martinRenou
Copy link
Member Author

Any idea how/why this fixes the mysterious multiple calls to init alert that showed up in the examples PR?

I have no idea ahah.

Also, very excited for this

Yes! Me too, this will be much simpler for everyone. This PR is not finished yet. I'll finish it tomorrow.

Comment on lines 50 to 57
install_requires=[
'ipykernel>=4.7',
'ipywidgets>=7.5.0',
'matplotlib>=2.0.0'
],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on having an extra_requires: 'lab' that pulls in jupyterlab)widgets so that the install instructions could be:

pip install ipympl
# or for jupyterlab
pip install ipympl[lab]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although I wonder if jupyterlab_widget will be an ipywidgets's dependency. If it's not, we could make it a dependency of ipympl, it's actually not a big dependency so we could ship it just by doing pip install ipympl, I really want to make user's life simple from now on.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was asking about that on gitter awhile ago. see https://gitter.im/jupyter-widgets/Lobby?at=5f7223041c5b0d210ad89905
I think ipywidgets will not require it at least in the immediate future.

I think the issue with requiring it for ipympl is that then you pick up all of jlab as a depdency (at least till the new pip comes out). I still think that thats worth it but I recognize that there are downsides

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One notable comment from that thread:

right now jupyterlab_widgets depends on jupyterlab - I suppose it doesn't have to, though, especially if the peer dependency/run constraint gives the right version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmh I wouldn't have expected that it depends on jlab, I am a bit disappointed. Then I agree with your first proposition.

There might be a hacky workaround for this though, we can maybe depend on jupyterlab_widgets at buildtime, and install the required static files under share and it might work.

@lgtm-com
Copy link

lgtm-com bot commented Oct 13, 2020

This pull request fixes 3 alerts when merging 24353d4 into 3372f9b - view on LGTM.com

fixed alerts:

  • 2 for Multiple calls to __init__ during object initialization
  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented Oct 13, 2020

This pull request fixes 3 alerts when merging d20967b into 3372f9b - view on LGTM.com

fixed alerts:

  • 2 for Multiple calls to __init__ during object initialization
  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented Oct 13, 2020

This pull request fixes 3 alerts when merging 4c4582f into 3372f9b - view on LGTM.com

fixed alerts:

  • 2 for Multiple calls to __init__ during object initialization
  • 1 for Module is imported with 'import' and 'import from'

@martinRenou martinRenou force-pushed the clean_setup branch 2 times, most recently from 6523883 to 65f6239 Compare October 13, 2020 13:43
@lgtm-com
Copy link

lgtm-com bot commented Oct 13, 2020

This pull request fixes 3 alerts when merging 65f6239 into 3372f9b - view on LGTM.com

fixed alerts:

  • 2 for Multiple calls to __init__ during object initialization
  • 1 for Module is imported with 'import' and 'import from'

@martinRenou
Copy link
Member Author

martinRenou commented Oct 13, 2020

@ianhi I think this PR is almost ready, it's working. Although let's wait for an official JupyterLab 3 release before merging and releasing.

@lgtm-com
Copy link

lgtm-com bot commented Oct 13, 2020

This pull request fixes 3 alerts when merging 99cf7f4 into 3372f9b - view on LGTM.com

fixed alerts:

  • 2 for Multiple calls to __init__ during object initialization
  • 1 for Module is imported with 'import' and 'import from'

@ianhi
Copy link
Collaborator

ianhi commented Oct 13, 2020

@martinRenou I couldn't get this to work. Kept running into this error:


~/Documents/jupyter/ipympl/ipympl/backend_nbagg.py in <module>
     25 
     26 here = os.path.dirname(__file__)
---> 27 with open(os.path.join(here, 'static', 'package.json')) as fid:
     28     js_semver = '^%s' % json.load(fid)['version']
     29 

FileNotFoundError: [Errno 2] No such file or directory: '/home/ian/Documents/jupyter/ipympl/ipympl/static/package.json'

I think that these lines need to be changed as well:

with open(os.path.join(here, 'static', 'package.json')) as fid:
js_semver = '^%s' % json.load(fid)['version']

Did you delete the old files in the static directory? If you didn't that may be why it's working for you and not for me.

@martinRenou
Copy link
Member Author

Oh yeah this needs to be changed. Bad that the CI did not catch it.

@ianhi
Copy link
Collaborator

ianhi commented Oct 13, 2020

Adding tests via nbval would have caught that I'm pretty sure

@ianhi
Copy link
Collaborator

ianhi commented Oct 13, 2020

I think this in pytest.ini would do it

[pytest]
testpaths = examples
norecursedirs = node_modules .ipynb_checkpoints
addopts = --nbval --current-env

along wiht pytest and nbval in an extra_requires for test

@lgtm-com
Copy link

lgtm-com bot commented Oct 14, 2020

This pull request fixes 3 alerts when merging 5b29411 into 3372f9b - view on LGTM.com

fixed alerts:

  • 2 for Multiple calls to __init__ during object initialization
  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented Oct 14, 2020

This pull request fixes 3 alerts when merging 3445cdb into 3372f9b - view on LGTM.com

fixed alerts:

  • 2 for Multiple calls to __init__ during object initialization
  • 1 for Module is imported with 'import' and 'import from'

@martinRenou
Copy link
Member Author

@ianhi it should work now

@ianhi
Copy link
Collaborator

ianhi commented Oct 14, 2020

So it does! 🎉 Thanks for this

README.md Outdated
Comment on lines 42 to 46
### Install the JupyterLab extension
### Use in JupyterLab

In order to install the JupyterLab extension `jupyter-matplotlib`, you will first need to install `nodejs`, you can install it with `conda` doing

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things here:

  1. Not sure where we landed on requiring jupyterlab-widgets (looks as though Remove JupyterLab dependency in jupyterlab_widgets jupyter-widgets/ipywidgets#2995 won't happen in the very near future?). But currently ipympl doesn't explicitly depend on it, so it ought to be included in the install instructions.

  2. I agree that it is best to use jlab3 but I bet many people will still use jlab2 for awhile. For example on jlab-git there's even still been the occasional person reporting an error they encountered on jlab1. Maybe we should keep the info but in a separate file than the readme. like installing-for-jlab2.md and link to it from here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This PR cannot be merged as it is anyway.

I suggest we wait for JupyterLab 3 official update and see what decisions are made on jupyterlab_widgets.

I agree

@ianhi
Copy link
Collaborator

ianhi commented Oct 14, 2020

oooh and the dev install instructions for jlab are different now as well right? like labextension develop . --overwrite?

@martinRenou
Copy link
Member Author

Thanks for your reviews @ianhi, that's very much appreciated

@stonebig
Copy link
Contributor

due to windows/npm issue on "fsevent", I can't compile on Windows... having an artifact generated by the CI system would be a nice feature, (like in github.com/altendky/pyqt5-tools/actions/runs/300796583)

Copy link
Collaborator

@ianhi ianhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

below suggested changes to pick up the jlab-widgets dep by way of ipywidgets which depends on it now 🎉

And enjoy vacation :)

Comment on lines 53 to 55
install_requires=[
'ipykernel>=4.7',
'ipywidgets>=7.5.0',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
install_requires=[
'ipykernel>=4.7',
'ipywidgets>=7.5.0',
install_requires=[
'ipykernel>=4.7',
'ipywidgets>=7.6.0',

Copy link
Contributor

@jasongrout jasongrout Dec 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, ipywidgets 7.6 is not available in conda for python 2. If you want to support python 2, don't up this requirement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment @jasongrout, there is no package supporting Python 2 anymore on conda-forge, right? So there should not be any problem increasing the requirement here? The ipympl package won't be available for Python 2 anyway.

@shaielc
Copy link

shaielc commented Dec 27, 2020

Hi, can you edit the readme to show that v0.5.8 is incompatible with jupyterlab 3?
it was a bit confusing getting here.

for anyone getting here from google

downgrade:

pip install -U jupyterlab==2.2.9
jupyter lab clean

then install ipympl using the instructions

setup.py Outdated
Comment on lines 34 to 37
('share/jupyter/nbextensions/jupyter-matplotlib',
'ipympl/nbextension', '*.*'),
('share/jupyter/labextensions/jupyter-matplotlib',
'ipympl/labextension', "*.*"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to @martinRenou the first two changes below seem to be necessary to make the resulting wheel file work.

Suggested change
('share/jupyter/nbextensions/jupyter-matplotlib',
'ipympl/nbextension', '*.*'),
('share/jupyter/labextensions/jupyter-matplotlib',
'ipympl/labextension', "*.*"),
('share/jupyter/nbextensions/jupyter-matplotlib',
'ipympl/nbextension', '**'),
('share/jupyter/labextensions/jupyter-matplotlib',
'ipympl/labextension', "**"),
('share/jupyter/labextensions/jupyter-matplotlib', '.', 'install.json'),

Based on https://github.com/jupyterlab/extension-cookiecutter-ts/blob/50a8b7eaa27af196439ba21cefff3d8237656776/%7B%7Bcookiecutter.python_name%7D%7D/setup.py#L37

Also I added the install.json file (https://github.com/jupyterlab/extension-cookiecutter-ts/blob/master/%7B%7Bcookiecutter.python_name%7D%7D/install.json) which will also need to be created

@ianhi
Copy link
Collaborator

ianhi commented Dec 27, 2020

@shaielc @bjudkewitz I if you'd like to use ipympl wiht jlab3 before this is merged i've created a wheel that works with jlab3 based off this PR that you can install with this command:

pip install https://github.com/ianhi/ipympl/releases/download/0.6.0/ipympl-0.6.0-py2.py3-none-any.whl

@stonebig
Copy link
Contributor

stonebig commented Dec 29, 2020

small remark on ipympl-0.6.0 to be : in classic Jupyter Notebook mode, if you have forgotten to do jupyter.exe nbextension enable --py --sys-prefix ipympl , the notebook remains in deadlock... maybe it was like that before

@snickell
Copy link

Tracking this in issue #281

@GF-Huang
Copy link

GF-Huang commented Jan 3, 2021

@shaielc @bjudkewitz I if you'd like to use ipympl wiht jlab3 before this is merged i've created a wheel that works with jlab3 based off this PR that you can install with this command:

pip install https://github.com/ianhi/ipympl/releases/download/0.6.0/ipympl-0.6.0-py2.py3-none-any.whl

It does not show anything when you call the plt.plot second time.

image

@ianhi
Copy link
Collaborator

ianhi commented Jan 3, 2021

@GF-Huang that's actually expected behavior. In short it's because the very first time you call plt.plot a new figure will be created, but the second time it will reuse the existing figure. If you uncomment the plt.figure then it should work as expected.

I'm happy to try to explain at greater length but lets please talk more about it on https://discourse.matplotlib.org/ so we can keep this PR about the update.

@martinRenou martinRenou force-pushed the clean_setup branch 5 times, most recently from acef3bc to 348959b Compare January 4, 2021 08:06
Signed-off-by: martinRenou <martin.renou@gmail.com>
@martinRenou
Copy link
Member Author

martinRenou commented Jan 4, 2021

This should be ready now (given that CI passes). Will merge and make a release around tonight. Thanks a lot @ianhi for the reviews!

@lgtm-com
Copy link

lgtm-com bot commented Jan 4, 2021

This pull request fixes 4 alerts when merging e31db70 into bd477f5 - view on LGTM.com

fixed alerts:

  • 2 for Multiple calls to __init__ during object initialization
  • 1 for Unused argument in a formatting call
  • 1 for Module is imported with 'import' and 'import from'

@martinRenou martinRenou marked this pull request as ready for review January 4, 2021 08:42
@martinRenou
Copy link
Member Author

Note to self: update binder config to use JupyterLab 3

@martinRenou martinRenou merged commit 17c0bfa into matplotlib:master Jan 4, 2021
@martinRenou martinRenou deleted the clean_setup branch January 4, 2021 16:55
celine168 added a commit to celine168/thebe that referenced this pull request Jan 5, 2021
Removing code block that is not necessary thanks to release 0.6.1 at ipympl: matplotlib/ipympl#272
@romainx romainx mentioned this pull request Jan 8, 2021
3 tasks
@GF-Huang
Copy link

GF-Huang commented Jan 9, 2021

Why I still get Error displaying widget: model not found of ipympl 0.6.2?

image

@martinRenou
Copy link
Member Author

Please open a separate issue, and can you add the output of jupyter labextension list there?

@GF-Huang
Copy link

GF-Huang commented Jan 10, 2021

image

By the way, the docs does not tell me need to install labextensions for jupyterlab 3.x. It seems for 1.x and 2.x.

image

@thomasaarholt
Copy link
Contributor

@GF-Huang please don't comment on merged PRs in this way, as it "pings" people who commented on the thread unnecessarily.

Feel free to open a new issue. Your comment about labextension is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
9 participants