nbclassic icon indicating copy to clipboard operation
nbclassic copied to clipboard

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

Open rmoe opened this issue 4 years ago • 4 comments

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

rmoe avatar Feb 01 '21 22:02 rmoe

@kevin-bates any idea on this? I wasn't familiar with the push to jupyterlab and notebook -> notebook-server when I worked on https://github.com/jupyter/notebook/pull/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?

mriedem avatar Feb 02 '21 14:02 mriedem

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.

kevin-bates avatar Feb 02 '21 16:02 kevin-bates

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?

echarles avatar Oct 28 '22 05:10 echarles

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 https://github.com/jupyter/notebook/pull/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.

kevin-bates avatar Oct 28 '22 14:10 kevin-bates