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

Jupyter Server CLI can't accept server extensions as key value items. #606

Closed
mwakaba2 opened this issue Nov 5, 2021 · 8 comments · Fixed by #610
Closed

Jupyter Server CLI can't accept server extensions as key value items. #606

mwakaba2 opened this issue Nov 5, 2021 · 8 comments · Fixed by #610

Comments

@mwakaba2
Copy link
Member

mwakaba2 commented Nov 5, 2021

Description

It seems like the jupyter server cli isn't able to accept server extensions listed as key value items because of the incorrect 'enabled' type. Traitlet interprets any true value as a string and not a boolean.

Reproduce

I've been using the dict traits to define the server extensions in the jupyter server cli.

-ServerApp.jpserver_extensions='{"serverextensionX": True, "jupyterlab": True}' 

However, I get the following deprecation warning for that configuration

for dict-traits is deprecated in traitlets 5.0. You can pass --jpserver_extensions <key=value> ... multiple times to add items to a dict.

When I update it to the following

-ServerApp.jpserver_extensions "serverextensionX"=True
-ServerApp.jpserver_extensions "jupyterlab"=True

I get the following error:

The 'enabled' trait of an ExtensionPackage instance expected a boolean, not the str 'True'

I tried passing in 1, true, and not setting any value, but they all get converted into strings and trigger the same error message.

Expected behavior

To accept string values "True" or "true" and enable server extensions.

Context

  • Operating System and version: OSX Big Sur
  • Browser and version: Chrome
  • Jupyter Server version: Jupyter Server 1.8.0
@mwakaba2 mwakaba2 added the bug label Nov 5, 2021
@mwakaba2 mwakaba2 changed the title Jupyter Server CLI cannot expect server extensions as key value items. Jupyter Server CLI can't accept server extensions as key value items. Nov 5, 2021
@zjffdu
Copy link

zjffdu commented Jun 6, 2022

I hit the same issue, any solution for it?

@kevin-bates
Copy link
Member

Hi @zjffdu. Could you please ensure you're running jupyter-server > 1.11? I cannot reproduce this issue with anything >= jupyter-server 1.12.0 - which coincides with the release that first includes #610.

@zjffdu
Copy link

zjffdu commented Jun 7, 2022

@kevin-bates I am using the master branch, version is 2.1.0.dev0

@kevin-bates
Copy link
Member

Hmm. Are you still trying to use the JSON format to describe the single parameter rather than break each key/value pair into separate options?

For example, this will not work using traitlets >= 5:

jupyter server --ServerApp.jpserver_extensions='{"serverextensionX": True, "jupyterlab": True}'

But this should be fine (and confirmed in my env using 2.1.0.dev0):

jupyter server --ServerApp.jpserver_extensions "serverextensionX"=True --ServerApp.jpserver_extensions "jupyterlab"=True

@zjffdu
Copy link

zjffdu commented Jun 7, 2022

@kevin-bates Here's the command I use

jupyter server --ServerApp.jpserver_extensions "simple_ext1"=True 

And this is the output I see:

