The primary drivers behind this fork of https://github.com/isginf/jupyterlab-server-timer were the following use cases:
- not all of our JupyerHub setups have a user server runtime limit
- enable users to setup a notification to get notified by their system notification system before the server terminates
Note that the first use case required a backward incompatible change. The performed changes are:
- the default value for the environment variable
JOB_RUN_TIMEwas removed to signal there is no server runtime limit. - the value of the environment variable
JOB_RUN_TIMEis now interpreted in seconds instead of minutes to align it with the--max-ageflag of thejupyterhub-idle-culler - rounding of the displayed time and visual changes
Just like its origin this extension uses two environment variables in the jupyter server environment:
JOB_START_TIME- Optional. The UTC timestamp when the jupyer server was started.
- If it is not set, it uses the time the server extension was loaded with a hard-wired overhead of 20 seconds to account for possible startup delays.
JOB_RUN_TIME- Optional. The runtime limit of the jupyter server in seconds.
- If not set, the time elapsed since the server started (
JOB_START_TIME) is displayed.
A subtile change is the rounding: the remaining time is always rounded down. If there are 5 minutes and 30 seconds left, it displays 5 minutes. If less than a minute remains it switches from the time display to the text any moment.
Furthermore the styling was a bit adjusted: no red text and no blinking, but two boom icons around the remaining time if runtime limit gets close.
The text and the alarm icon integrate with jupyterlab light and dark mode and change appearance when switched. The boom icons don't change, but look okay-ish in all jupyterlab theme modes.
A click on opens a dialog in which the user is asked if she wants to enable notifications. With click on
ok the web notification api is used to setup a system notification before the server is terminated.
For user servers without a runtime limit we simply display the duration the server is already running. This change required a backward incompatible change: the original extension used a default value if the environment variable JOB_RUN_TIME is not set. This extension uses None as value if it is not set.
Unlike the remaining time, the duration is always rounded up. Thus, if the server runs for 1 minute and 30 seconds, 2 minutes is displayed. Of course, the alarm icon to setup notifications is not displayed.
Server runs for 2 minutes
This project contains a python package named jupyterlab_server_timer for the jupyter server extension and a npm package named jupyterlab-server-timer for the frontend extension.
You need an environment with python and node available. The python environment must have hatch installed. For details see: https://jupyterlab.readthedocs.io/en/stable/extension/extension_tutorial.html#extension-tutorial
Here are the most important things:
- run
hatch run depsto download all dependencies of the frontend extension - run
hatch run rebuildto rebuild the extension and to ensure it is integrated into jupyterlab - run
hatch run labto start a jupyterlab instance with this extension (and without token authentication)- note: the values of the environment variables to configure this extension can be changed in the file
pyproject.tomlunder section[tool.hatch.envs.default.env-vars]
- note: the values of the environment variables to configure this extension can be changed in the file
- run
hatch run py-teststo run unit tests of the python backend - run
hatch run ui-teststo run unit tests of the frontend - run
hatch run checkto list the status of the jupyter labextensions and jupyter server extensions- note: it should list this extension with status like enabled and ok
To create a release, i. e. an installable python package:
- run
hatch version <version number>, version number schema is described here: https://github.com/jupyterlab/hatch-nodejs-version#semver - run
hatch buildto create the distribution files - the
distdirectory contains the*.whlfile which can be installed into a python environment - see also RELEASE
Note — I didn't regard the integration tests. There are documented here: ui-tests
The work was conducted as part of the research project KI-StudiUm at the Westsächsische Hochschule Zwickau, which was funded by the Federal Ministry of Research, Technology and Space as part of the federal-state initiative "KI in der Hochschulbildung" under the funding code 16DHBKI063.