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

Jupyterlab extension fails to load when c.NotebookApp.log_json is set #43

Open
rmoe opened this issue Feb 1, 2021 · 4 comments
Open

Comments

@rmoe
Copy link

rmoe commented Feb 1, 2021

I'm testing out JupyterLab 3.0.5 alongside classic notebook in a JupyterHub environment. The classic notebook works fine but when navigating to /lab I get a 404. In the logs I see the following traceback on server startup:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/notebook/notebookapp.py", line 1991, in init_server_extensions
    func(self)
  File "/opt/conda/lib/python3.8/site-packages/jupyterlab/serverextension.py", line 13, in load_jupyter_server_extension
    extension.update_config(serverapp.config)
  File "/opt/conda/lib/python3.8/site-packages/nbclassic/shim.py", line 138, in update_config
    shimmed_config = self.shim_config_from_notebook_to_jupyter_server(config)
  File "/opt/conda/lib/python3.8/site-packages/nbclassic/shim.py", line 228, in shim_config_from_notebook_to_jupyter_server
    raise TraitError("Trait, {}, not found.".format(trait_name))
traitlets.traitlets.TraitError: Trait, log_json, not found.

c.NotebookApp.log_json = True is set in .jupyter/jupyter_notebook_config.py

@mriedem
Copy link
Contributor

mriedem commented Feb 2, 2021

@kevin-bates any idea on this? I wasn't familiar with the push to jupyterlab and notebook -> notebook-server when I worked on jupyter/notebook#5799 but now I realize why you wanted to mirror that change in notebook-server. 😄

@rmoe mentioned he found a workaround for this issue:

I discovered a workaround (or maybe it's the real solution, I can't tell) where renaming the trait to SingleUserNotebookApp allows the JupyterLab server extension to start up. We get JSON logging in the classic notebook and JupyterLab seems to work as expected.

Is that the correct thing to do here or is there an issue to be fixed?

@kevin-bates
Copy link
Member

Yeah, I think the correct next step is to get the json-logging PR into jupyter_server. Given the test frameworks are different and most of the PR is test code, it might be easier to just apply the non-test changes and create new test code than cherry-pick the commits.

I'm not really up on all the shimming that takes place in these environments but the fact that the 'trait not found' message is coming from shim_config_from_notebook_to_jupyter_server() is a good clue.

@echarles
Copy link
Member

The shim_config_from_notebook_to_jupyter_server.is implemented in the notebook_shim repo https://github.com/jupyter/notebook_shim in https://github.com/jupyter/notebook_shim/blob/189915e9ff4b1c926c9439211fdf7f6767c1bb77/notebook_shim/shim.py#L145-L149

Should this issue be move the the notebook_shim repo?

@kevin-bates
Copy link
Member

Hi @echarles.

It looks like the issue may be that log_json isn't on jupyter_server and, (I'm guessing here) the shim layer makes an assumption that all notebook traits will exist on jupyter_server.

If the shim layer needs to tolerate missing traits on jupyter_server, then it sounds like an issue for that repo. However, to preserve functional compatibility, we should get jupyter/notebook#5799 into jupyter_server.

@mriedem - would you be able to migrate the changes from your notebook PR into jupyter_server? The source changes should be nearly one-to-one. The test frameworks, on the other hand, differ (server uses pytest) so that's probably where some effort will need to take place.

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

4 participants