[W 2022-06-07 23:04:29 Simple_Extensions_Example.057 ServerApp] The 'enabled' trait of an ExtensionPackage instance expected a boolean, not the str 'True'.
Note: NumExpr detected 16 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8.
NumExpr defaulting to 8 threads.
[I 2022-06-07 23:04:32 Simple_Extensions_Example.298 ServerApp] jupyterlab | extension was successfully linked.
[I 2022-06-07 23:04:32 Simple_Extensions_Example.886 ServerApp] nbclassic | extension was successfully linked.
[I 2022-06-07 23:04:32 Simple_Extensions_Example.887 ServerApp] panel.io.jupyter_server_extension | extension was successfully linked.
[I 2022-06-07 23:04:32 Simple_Extensions_Example.968 LabApp] JupyterLab extension loaded from /Users/jianfezhang/opt/anaconda3/lib/python3.9/site-packages/jupyterlab
[I 2022-06-07 23:04:32 Simple_Extensions_Example.968 LabApp] JupyterLab application directory is /Users/jianfezhang/opt/anaconda3/share/jupyter/lab
[I 2022-06-07 23:04:32 Simple_Extensions_Example.972 ServerApp] jupyterlab | extension was successfully loaded.
[I 2022-06-07 23:04:32 Simple_Extensions_Example.981 ServerApp] nbclassic | extension was successfully loaded.
[I 2022-06-07 23:04:32 Simple_Extensions_Example.982 ServerApp] panel.io.jupyter_server_extension | extension was successfully loaded.
[I 2022-06-07 23:04:32 Simple_Extensions_Example.983 ServerApp] Serving notebooks from local directory: /Users/jianfezhang/github/jupyter_server/examples/simple
[I 2022-06-07 23:04:32 Simple_Extensions_Example.983 ServerApp] Jupyter Server 1.4.1 is running at:
[I 2022-06-07 23:04:32 Simple_Extensions_Example.983 ServerApp] http://localhost:8888/?token=e1bea66635205b742f498ffc0bc5778be4005de8f5810a64
[I 2022-06-07 23:04:32 Simple_Extensions_Example.983 ServerApp]  or http://127.0.0.1:8888/?token=e1bea66635205b742f498ffc0bc5778be4005de8f5810a64
[I 2022-06-07 23:04:32 Simple_Extensions_Example.983 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2022-06-07 23:04:32 Simple_Extensions_Example.986 ServerApp] 
    
    To access the server, open this file in a browser:
        file:///Users/jianfezhang/Library/Jupyter/runtime/jpserver-23936-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=e1bea66635205b742f498ffc0bc5778be4005de8f5810a64
     or http://127.0.0.1:8888/?token=e1bea66635205b742f498ffc0bc5778be4005de8f5810a64
[W 2022-06-07 23:05:48 Simple_Extensions_Example.484 ServerApp] 404 GET /simple_ext1/default (::1) 12.39ms referer=None
[W 2022-06-07 23:06:02 Simple_Extensions_Example.369 ServerApp] 404 GET /static/simple_ext1/home.html (::1) 3.25ms referer=None

But I can not open http://localhost:8888/simple_ext1/default, this is what I see in browser
image

@kevin-bates
Copy link
Member

I knew adding the version information in the startup info messages was a good idea! 😉

[I 2022-06-07 23:04:32 Simple_Extensions_Example.983 ServerApp] Jupyter Server 1.4.1 is running at:

Looks like you have an issue with python envs. You should see this when running 2.1.0.dev0...

[I 2022-06-07 07:32:49.757 ServerApp] Jupyter Server 2.1.0.dev0 is running at:

@zjffdu
Copy link

zjffdu commented Jun 8, 2022

Thanks @kevin-bates , this is indeed my env issue. After I correct this issue, I hit another error when I run command:

(jupyter-server-example) ➜  simple git:(master) ✗ /Users/jianfezhang/opt/anaconda3/envs/jupyter-server-example/bin/jupyter server --ServerApp.jpserver_extensions="{'simple_ext1': True}"

/Users/jianfezhang/opt/anaconda3/envs/jupyter-server-example/lib/python3.7/site-packages/traitlets/traitlets.py:3264: FutureWarning: --jpserver_extensions={'simple_ext1': True} for dict-traits is deprecated in traitlets 5.0. You can pass --jpserver_extensions <key=value> ... multiple times to add items to a dict.
  FutureWarning,
[W 2022-06-08 22:33:27 Simple_Extensions_Example.732 ServerApp] The module 'simple_ext1' could not be found. Are you sure the extension is installed?
[W 2022-06-08 22:33:27 Simple_Extensions_Example.751 ServerApp] The module 'simple_ext11' could not be found. Are you sure the extension is installed?
[W 2022-06-08 22:33:27 Simple_Extensions_Example.751 ServerApp] The module 'simple_ext2' could not be found. Are you sure the extension is installed?
[I 2022-06-08 22:33:27 Simple_Extensions_Example.758 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2022-06-08 22:33:27 Simple_Extensions_Example.827 ServerApp] jupyter_server_terminals | extension was successfully loaded.

I can ensure that jupyter-server-example is installed as I can find file jupyter-server-example.egg-link under /Users/jianfezhang/opt/anaconda3/envs/jupyter-server-example/lib/python3.7/site-packages.

Is there anything wrong with my environment? Thanks

@Zsailer
Copy link
Member

Zsailer commented Jun 8, 2022

Looks like the examples are currently broken, see #858. I'll dive into this later today and try to get things working. Watch that issue for updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants