Skip to main content

A Jupyter Server Session Manager that rehydrates and synchronizes Jupyter sessions (e.g. notebook-kernel connections).

Project description

Jupyter Server Synchronizer

A Jupyter Server Session Manager that rehydrates and persists kernels and 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_server_synchronizer-0.0.8.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyter_server_synchronizer-0.0.8-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_server_synchronizer-0.0.8.tar.gz.

File metadata

File hashes

Hashes for jupyter_server_synchronizer-0.0.8.tar.gz
Algorithm Hash digest
SHA256 0ac348bb878293779d1053653fe3304eed0b2d6c81cf0a85452fa7b7c74fb04f
MD5 c565162f836047da2d82912003b4e44d
BLAKE2b-256 09aa7ac21dcb2b5ca66c56d792395f8f63ccf4d35644ada21740775b5fcffb8a

See more details on using hashes here.

File details

Details for the file jupyter_server_synchronizer-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_server_synchronizer-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 02598944dd5eadb6f86d0b785a755dd0ae9deaba8dd5b2edf17cab413b67dc2c
MD5 6ae8949a1b6f88e13cd8e55040b532f9
BLAKE2b-256 892fa1b12387fe2a7f982c2d563374749e31d25361b89fb8018a63189e76d1bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page