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

Support JupyterLab 2.0.0 - plotlywidget #2261

Merged
merged 1 commit into from
Mar 11, 2020

Conversation

consideRatio
Copy link
Contributor

See #2249 (comment)

Attempted fix for #2249, but not tested and mainly a suggestion without deep comprehension. This should had been part of #2245 if I had done it right from the start.

@consideRatio
Copy link
Contributor Author

/cc: @nicolaskruchten being the reviewer of #2245!

@nicolaskruchten
Copy link
Contributor

Thanks @consideRatio ! I tried this last week and while it works in Jlab 2.x it breaks in 1.2... I filed an issue to discuss this over here jupyter-widgets/ipywidgets#2809 ... Are you able to install plotlywidget with this patch and make it work in both JLab 1.2 and JLab 2.0?

@consideRatio
Copy link
Contributor Author

Ah thanks for looping me in @nicolaskruchten! I struggle to overview the situation still.

Dependency overview

To be able to install the latest version of plotlywidget on both JupyterLab 1 and 2, we need to avoid have conflicting dependencies making us request both for example jupyte-widgets/base of two different versions, but also not two different versions of jupyterlab core packages.

plotlywidgets does not directly depend on either JupyterLab 1 or JupyterLab 2 core packages, but it depends on @jupyter-widgets/base. We want it to function with the @jupyter-widgets/base installed as part of the peer dependency @jupyter-widgets/jupyterlab-manager, which will install a @jupyter-widgets/base version depending on its own version, which will be chosen as the latest version supporting the current JupyterLab version through its own dependencies I think.

To test if this change make sense, I figure one would need to.

  1. Install JupyterLab 1
  2. Install @jupyter-widgets/jupyterlab-manager, and verify its version is the latest version with compatible JupyterLab 1 dependencies
  3. Install plotlywidget
  4. Try using plotlywidget

Then, do the same, but starting out by installing JupyterLab 2.

@consideRatio
Copy link
Contributor Author

Reproduce my test

VERSION=1
conda create -y -c conda-forge -n jlab${VERSION} jupyterlab=${VERSION}
conda activate jlab${VERSION}
pip install plotly ipywidgets
jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build

# navigate to this repos packages/javascript/plotlywidget folder
npm install
jupyter labextension install .

jupyter lab

# tests to run in a cell
!jupyter --version
!jupyter labextension list
import plotly.graph_objects as go
go.FigureWidget()

Successful outcome for both JupyterLab 1 and 2

image

@nicolaskruchten
Copy link
Contributor

OK then! I guess the way I was testing it was not sufficiently isolated. I was downgrading JupyterLab from 2 to 1 in the same environment. Thanks for going all the way through all the right motions to make this work :)

@jasongrout
Copy link

jasongrout commented Mar 10, 2020

plotlywidgets does not directly depend on either JupyterLab 1 or JupyterLab 2 core packages, but it depends on @jupyter-widgets/base. We want it to function with the @jupyter-widgets/base installed as part of the peer dependency @jupyter-widgets/jupyterlab-manager, which will install a @jupyter-widgets/base version depending on its own version, which will be chosen as the latest version supporting the current JupyterLab version through its own dependencies I think.

Yes, basically that's the idea. The lab manager will pull in the correct version of the base package, so you just need to allow either base package version, and the lab manager will pick the one that works with your jupyterlab version.

This relies on JupyterLab correctly and completely deduplicating packages in the build process.

@nicolaskruchten nicolaskruchten self-requested a review March 10, 2020 19:22
@nicolaskruchten
Copy link
Contributor

OK this is lovely, thanks everyone for bearing with my bad testing practices and helping out, it's much-appreciated! I'm planning on pushing out another patch release tomorrow with this fix

@nicolaskruchten nicolaskruchten merged commit 15ab76f into plotly:master Mar 11, 2020
@nicolaskruchten
Copy link
Contributor

nicolaskruchten commented Mar 11, 2020

OK, so I built and published version 1.5.4-rc1 of plotlywidget using this change, and trying to install it into clean environments actually fails in both 1.2 and 2.0. I'm pretty puzzled as to why.

JLab 1.2 test sequence

conda create -y -c conda-forge -n jlab1 jupyterlab=1.2
conda activate jlab1
pip install plotly ipywidgets
jupyter labextension install @jupyter-widgets/jupyterlab-manager@1.1 jupyterlab-plotly@1.5.3 plotlywidget@1.5.4-rc1
jupyter lab

JLab 2.0 test sequence

