jupyter_server icon indicating copy to clipboard operation
jupyter_server copied to clipboard

Jupyter Server cannot recognize contents_manager_class class in the config.py file

Open luweizheng opened this issue 2 years ago • 3 comments

Description

Not sure if this is the jupyter_server's bug.

Recent jupyter may have some breaking changes on the config file. Some plugin with notebook.services.contents.filemanager.FileContentsManager cannot be recognized when configured c.NotebookApp.contents_manager_class in the jupyter_notebook_config.py file.
Or maybe the community should update when implementing a contents_manager_class?

Reproduce

I want to use notedown plugin to open markdown file in jupyter notebook. This plugin can open the .md file in jupyter notebook just as a normal .ipynb file.

I get the above error when starting the jupyter after setting c.NotebookApp.contents_manager_class = 'notedown.NotedownContentsManager'.

I try a quick fix by changing the following two lines. I am not familiar with this filemanager stuff.

import jupyter_server.transutils
from jupyter_server.services.contents.filemanager import FileContentsManager

It seems that jupyter can start without the error. But I cannot open the markdown file as a normal ipynb file. The markdown file can be opened but in the markdown format. It is not what this plugin expects.

Earyl version of jupyter can work.

Early version like 4.4.0 works.

jupyter --version
4.4.0

New version like jupyter_server 2.7.0 does not work.

jupyter --version
Selected Jupyter core packages...
IPython          : 8.11.0
ipykernel        : 6.25.0
ipywidgets       : 8.1.0
jupyter_client   : 8.3.0
jupyter_core     : 5.3.1
jupyter_server   : 2.7.0
jupyterlab       : 4.0.3
nbclient         : 0.8.0
nbconvert        : 7.7.3
nbformat         : 5.9.2
notebook         : 7.0.1
qtconsole        : 5.4.3
traitlets        : 5.9.0

Context

Full stack tree when setting explicitly contents_manager_class to notebook.services.contents.largefilemanager.LargeFileManager:

W 2023-08-01 21:33:31.193 ServerApp] notebook | error linking extension: The 'contents_manager_class' trait of a ServerApp instance expected a subclass of 'jupyter_server.services.contents.manager.ContentsManager', not the str 'You need to install the jupyter notebook.'.
    Traceback (most recent call last):
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 342, in link_extension
        extension.link_all_points(self.serverapp)
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 224, in link_all_points
        self.link_point(point_name, serverapp)
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 214, in link_point
        point.link(serverapp)
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/jupyter_server/extension/manager.py", line 136, in link
        linker(serverapp)
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/jupyter_server/extension/application.py", line 405, in _link_jupyter_server_extension
        self.serverapp.update_config(self.config)
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/traitlets/config/configurable.py", line 230, in update_config
        self._load_config(config)
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/traitlets/config/configurable.py", line 181, in _load_config
        setattr(self, name, deepcopy(config_value))
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/traitlets/traitlets.py", line 732, in __set__
        self.set(obj, value)
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/traitlets/traitlets.py", line 706, in set
        new_value = self._validate(obj, value)
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/traitlets/traitlets.py", line 738, in _validate
        value = self.validate(obj, value)
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/traitlets/traitlets.py", line 2056, in validate
        self.error(obj, value)
      File "/Users/xxx/anaconda3/envs/df/lib/python3.10/site-packages/traitlets/traitlets.py", line 844, in error
        raise TraitError(e)
    traitlets.traitlets.TraitError: The 'contents_manager_class' trait of a ServerApp instance expected a subclass of 'jupyter_server.services.contents.manager.ContentsManager', not the str 'You need to install the jupyter notebook.'.

luweizheng avatar Aug 01 '23 13:08 luweizheng