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

Unable to configure S3 content manager on recent jupyter-server versions #161

Closed
djuarezg opened this issue May 1, 2023 · 8 comments
Closed

Comments

@djuarezg
Copy link
Contributor

djuarezg commented May 1, 2023

As for https://discourse.jupyter.org/t/bad-config-encountered-during-initialization-the-contents-manager-class-trait-of-a-singleuserlabapp-instance-expected-a-subclass-of-jupyter-server-services-contents-manager-contentsmanager-not-the-s3contentsmanager-s3contentsmanager/17304, I cannot switch to s3contents as the manager due to getting the same error as above.

My image is based on https://hub.docker.com/layers/jupyter/scipy-notebook/python-3.10.10

import s3contents
 
c = get_config()
c.S3ContentsManager.bucket = "test-bucket-ignore"
c.S3ContentsManager.endpoint_url = "asdasda"
c.S3ContentsManager.access_key_id = "asdasd"
c.S3ContentsManager.secret_access_key = "asdasda"
c.S3ContentsManager.skip_tls_verify = True
c.NotebookApp.contents_manager_class = s3contents.S3ContentsManager

I am getting:

Bad config encountered during initialization: The ‘contents_manager_class’ trait of a SingleUserLabApp instance expected a subclass of ‘jupyter_server.services.contents.manager.ContentsManager’, not the S3ContentsManager S3ContentsManager.

Using the following package versions:

jupyter_core                      5.3.0
jupyter-events                    0.6.3
jupyter-resource-usage            0.7.1
jupyter_server                    2.5.0
jupyter_server_fileid             0.9.0
jupyter-server-mathjax            0.2.6
jupyter-server-proxy              3.2.2
jupyter_server_terminals          0.4.4
jupyter_server_ydoc               0.8.0
jupyter-telemetry                 0.1.0
jupyter-ydoc                      0.2.3
jupyterhub                        3.1.1
jupyterlab                        3.6.3
jupyterlab-code-formatter         1.6.0
jupyterlab-git                    0.41.0
jupyterlab-pygments               0.2.2
jupyterlab_server                 2.22.1
jupyterlab-system-monitor         0.8.0
jupyterlab-topbar                 0.6.1
jupyterlab-vimrc                  0.5.2
jupyterlab-widgets 

Running the following processes on the spawned container:

(base) jovyan@example:~$ ps auxfww
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
jovyan     92652  0.0  0.0   7620  4376 pts/0    Ss   11:18   0:00 bash
jovyan     92895  0.0  0.0  10040  1600 pts/0    R+   11:21   0:00  \_ ps auxfww
jovyan         1  0.0  0.0   2784   992 ?        Ss   May01   0:02 tini -g -- start-notebook.sh --ip=127.0.0.1 --port=57307 --notebook-dir=/home/jovyan/work --SingleUserNotebookApp.default_url=/lab --debug
jovyan         7  0.2  0.3 1152852 200016 ?      Sl   May01   2:22 /opt/conda/bin/python3.10 /opt/conda/bin/jupyterhub-singleuser --ip=127.0.0.1 --port=57307 --notebook-dir=/home/jovyan/work --SingleUserNotebookApp.default_url=/lab --debug
jovyan       125  0.0  0.1 1000708 105652 ?      Ssl  May01   0:06  \_ /opt/conda/bin/python -m ipykernel_launcher --profile=python -f /home/jovyan/.local/share/jupyter/runtime/kernel-00d5e0e5-28cb-4574-b25f-544ae0670add.json

PS: Note that I had to apply #142 suggestion in order to make it work.

@djuarezg djuarezg changed the title Unable to configure S3 content manager on recent jupyter versions Unable to configure S3 content manager on recent jupyter-server versions May 2, 2023
@djuarezg
Copy link
Contributor Author

djuarezg commented May 2, 2023

I suspect this is the main reason: jupyter/notebook#5957 (comment)

That got reverted on posterior versions and this package is not ready for that yet.

@danielfrg
Copy link
Owner

Could be yeah. I dont have much time to work on it these days so if you find time to make a PR and update the test matrix it should be easy to test.

@djuarezg
Copy link
Contributor Author

djuarezg commented May 3, 2023

@danielfrg not so proficient in these jupyter world but I found a way to make it work. It turns out that when using jupyter_server, the following lines are the reason why the above class mismatch: https://github.com/danielfrg/s3contents/blob/e44f57054a079e1caee9be94c7a0fbf4abd087d2/s3contents/ipycompat.py#L22-25

If you change them like this it works:

-from notebook.services.contents.filecheckpoints import GenericFileCheckpoints
-from notebook.services.contents.filemanager import FileContentsManager
-from notebook.services.contents.manager import ContentsManager
+from jupyter_server.services.contents.filecheckpoints import GenericFileCheckpoints
+from jupyter_server.services.contents.filemanager import FileContentsManager
+from jupyter_server.services.contents.manager import ContentsManager

Same applies to HybridContents if used as well, imports have to come from jupyter_server

Do you have any recommendation on how to make this less dirty?

@danielfrg
Copy link
Owner

This looks fine to me. If we just wrap that with an if that checks the version of notebook it should work. Its pretty common to do that.

@djuarezg
Copy link
Contributor Author

djuarezg commented May 3, 2023

@danielfrg
Copy link
Owner

Yes, its not the cleanest but its pretty common to deal with this situations.

@xfu83
Copy link

xfu83 commented May 5, 2023

@danielfrg could you help cut a patch release and publish it on Pypi, thanks!

@danielfrg
Copy link
Owner

Just released 0.10.0. Let me know any issues.

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

3 participants