conda create -y -c conda-forge -n jlab2 jupyterlab=2.0
conda activate jlab2
pip install plotly ipywidgets
nvm use 12
jupyter labextension install @jupyter-widgets/jupyterlab-manager@2.0 jupyterlab-plotly@1.5.3 plotlywidget@1.5.4-rc1
jupyter lab

@nicolaskruchten
Copy link
Contributor

Ah hang on, this might be because the version of the widget doesn't match what plotly expects?

@jasongrout
Copy link

Ah hang on

As in you want to investigate this a bit further and post results?

@nicolaskruchten
Copy link
Contributor

Yes, sorry. I think that's what it was... I didn't realize just how coupled plotly and plotlywidget are.

@nicolaskruchten
Copy link
Contributor

OK yes, if I set https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/_widget_version.py to match the exact version including the rc string and reload then everything works properly. I thought I could test plotlywidget 1.5.4-rc1 with plotly 4.5.3 but apparently not.

@jasongrout
Copy link

Yeah, you're running into two different things:

  1. Usually a package would have ^1.5.3 there to pull in the appropriate semver range of 1.x. However, that will not pull in prereleases, per semver, so you'd have to have ^1.5.4-rc1
  2. The bigger problem here is that the backend is tightly coupled to the version of the frontend. A better way is to couple the backend to the data model version. In this case, the data model doesn't change, so that number wouldn't change. However, this introduces other complications with, for example, getting the plotly js in the html manager. We've had long discussions about this, and what is best and what is most practical/simplest in the ipywidgets dev community.

@nicolaskruchten
Copy link
Contributor

Thanks for the extra info @jasongrout ! I'm new to the release process of plotly and associated bundles and this coupling was mentioned during the handoff but I'd never stubbed my toe on it until now :)

Sorry for the multiple false alarms.

@jtlz2
Copy link

jtlz2 commented Apr 3, 2020

