Deploying a Jupyter Server extension on TLJH

Hi,

I have developed a simple Jupyter Server extension that I would like to deploy on TLJH. I set up a TLJH development environment in a Docker container and successfully installed the extension. If I run jupyter server extension list I get the following output:

demo_app enabled
- Validating demo_app...
  demo_app  OK

I know that Jupyter Server is currently not the default server back-end, so I followed the instructions mentioned here and here. However, when I login to my TLJH instance through the browser and try to access my extension, I get a 404 : Not Found error.

I looked through the logs and didn’t find much that would help me understand what went wrong. For instance, in the jupyterhub logs I only found the following:

Apr 09 19:12:22 8aca9ac6b558 bash[4260]: [W 2021-04-09 19:12:22.483 SingleUserNotebookApp log:181] 404 GET /user/admin/demo-app (admin@172.17.0.1) 2.08ms

I already did something quite similar with the old NotebookApp, which basically worked out of the box. I am puzzled what the problem could be here, and I would be grateful for hints where to start with the debugging. To be honest, I don’t even know how to check if I was successful in making Jupyter Server the default back-end …

Well, it turns out I had the extension’s handlers configured incorrectly. My server extension declared the handler for the main entry point like this:

self.handlers.extend( [ 
   ( ujoin( self.serverapp.base_url, self.extension_url ), AppHandler )
) ]

Because class ExtensionApp adds the base URL to the enpoints by default, this resulted in an endpoint of the form /user/username/user/username/extension_url. I just had to change the handler declaration to:

self.handlers.extend( [ 
   ( self.extension_url, AppHandler )
) ]
1 Like

Hello @ewidl I just came a across this post and despite I am not facing the same issue as you. I wanted to ask you a couple things:

  1. How did you package the extension to be deployed in your TLJH instance? I have followed this instructions. I can get the lab extension installed and listed when executing jupyter labextension list however it doesn’t show up when executing jupyter serverextension list.

  2. Have you found any particularity/singularity of packaging and deploying lab extensions that has a frontend and a server component to a TLJH instance?

Thank you very much in advance

Dear @Francisco_Rivas,

Packing of JupyterLab extensions is indeed a bit tricky. This is mostly because you have not only to package the Python code, but also the TypeScript code (or its artifacts). Package jupyter_packaging provides several useful functions to do that, for instance install_npm …

However, I have not yet worked on an extension for JupyterLab 3.0, so there might be a few obstacles that I am unaware of. I am therefore cautious to give advice here. But I always found it very instructive to take a look at other extensions that are actively maintained, for instance jupyterlab-git (and especially the setup.py in this specific case).

1 Like

The extension-examples and the extension-cookiecutter-ts repos should be helpful too.

1 Like

Can you share Your Configuration Options?

I want deploy on TLJH, but It doesn’t work
If I run jupyter serverextension list I get the below output

nteract_on_jupyter enabled

  • Validating…
    nteract_on_jupyter 2.15.1 OK

I make jupyterhub_config.py

export JUPYTERHUB_SINGLEUSER_APP='jupyter_server.serverapp.ServerApp'

but It’s not solve the problem.
server response message is Bad Gate

please help.

@kaminion

It’s a bit confusing unfortunately, but try running jupyter server extension list (notice the space between server and extension). The subcommand you used above points to the classic notebook server extension list, not the new jupyter_server extension list.

You may need to enable your extension against the Jupyter Server using jupyter server extension enable <extension_name> (again, notice the space).

1 Like

@Zsailer
Oh. Thanks.
I’m run command include space jupyter server extension enable <extension_name>
and jupyter server extension list

It has been applied accurately.

config dir: /usr/etc/jupyter
<extension_name> enabled
Validating… <extension_name>
<extension_name> OK

but The extension is still not working on the hub. Is there any way to solve this problem?
I’m using the nteract_on_jupyter extension

Maybe I solve the problem.
I’m add to c.Spanwer Options in JupyterHub Config file.

It might not be. If you know the solution, please tell me.