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

jupyter-events break JupyterLab due to lack of jsonschema version pin/incompatibility with newer versions #99

Open
krassowski opened this issue Jun 25, 2024 · 5 comments

Comments

@krassowski
Copy link
Member

See:

But briefly:

Traceback (most recent call last):
  File "/usr/bin/jupyter", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/jupyter_core/command.py", line 261, in main
    mod = __import__(package)
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/jupyterlab/__init__.py", line 8, in <module>
    from .handlers.announcements import (
  File "/usr/lib/python3.11/site-packages/jupyterlab/handlers/announcements.py", line 14, in <module>
    from jupyter_server.base.handlers import APIHandler
  File "/usr/lib/python3.11/site-packages/jupyter_server/base/handlers.py", line 24, in <module>
    from jupyter_events import EventLogger
  File "/usr/lib/python3.11/site-packages/jupyter_events/__init__.py", line 3, in <module>
    from .logger import EVENTS_METADATA_VERSION, EventLogger
  File "/usr/lib/python3.11/site-packages/jupyter_events/logger.py", line 19, in <module>
    from .schema import SchemaType
  File "/usr/lib/python3.11/site-packages/jupyter_events/schema.py", line 18, in <module>
    from .validators import draft7_format_checker, validate_schema
  File "/usr/lib/python3.11/site-packages/jupyter_events/validators.py", line 44, in <module>
    JUPYTER_EVENTS_SCHEMA_VALIDATOR = Draft7Validator(
                                      ^^^^^^^^^^^^^^^^
TypeError: create.<locals>.Validator.__init__() got an unexpected keyword argument 'registry'

As per:

Downgrading jsonschema from the latest 4.20.0 to 4.19.2 solved the issue for me, fyi.

Originally posted by @gokceneraslan in jupyter/jupyter_core#369 (comment)

Current version is 4.22

@aktech
Copy link

aktech commented Sep 3, 2024

Downgrading jsonschema to 4.19.2, didn't work for me. Here is an example github actions run:

In this case it only happens when importing CondaProject (ref). conda-project depends on conda-lock and I suspect, when importing conda-project, it imports conda-lock dependencies and conda-locks vendor dependencies (?) cause this behaviour.

@Orest02
Copy link

Orest02 commented Sep 13, 2024

I agree, I tried all there was on Github issues and StackOverflow, none worked

@NevilleMthw
Copy link

Has this issue been resolved at all? I think there is a compatibility issue with jsonschema and jupyter_events. I have mentioned an issue as well. jupyter/jupyter_core#407

@Zsailer
Copy link
Member

Zsailer commented Feb 3, 2025

I don't think this is due to a lack of a pin.

I tried many things to reproduce this. It's a very subtle issue, but the only way I can see this is if, after installing a Jupyter web application (e.g. Lab or Notebook), I downgrade jsonschema manually to < 4.18. This is consistent with what we'd expect given the backward incompatible API introduced in the jsonschema package in 4.18 (and the deprecation warnings that appeared to signal this change).

This can easily happen if users install a dependency after e.g. JupyterLab that pins jsonschema, thereby downgrading jsonschema to < 4.18. I think a lot of libraries did exactly that (pin jsonschema) when this new "registry" API was released, because it introduced a backwards incompatible change. In Jupyter, we handled this new API and updated our pin in #80.

Any version equal or above jsonschema 4.18 doesn't seem to trigger this issue.

The various threads reporting this issue are difficult to determine what version of jsonschema is running. For example, this comment suggests it happens in a later version; however, they then report after downgrading and upgrading again, things worked. My hunch is that their original report of a higher version (4.20) was inaccurate.

I think the only thing we do here to improve things is add a version check on jsonschema when jupyter_events is imported and raise an error forcing users to upgrade jsonschema. This might cause conflicts with packages that pin jsonschema, but such is life in the Python work 😅. At least, this would be a more clear error.

@krassowski
Copy link
Member Author

Thank you for looking into this!

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

No branches or pull requests

5 participants