@nicolaskruchten Thanks, but still no joy here :(

nvm use 12
pip install plotly ipywidgets jupyterlab==2.0
jupyter labextension install @jupyter-widgets/jupyterlab-manager@2.0 jupyterlab-plotly@1.5.3 plotlywidget@1.5.4-rc1 --debug

gives the below. I can't (I think) use a venv because I'm running in a jupyterhub container (I can't even work out how to restart jupyter lab without inadvertently killing the pod).

Searching ['/home/jovyan', '/home/jovyan/.jupyter', '/opt/conda/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
Looking for jupyter_config in /etc/jupyter
Looking for jupyter_config in /usr/local/etc/jupyter
Looking for jupyter_config in /opt/conda/etc/jupyter
Looking for jupyter_config in /home/jovyan/.jupyter
Looking for jupyter_config in /home/jovyan
Node v8.10.0

Yarn configuration loaded.
> /opt/conda/bin/npm pack @jupyter-widgets/jupyterlab-manager@2.0
\jupyter-widgets-jupyterlab-manager-2.0.0.tgz

Node v8.10.0

Yarn configuration loaded.
> /opt/conda/bin/npm pack jupyterlab-plotly@1.5.3
\jupyterlab-plotly-1.5.3.tgz

Node v8.10.0

Yarn configuration loaded.
> /opt/conda/bin/npm pack plotlywidget@1.5.4-rc1
-plotlywidget-1.5.4-rc1.tgz

Node v8.10.0

Yarn configuration loaded.
Building jupyterlab assets (build:prod:minimize)
The extension "@jupyterlab/hub-extension" is outdated.

> node /opt/conda/lib/python3.6/site-packages/jupyterlab/staging/yarn.js install --non-interactive
/yarn install v1.21.1
[1/5] Validating package.json...
[2/5] Resolving packages...
warning jupyterlab-plotly > plotly.js > regl-splom > left-pad@1.3.0: use String.prototype.padStart()
warning jupyterlab-plotly > plotly.js > point-cluster > bubleify > buble > os-homedir@2.0.0: This is not needed anymore. Use `require('os').homedir()` instead.
[3/5] Fetching packages...
warning @blueprintjs/core@3.24.0: Invalid bin entry for "upgrade-blueprint-2.0.0-rename" (in "@blueprintjs/core").
warning @blueprintjs/core@3.24.0: Invalid bin entry for "upgrade-blueprint-3.0.0-rename" (in "@blueprintjs/core").
warning sha.js@2.4.11: Invalid bin entry for "sha.js" (in "sha.js").
error marked@0.8.0: The engine "node" is incompatible with this module. Expected version ">= 8.16.2". Got "8.10.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

npm dependencies failed to install
Traceback (most recent call last):

  File "/opt/conda/lib/python3.6/site-packages/jupyterlab/debuglog.py", line 47, in debug_logging
    yield

  File "/opt/conda/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 105, in start
    command=command, app_options=app_options)

  File "/opt/conda/lib/python3.6/site-packages/jupyterlab/commands.py", line 460, in build
    command=command, clean_staging=clean_staging)

  File "/opt/conda/lib/python3.6/site-packages/jupyterlab/commands.py", line 652, in build
    raise RuntimeError(msg)

RuntimeError: npm dependencies failed to install

An error occured.
RuntimeError: npm dependencies failed to install
See the log file for details:  /tmp/jupyterlab-debug-lqg7l6ls.log
Exiting application: jupyter
root@jupyter-jtlz2:~# more /tmp/jupyterlab-debug-lqg7l6ls.log
Node v8.10.0

Yarn configuration loaded.
> /opt/conda/bin/npm pack @jupyter-widgets/jupyterlab-manager@2.0
jupyter-widgets-jupyterlab-manager-2.0.0.tgz

Node v8.10.0

Yarn configuration loaded.
> /opt/conda/bin/npm pack jupyterlab-plotly@1.5.3
jupyterlab-plotly-1.5.3.tgz

Node v8.10.0

Yarn configuration loaded.
> /opt/conda/bin/npm pack plotlywidget@1.5.4-rc1
plotlywidget-1.5.4-rc1.tgz

Node v8.10.0

Yarn configuration loaded.
Building jupyterlab assets (build:prod:minimize)
The extension "@jupyterlab/hub-extension" is outdated.

> node /opt/conda/lib/python3.6/site-packages/jupyterlab/staging/yarn.js install --non-interactive
yarn install v1.21.1
[1/5] Validating package.json...
[2/5] Resolving packages...
warning jupyterlab-plotly > plotly.js > regl-splom > left-pad@1.3.0: use String.prototype.padStart()
warning jupyterlab-plotly > plotly.js > point-cluster > bubleify > buble > os-homedir@2.0.0: This is not needed anymore. Use `require('os').homedir()` i
nstead.
[3/5] Fetching packages...
warning @blueprintjs/core@3.24.0: Invalid bin entry for "upgrade-blueprint-2.0.0-rename" (in "@blueprintjs/core").
warning @blueprintjs/core@3.24.0: Invalid bin entry for "upgrade-blueprint-3.0.0-rename" (in "@blueprintjs/core").
warning sha.js@2.4.11: Invalid bin entry for "sha.js" (in "sha.js").
error marked@0.8.0: The engine "node" is incompatible with this module. Expected version ">= 8.16.2". Got "8.10.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

npm dependencies failed to install
Traceback (most recent call last):

  File "/opt/conda/lib/python3.6/site-packages/jupyterlab/debuglog.py", line 47, in debug_logging
    yield

  File "/opt/conda/lib/python3.6/site-packages/jupyterlab/labextensions.py", line 105, in start
    command=command, app_options=app_options)

  File "/opt/conda/lib/python3.6/site-packages/jupyterlab/commands.py", line 460, in build
    command=command, clean_staging=clean_staging)

  File "/opt/conda/lib/python3.6/site-packages/jupyterlab/commands.py", line 652, in build
    raise RuntimeError(msg)

RuntimeError: npm dependencies failed to install

@consideRatio
Copy link
Contributor Author

@jtlz2 there are newer versions of things out at this point, so locking into plotlywidget@1.5.4-rc1 is probably a bad idea since 1.5.4 is out for example.

Here are versions of relevance:
https://www.npmjs.com/package/jupyterlab-plotly
https://www.npmjs.com/package/@jupyter-widgets/jupyterlab-manager
https://www.npmjs.com/package/plotlywidget

I note also that you got this error:

error marked@0.8.0: The engine "node" is incompatible with this module. Expected version ">= 8.16.2". Got "8.10.0"
error Found incompatible module.

And that you had version 8.10.0 active, so even though you wrote nvm use 12, it seems that is the key issue - why didn't it switch to using node 12?

@nicolaskruchten
Copy link
Contributor

I agree with @consideRatio: the core issue seems to be that this command is running under an outdated version of node.

In addition, yesterday we released Plotly.py 4.6.0 and the corresponding extensions now share version numbers, so you'll likely want the extensions versioned 4.6.0 as well.

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

Successfully merging this pull request may close these issues.

None yet

4 participants