Skip to main content

Develop

Follow the below steps to develop Jupyter Manager.

Environment

You need Miniconda up-and-running on your machine.

Clone the jupyter-manager repository.

git clone https://github.com/datalayer/jupyter-manager.git && \
cd jupyter-manager

If you already have created a conda environment, please remove it.

conda deactivate && \
make env-rm

Create a new conda environment.

make env && \
conda activate datalayer

Install and Build

Install the JavaScript dependencies.

yarn

Build the JavaScript code.

yarn build

Install the Python package.

pip install -e .[test]
# Double check
pip list | grep manager
# jupyter_manager ...

Link the JupyterLab extension for development.

jupyter labextension develop . --overwrite
# Installing: .../jupyter_manager/labextension -> @datalayer/jupyter-manager
# Removing: .../labextensions/@datalayer/jupyter-manager
# Symlinking: .../labextensions/@datalayer/jupyter-manager -> .../jupyter_manager/labextension

Check the availability of your Jupyter extension.

jupyter labextension list
# JupyterLab v4.0.0
# .../share/jupyter/labextensions
# jupyterlab_pygments v0.2.2 enabled X (python, jupyterlab_pygments)
# @datalayer/jupyter-manager v0.0.2 enabled X
jupyter server extension list
# Package jupyter_manager took 0.0015s to import
# jupyter_manager 0.0.2 OK

JupyterHub

Start JupyterHub and the separated webapp.

yarn jupyterhub

Check that JupyterHub is working fine by launching a server.

  1. Browse http://localhost:8000 and login with username ($USER being you operating system user) and any password.
  2. This will launch a JupyterLab server, you can view the Jupyter Manager extension.
  3. You can view the adminstration page on http://localhost:8000/hub/admin

While JupyterHub and your server is running, you can run Jupyter Manager is a separated application on http://localhost:3063.

In another terminal, you can connect to the JupyterHub local SQLite database an run queries.

# .schema
# .tables
# .schema api_tokens
# select * from api_tokens;
make sqlite

Inspect the configurable HTTP proxy routes.

# Use the Authorization token defined in c.ConfigurableHTTPProxy.auth_token = '0bc02bede919e99a26de1e2a7a5aadfaf6228de836ec39a05a6c6942831d8fe5'
curl \
-H "Authorization: token 0bc02bede919e99a26de1e2a7a5aadfaf6228de836ec39a05a6c6942831d8fe5" \
http://localhost:8001/api/routes | jq
# {
# "/": {
# "hub": true,
# "target": "http://127.0.0.1:8081",
# "jupyterhub": true,
# "last_activity": "2023-05-07T10:51:55.714Z"
# }
# }

JupyterLab

Start JupyterLab and watch the sources.

echo open http://localhost:8686/api/jupyter/lab?token=60c1661cc408f978c309d04157af55c9588ff9557c9380e4fb50785750703da6
yarn jupyterlab

Alternatively, you can use 2 terminals. First start JupyterLab in terminal 1.

echo open http://localhost:8686/api/jupyter/lab?token=60c1661cc408f978c309d04157af55c9588ff9557c9380e4fb50785750703da6
jupyter lab --port 8686

Then, in terminal 2, watch for changes.

yarn watch

Web Application

Start the Webpack and Jupyter servers.

echo open http://localhost:3063
echo open http://localhost:8686/api/jupyter?token=60c1661cc408f978c309d04157af55c9588ff9557c9380e4fb50785750703da6
yarn start

Clean

Kill any remaining ghost processes.

yarn kill

To restart JupyterHub from zero, remove the SQLite database.

rm jupyterhub.sqlite