John
John

Reputation: 641

How to use ContentsManager for Jupyter?

I've read about Jupyter ContentsManager but have no idea how to use it and the documentation is really bad. What should I do? Where do I run it and how do I connect it to my Jupyter Environment and notebooks?

Upvotes: 1

Views: 1982

Answers (1)

krassowski
krassowski

Reputation: 15409

To swap the contents manager in JupyterLab 3.0+ that is running on the new jupyter server (this is the default way of doing things, but if you are running on JupyterHub it might still use the old notebook server), create a jupyter_server_config.py file; you can auto-generate it in appropriate location using:

jupyter server --generate-config

and set the contents manager class to you own manager:

c.ServerApp.contents_manager_class = "python.module.for.your.ContentsManagerSubclass"

This option is described on the list of configuration options of jupyter server.

(alternatively, you could use a json file). For older JupyterLab versions, or if for some weird reason you are using the old notebook you will want to use jupyter_notebook_config.py where this option was named c.NotebookApp.contents_manager_class. You can read more on this topic here - although the examples reference the old notebook way of doing things so you would need to updated accordingly.

You may also be interested to learn how jupytext hot swaps the content managers reacting to user settings, see the code here.

Upvotes: 1

Related Questions