Extension not working with JupyterHub

Hi all, over the summer I developed an extension for JupyterLab and am now trying to get it to work with JupyterHub. I’ve made the extension into a pip package, uploaded it to TestPyPI, and included its installation in my Dockerfile, which looks like this:

ARG BASE_CONTAINER=jupyter/tensorflow-notebook:hub-1.4.2
FROM $BASE_CONTAINER

LABEL maintainer="Texas State EECS Group"

USER root

# Install JupyterLab extension
WORKDIR /home/jovyan
RUN pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple jupyterlab-power-and-energy

EXPOSE 8888

When I create the image with sudo docker build . -t image-test, run it using sudo docker run -p 8888:8888 image-test, and open up JupyterHub in my browser, the extension doesn’t seem to be working properly since the “Measure Energy Usage” button it should add to the notebook toolbar is missing. (In JupyterLab it looks like the attached screenshot). However, if I run jupyter labextension list in the JupyterHub terminal I can see that it’s installed and enabled. Any ideas about why this might be happening are much appreciated.

The code for the extension is here; the additional backend components that do the actual measuring of energy usage are not included, but we’re not trying to include them in the Docker image at the present time: GitHub - TrevorVillwock/jupyterlab_power_and_energy: A JupyterLab extension that lets users measure the power and energy usage of their code

Testing this on Ubuntu 20.04.2 using WSL 2 running on Windows 10

It might be related to the command run by JupyterHub, and whether or not your extension is compatible with both jupyter notebook and jupyter server. See: Configuring user environments — JupyterHub 1.4.2 documentation

1 Like

Thanks for the help! Should that export JUPYTERHUB_SINGLEUSER_APP='jupyter_server.serverapp.ServerApp' command just go in the Dockerfile then? Or somewhere in the extension itself inside the pip package?

I think defining it as an ENV in your Dockerfile should work, let me know if it does.

Actually, the problem ended up being in a completely different place–I had to add -e JUPYTER_ENABLE_LAB=yes when I ran the container so it would open in jupyterlab instead of jupyter notebook. I didn’t realize that my button would only show up in lab and not in notebook. Thanks so much for the help though!

1 Like