Skip to main content

Jupyter Server Synchronizer

Build Status codecov

A Jupyter Server Session Manager that persists and rehydrates kernel sessions beyond the lifetime of a server.

This is particularly useful for Jupyter Servers running remote kernels and contents.

Basic usage

Install and enable the extension:

pip install jupyter_server_synchronizer

jupyter server extension enable jupyter_server_synchronizer

When you start a Jupyter Server, it synchronize all managers before the Web application is started.

jupyter server --ServerApp.session_manager_class=jupyter_server_synchronizer.SynchronizerSessionManager

To synchronize periodically, enable the auto-synchronizing feature using the autosync config option. For example,

jupyter server --ServerApp.session_manager_class=jupyter_server_synchronizer.SynchronizerSessionManager --SynchronizerSessionManager.autosync=True

Otherwise, you can trigger the synchronization making a POST request to the /api/sync endpoint.

Example

Below is a example of running the synchronizer with Jupyter Server talking to a Jupyter Kernel Gateway as its "remote" kernel service provider.

First, start the Kernel Gateway. You'll need to enable the list_kernels method. In the example, we are assuming the Kernel Gateway is not multi-tenant; i.e. there is a single KG for a single Jupyter Server. We'll set the port to 9999 to free up 8888 for our Jupyter Server.

jupyter kernelgateway \
    --port 9999 \
    --JupyterWebsocketPersonality.list_kernels=True

Second, start the Jupyter Server and point it at the Kernel Gateway. Note that we set a database_filepath trait in both the SessionManager and SynchronizerExtension (these paths don't need to be the same). The Synchronize relies on saving/storing of information about Jupyter kernels and sessions in a persistent database. This information is necessary to rehydrate and synchronize.

We'll enable the "autosync" feature to periodically synchronize the server.

jupyter lab \
    --gateway-url=http://127.0.0.1:9999 \
    --ServerApp.session_manager_class=jupyter_server_synchronizer.SynchronizerSessionManager
    --SynchronizerSessionManager.database_filepath=jupyter-database.db \
    --SynchronizerSessionManager.autosync=True \
    --SynchronizerSessionManager.log_level=DEBUG

Now, let's kill that server:

kill -9 $(echo $(pgrep -lf jupyter-lab) | awk '{print $1;}')

And restart it to see if the kernels rehydrate and begin synchronizing again.

jupyter lab \
    --gateway-url=http://127.0.0.1:9999 \
    --ServerApp.session_manager_class=jupyter_server_synchronizer.SynchronizerSessionManager
    --SessionManager.database_filepath=jupyter-database.db \
    --SynchronizerSessionManager.autosync=True \
    --SynchronizerSessionManager.log_level=DEBUG

Release files for jupyter-server-synchronizer 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyter-server-synchronizer 0.0.10
File Size Uploaded
jupyter_server_synchronizer-0.0.10.tar.gz 20.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyter-server-synchronizer 0.0.10
File Interpreter ABI Platform
jupyter_server_synchronizer-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 36.2 kB

Release files / jupyter_server_synchronizer-0.0.10.tar.gz

Download URL jupyter_server_synchronizer-0.0.10.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
567198c56b787dd186c61c37d24a667165707d26eada2bedfe5466eb81e5ec31
BLAKE2b-256 checksum
How to use checksums
43f29560fcebaf15275ca66c918f0c8cecc89c4baec090927eaef0260ac7731f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.11.8

Release files / jupyter_server_synchronizer-0.0.10-py3-none-any.whl

Download URL jupyter_server_synchronizer-0.0.10-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a05a4924d7c1a9807a8b725de6732ef485f58a34859258e64363ad7c0818ae56
BLAKE2b-256 checksum
How to use checksums
1c5efca82829689e8a4463c29f416cececd8bbb55cfaccfe463cf32082254b11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page