Skip to content

A JupyterLab extension that displays either the remaining or the actual server run time in the status bar.

License

Notifications You must be signed in to change notification settings

tobi45/jupyterlab-server-timer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JupyterLab Server Timer

The primary drivers behind this fork of https://github.com/isginf/jupyterlab-server-timer were the following use cases:

  1. not all of our JupyerHub setups have a user server runtime limit
  2. 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:

  1. the default value for the environment variable JOB_RUN_TIME was removed to signal there is no server runtime limit.
  2. the value of the environment variable JOB_RUN_TIME is now interpreted in seconds instead of minutes to align it with the --max-age flag of the jupyterhub-idle-culler
  3. 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.

User Servers with Runtime Limit

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.

Server terminates in 5 minutes
Server terminates in 4 minutes
Server terminates any moment

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.

Enable Notification

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.

User Servers without Runtime Limit

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

Getting Started

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 deps to download all dependencies of the frontend extension
  • run hatch run rebuild to rebuild the extension and to ensure it is integrated into jupyterlab
  • run hatch run lab to 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.toml under section [tool.hatch.envs.default.env-vars]
  • run hatch run py-tests to run unit tests of the python backend
  • run hatch run ui-tests to run unit tests of the frontend
  • run hatch run check to 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:

Note — I didn't regard the integration tests. There are documented here: ui-tests

Funding

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.

About

A JupyterLab extension that displays either the remaining or the actual server run time in the status bar.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 79.0%
  • Python 16.1%
  • JavaScript 3.2%
  • CSS 1.7%