jupytext: TypeError: t.currentWidget.context.model.metadata.has is not a function with JupyterLab 4

Hello,

I was trying out JupyterLab 4 (4.0.0b0), and noticed that jupytext doesn’t work. When I open JupyterLab, the browser console gets filled with the following error message several times:

console output
TypeError: t.currentWidget.context.model.metadata.has is not a function
    e http://localhost:8890/lab/extensions/jupyterlab-jupytext/static/568.5f8c2e2ac5a41b57f216.js?v=5f8c2e2ac5a41b57f216:1
    u http://localhost:8890/lab/extensions/jupyterlab-jupytext/static/568.5f8c2e2ac5a41b57f216.js?v=5f8c2e2ac5a41b57f216:1
    isToggled http://localhost:8890/lab/extensions/jupyterlab-jupytext/static/568.5f8c2e2ac5a41b57f216.js?v=5f8c2e2ac5a41b57f216:1
    isToggled http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    get isToggled http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    createItemClass http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    renderItem http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    onUpdateRequest http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    processMessage http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    C http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    r http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    _ http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    n http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    promise callback*37192/n http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    b http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    s http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    update http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    refresh http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    hideAndReset http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    handleEvent http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    onAfterShow http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    processMessage http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    C http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    r http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    show http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    onActivateRequest http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    processMessage http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    C http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    r http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    _ http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    n http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    promise callback*37192/n http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    b http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    s http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    activate http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    execute http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    execute http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    _executeKeyBinding http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    processKeydownEvent http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    evtKeydown http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
    handleEvent http://localhost:8890/static/lab/jlab_core.fb8ee545cf9dfd6b68f1.js?v=fb8ee545cf9dfd6b68f1:1
jlab_core.fb8ee545cf9dfd6b68f1.js:1:1597138

Also, if I open the command palette, the search doesn’t work, and whenever I type something the error appears in the console.

This happens both on Firefox and Chrome.

I can reproduce this with an environment created from scratch:

$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ pip install --pre jupyterlab
(venv) $ pip install jupytext
(venv) $ jupyter --version

IPython          : 8.11.0
ipykernel        : 6.22.0
ipywidgets       : not installed
jupyter_client   : 8.1.0
jupyter_core     : 5.3.0
jupyter_server   : 2.5.0
jupyterlab       : 4.0.0b0
nbclient         : 0.7.2
nbconvert        : 7.2.10
nbformat         : 5.8.0
notebook         : not installed
qtconsole        : not installed
traitlets        : 5.9.0

(venv) $ pip list | grep "jupytext"

jupytext                  1.14.5

(venv) $ jupyter lab

...
[I 2023-03-29 13:46:33.070 ServerApp] jupytext | extension was successfully linked.
...

If I leave out --pre from pip install jupyterlab, I get jupyterlab 3.6.2 and this doesn’t happen.

I’m not familiar with extension development, I briefly tried to look through the jupyter extension migration guide, but I couldn’t see anything obvious related to this.

I’m on ubuntu 20.04. Let me know if you need more information.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 26 (17 by maintainers)

Most upvoted comments

I have seen the tentative version of the extension working with Jupyter Lab 4 - thank you so much @parmentelat!

This is how I installed it:

# Install jupytext
pip install jupytext

# Uninstall the extension 1.3.9 binded with Jupytext (that one only works with JLab 3)
jupyter labextension uninstall jupytext

# Install the development version of the extension
pip install git+https://github.com/mwouts/jupyterlab-jupytext.git@jupyterlab4

In the coming days, I would like to

  • See how we can fix the option to open text notebooks with a double click (cf @parmentelat 's comment above)
  • Understand if we can continue shipping the new extension directly within Jupytext, or not
  • If we have to move it to the other repository, then I’d like to keep the full history of index.ts there

I’ve seen this! And it matters a lot to me, but I also happen to have a full-time day job.

I will see what I can do, but any help here would be much appreciated 😀

This has been solved in jupytext==1.15.0. Thanks to @parmentelat , the embedded extension is now compatible with both JLab 3 and 4!

Those who installed the temporary workaround will need to uninstall it. In other words, the new instructions are

pip uninstall jupyterlab-jupytext
pip install 'jupytext>=1.15.0'

I am trying to follow the extension tutorial.

Since the extension tutorial seems to require that the extension has its own repository, I have unarchived https://github.com/mwouts/jupyterlab-jupytext/ (Q: if I package the extension separately from jupytext, I will probably have to take a dependency from jupytext onto jupyterlab-jupytext to get the extension installed automatically?)

The corresponding PR is https://github.com/mwouts/jupyterlab-jupytext/pull/3, however I have not yet been able to test it. The command pip install -ve . fails with an error that seems similar to https://github.com/jupyterlab/jupyterlab/issues/13224. I have tried to run jlpm cache clean but the issue remains. Any suggestion?

I guess this is why the jupytext commands not showing up in jupyterlab. Got confused when commands not shown like the docs said, until seeing this issue.