jupyterlab / extension-examples

JupyterLab Extensions by Examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Server Extension example not compatible with JupyterHub

cjimti opened this issue · comments

I'm running JupyterLab v3.0.7 from JupyterHub on Kubernetes (jupyterhub/k8s-hub:0.11.1). I created the Server Extension example with cookiecutter https://github.com/jupyterlab/extension-cookiecutter-ts and chose yes for server extension.

The server extension runs fine on my local JupyterLab install as shown in the browser console log:

JupyterLab extension jupyterlab-myexample is activated! 703.a90f5cb85c09b92b6cd6.js:1:281
Object { data: "This is /jupyterlab-myexample/get_example endpoint!" }

However, the JupyterLab proxied from JupyterHub gives a 404 when contacting the server extension endpoint:

JupyterLab extension jupyterlab-myexample is activated! 703.a90f5cb85c09b92b6cd6.js:1:281
XHR GET https://lab.example.com/user/craig/jupyterlab-myexample/get_example?1615070061547 [HTTP/2 404 Not Found 115ms]

Not a JSON response body. 
Response { type: "basic", url: "https://lab.example.com/user/craig/jupyterlab-myexample/get_example?1615070061547", redirected: false, status: 404, ok: false, statusText: "Not Found", headers: Headers, body: ReadableStream, bodyUsed: true }

I used the cookiecutter example out of the box with no changes to the generated code. I am not sure if I am missing some extra steps to make this compatible with JupyterHub

Here is the jupyter labextension list from the JupyterHub spawned JupyterLab:

JupyterLab v3.0.7
/opt/conda/share/jupyter/labextensions
        jupyterlab-myexample v0.1.0 enabled OK (python, jupyterlab-myexample)
        jupyterlab-topbar-extension v0.6.1 enabled OK (python, jupyterlab-topbar)
        jupyterlab-system-monitor v0.8.0 enabled OK (python, jupyterlab-system-monitor)
        jupyterlab-python-file v0.5.2 enabled OK (python, jupyterlab-python-file)
        @jupyter-widgets/jupyterlab-sidecar v0.6.0 enabled OK (python, sidecar)
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)
        @jupyter-server/resource-usage v0.5.0 enabled OK (python, jupyter-resource-usage)

Other labextensions (built into JupyterLab)
   app dir: /opt/conda/share/jupyter/lab
        @jupyterlab-classic/application v0.1.6 enabled OK
        @jupyterlab/fasta-extension v3.0.0 enabled OK
        @jupyterlab/geojson-extension v3.0.0 enabled OK
        @jupyterlab/katex-extension v3.1.0 enabled OK
        @jupyterlab/mathjax3-extension v4.1.1 enabled OK
        @krassowski/jupyterlab-lsp v3.4.1 enabled OK
        jupyter-matplotlib v0.8.3 enabled OK
        jupyterlab-plotly v4.14.3 enabled OK
        plotlywidget v4.14.3 enabled OK


Disabled extensions:
    @jupyterlab/extensionmanager-extension (all plugins)
    @jupyterlab/mathjax2-extension:plugin

jupyter server extension list:

Config dir: /home/jovyan/.jupyter

Config dir: /opt/conda/etc/jupyter
    jupyter_lsp enabled
    - Validating jupyter_lsp...
      jupyter_lsp 1.1.4 OK
    jupyter_resource_usage enabled
    - Validating jupyter_resource_usage...
      jupyter_resource_usage  OK
    jupyterlab-myexample enabled
    - Validating jupyterlab-myexample...
      jupyterlab-myexample 0.1.0 OK
    jupyterlab enabled
    - Validating jupyterlab...
      jupyterlab 3.0.7 OK
    nbclassic enabled
    - Validating nbclassic...
      nbclassic  OK

Config dir: /usr/local/etc/jupyter

Is this a configuration or compatibility issue with JupyterHub or is the example missing something necessary for the extension to work through JupyterHub?

Thanks

@cjimti JupyterLab 3 uses a new server for Jupyter that unfortunately is not supported by default by JupyterHub.

You can activate a fallback see the server extension example - to be more specific the commit that implements it: https://github.com/jupyterlab/extension-examples/pull/145/files