Jupyter-server-proxy development environment


I would like to experiment with an enhancement to jupyter-server-proxy, but I am finding it tricky to set up a development environment for it. Everything is as expected except that no menu items ever appear in my Jupyter notebook.


# Clone jupyter-server-proxy
git clone https://github.com/jupyterhub/jupyter-server-proxy
cd jupyter-server-proxy

# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate

# Install python-server-proxy in editable mode
pip install -e .
# As per instructions, for "-e" installs: https://jupyter-server-proxy.readthedocs.io/en/latest/install.html
jupyter serverextension enable --sys-prefix jupyter_server_proxy

# Create proxied package
pip install cookiecutter
cookiecutter contrib/template -o contrib/
#    project_name []: jsptest
#    author_name [Project Jupyter Contributors]:
#    author_email [projectjupyter@gmail.com]:

# Install proxied package
cd contrib/jsptest
pip install -e .

# Run notebook
jupyter notebook

Unfortunately, it doesn’t seem to work as the menu item is missing.
Screenshot 2020-09-08 at 12.42.31

This is a bit weird, because I know that the setup function is being called as I modifed the init.py with some print statements.

Return config on servers to start for jsptest

See https://jupyter-server-proxy.readthedocs.io/en/latest/server-process.html
for more information.
import os

def _get_cmd():
    print("Get CMD for jsptest")
    return ["python", "-m", "http.server", "--directory", "/tmp/stuff"]

def setup_jsptest():
    print("Setting up jsptest")
    return {
        'command': _get_cmd,
        'environment': {},
        'launcher_entry': {
            'title': 'jsptest',
            'icon_path': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'icons', 'jsptest.svg')

print("Importing jsptest")

When starting up:

$ jupyter notebook
Importing jsptest
Setting up jsptest
[I 12:44:43.060 NotebookApp] Serving notebooks from local directory: /Users/dpwrussell/Checkout/MathWorks/Jupyter/jupyter-server-proxy
[I 12:44:43.060 NotebookApp] Jupyter Notebook 6.1.3 is running at:
[I 12:44:43.060 NotebookApp] http://localhost:8888/?token=cb18ce2a3b1d1f7f3e97bf328069ec06ee116cb4abfc871a
[I 12:44:43.060 NotebookApp]  or
[I 12:44:43.060 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 12:44:43.069 NotebookApp]

    To access the notebook, open this file in a browser:
    Or copy and paste one of these URLs:

I also tried building a wheel from jsptest and installing it into a Dockerized Jupyter notebook and that worked fine, so I think it’s just a development issue.

Any ideas?

The instructions may be incomplete, can you try something like

jupyter nbextension install --py --sys-prefix jupyter_server_proxy
jupyter nbextension enable --py --sys-prefix jupyter_server_proxy

Taken from https://jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/Distributing%20Jupyter%20Extensions%20as%20Python%20Packages.html#Install-and-enable-the-server-extension-and-nbextension

If you do a normal pip install the configuration files to automatically activate the extension are installed, but that doesn’t work with pip install -e

1 Like

@manics Spot on, thanks!