Deploying a Jupyter Server extension on TLJH


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@ 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 in this specific case).

1 Like

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

1 Like