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

jupyterhub/tests/test_singleuser.py::test_singleuser_app_class[notebook.notebookapp.NotebookApp] fails with dev traitlets #4418

Closed
manics opened this issue Apr 16, 2023 · 7 comments
Labels

Comments

@manics
Copy link
Member

manics commented Apr 16, 2023

Bug description

jupyterhub/tests/test_singleuser.py::test_singleuser_app_class[notebook.notebookapp.NotebookApp] fails when dev traitlets are installed

Expected behaviour

JupyterHub CI tests should pass

Actual behaviour

When https://github.com/ipython/traitlets/tree/0505aef059b03bc93638533af9933004ffe23074 is installed in the Python 3.11 main_dependencies test:

if [ "${{ matrix.main_dependencies }}" != "" ]; then
pip install git+https://github.com/ipython/traitlets#egg=traitlets --force
pip install --upgrade --pre sqlalchemy

One test fails, due to:

$ JUPYTERHUB_SINGLEUSER_APP=notebook.notebookapp.NotebookApp python -m jupyterhub.singleuser --help-all

Traceback (most recent call last):
  File "/test/mambaforge/envs/py11/lib/python3.11/site-packages/notebook/traittypes.py", line 235, in _resolve_classes
    klass = self._resolve_string(klass)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/test/mambaforge/envs/py11/lib/python3.11/site-packages/traitlets/traitlets.py", line 1953, in _resolve_string
    return import_item(string)
           ^^^^^^^^^^^^^^^^^^^
  File "/test/mambaforge/envs/py11/lib/python3.11/site-packages/traitlets/utils/importstring.py", line 30, in import_item
    module = __import__(package, fromlist=[obj])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'jupyter_server.contents'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 148, in _get_module_details
  File "<frozen runpy>", line 112, in _get_module_details
  File "/test/work/jupyter/jupyterhub/jupyterhub/singleuser/__init__.py", line 67, in <module>
    from .app import SingleUserNotebookApp, main
  File "/test/work/jupyter/jupyterhub/jupyterhub/singleuser/app.py", line 51, in <module>
    SingleUserNotebookApp = make_singleuser_app(App)
                            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/test/work/jupyter/jupyterhub/jupyterhub/singleuser/mixins.py", line 904, in make_singleuser_app
    empty_parent_app = App()
                       ^^^^^
  File "/test/mambaforge/envs/py11/lib/python3.11/site-packages/traitlets/traitlets.py", line 1239, in __new__
    inst.setup_instance(*args, **kwargs)
  File "/test/mambaforge/envs/py11/lib/python3.11/site-packages/traitlets/traitlets.py", line 1282, in setup_instance
    super(HasTraits, self).setup_instance(*args, **kwargs)
  File "/test/mambaforge/envs/py11/lib/python3.11/site-packages/traitlets/traitlets.py", line 1258, in setup_instance
    init(self)
  File "/test/mambaforge/envs/py11/lib/python3.11/site-packages/notebook/traittypes.py", line 226, in instance_init
    self._resolve_classes()
  File "/test/mambaforge/envs/py11/lib/python3.11/site-packages/notebook/traittypes.py", line 238, in _resolve_classes
    warn(f"{klass} is not importable. Is it installed?", ImportWarning)
TypeError: warn() missing 1 required keyword-only argument: 'stacklevel'

https://github.com/ipython/traitlets/blob/0505aef059b03bc93638533af9933004ffe23074/traitlets/utils/warnings.py#L6-L11
requires a stacklevel kwarg but
https://github.com/jupyter/notebook/blob/v6.5.4/notebook/traittypes.py#L238
doesn't pass it

@manics manics added the bug label Apr 16, 2023
manics added a commit to manics/jupyterhub that referenced this issue Apr 16, 2023
JupyterHub CI is currently broken with dev traitlets: jupyterhub#4418

This temporarily disables it
@manics
Copy link
Member Author

manics commented Apr 16, 2023

@blink1073 Is this breakage due to ipython/traitlets#838 intended?

@blink1073
Copy link

traitlets.warn was never a part of the public API (it wasn't part of _all_). The bug here is that notebook.traittypes is importing warn from traitlets instead of warnings.

@I-Am-D-B
Copy link

I-Am-D-B commented Sep 15, 2023

Did this bug somehow get re-introduced? I'm getting essentially the same thing with 6.5.5, when I didn't yesterday, it looks like.

Traceback (most recent call last):
  File ".......venv/lib/python3.10/site-packages/notebook/traittypes.py", line 235, in _resolve_classes
    klass = self._resolve_string(klass)
  File ".......venv/lib/python3.10/site-packages/traitlets/traitlets.py", line 2009, in _resolve_string
    return import_item(string)
  File ".......venv/lib/python3.10/site-packages/traitlets/utils/importstring.py", line 30, in import_item
    module = __import__(package, fromlist=[obj])
ModuleNotFoundError: No module named 'jupyter_server.contents'
rm -rf venv/
python3.10 -m venv venv
source venv/bin/activate
pip install --force-reinstall -v "notebook>=6,<7"
jupyter-notebook 

Effectively, this worked yesterday, jupyter-notebook 6.5.5 failing to start notebook server today. Only relevant thing I found. Did some underlying dependency that's not pinned for 6.5.5 change?

@minrk
Copy link
Member

minrk commented Sep 15, 2023

@I-Am-D-B I don't think that's related. I think you're hitting jupyter/notebook#7048 which is a bug in notebook, but also a backward-incompatible change in traitlets 5.10 that may want reverting. Pinning traitlets<5.10 should fix it for now.

@minrk
Copy link
Member

minrk commented Sep 15, 2023

Closing in favor of the jupyter/notebook issue.

@minrk minrk closed this as completed Sep 15, 2023
@I-Am-D-B
Copy link

Thanks @minrk. I did:

pip install --force-reinstall -v "traitlets<5.10" and now jupyter-notebook runs.

Back to what I was trying to actually debug 2 days ago...

@mahmoudsamhoud
Copy link

mahmoudsamhoud commented Sep 27, 2023

Thanks @minrk
pip install --force-reinstall -v "traitlets<5.10" works just fine

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

No branches or pull requests

5 participants