ipywidgets icon indicating copy to clipboard operation
ipywidgets copied to clipboard

Breaking changes in ipywidgets v8 and jupyterlab-widgets v3

Open flekschas opened this issue 3 years ago • 0 comments

Description

I am the developer of a jupyter widgets and I noticed that my widget started to fail with ipywidgets v8 and/or jupyterlab-widgets v3. (What happened to jupyterlab-widgets v2 by the way?)

The error message is:

Model class 'JupyterScatterModel' from module 'jupyter-scatter' is loaded but can not be instantiated

I looked over the ipywidgets v8 changelog but couldn't find anything mentioning of breaking changes. However, one or multiple changes must cause the failing instantiation.

Reproduce

  1. Create the following environment-py39-ipyw8-jlab3.yml
name: jscatter-py39-ipyw8-jlab3

channels:
  - conda-forge
  - defaults

dependencies:
  - python==3.9.*
  - nodejs==16.*
  - numpy
  - pandas
  - pip
  - pip:
    - jupyterlab==3.*
    - ipywidgets==8.*
    - jupyterlab_widgets==3.*
    - jupyter-scatter
  1. Then do
conda env create -f ./environment-py39-ipyw8-jlab3.yml 
conda activate jscatter-py39-ipyw8-jlab3
jupyter-lab
  1. Then run
import numpy as np
import jscatter
jscatter.plot(x=np.random.rand(500), y=np.random.rand(500))

The widget will fail to instantiate.

For comparison, create the environment-py39-ipyw7-jlab1.yml and repeat steps two and three.

name: jscatter-py39-ipyw7-jlab1

channels:
  - conda-forge
  - defaults

dependencies:
  - python==3.9.*
  - nodejs==18.*
  - numpy
  - pandas
  - pip
  - pip:
    - jupyterlab==3.*
    - ipywidgets==7.*
    - jupyterlab_widgets==1.*
    - jupyter-scatter

This time the widget will load as expected.

Expected behavior

The widget should load as expected or at the very least it should throw a useful error message.

If using JupyterLab

  • JupyterLab version: 3.4.8
Installed Labextensions
pyterLab v3.4.8
/Users/me/miniforge3/envs/jscatter-py39-ipyw8-jlab3/share/jupyter/labextensions
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
        jupyter-scatter v0.7.1 enabled OK
        @jupyter-widgets/jupyterlab-manager v5.0.3 enabled OK (python, jupyterlab_widgets)

flekschas avatar Oct 12 '22 02:10 flekschas