A Jupyter Server extension providing an endpoint for kernel connection files.
Project description
jupyter-server-connections: A Jupyter server extension to share kernel connection files
Each kernel creates a connections file formatted as JSON that contains the
ports used for creating the various ZeroMQ sockets to communicate with the
kernel. This file is located in the JUPYTER_RUNTIME_DIR directory, e.g.,
~/.local/share/jupyter/data/runtime, with a kernel-<id>.json file name
structure, where <id> is replaced with the UUID of the kernel. The UUID is
automatically generated when using the POST /kernels endpoint of the
jupyter_server REST API.
The POST /kernels endpoint returns only the Location header to the newly
created kernel. The GET /kernels endpoint returns a list of kernels with some
information about the kernels, like the id, name, execution_count, and
last_activity. The GET /kernels/{id} endpoint of the jupyter_server REST API
returns the same information for a specific kernel. However, the connection file
contents are not supplied by these endpoints. So, a client using the
jupyter_server REST API can create, start, stop, and remove kernels but there is
no way to obtain the connection file contents for the kernels from the
jupyter_server REST API, which is needed to establish a connection to the ZeroMQ
sockets to connect and execute code on the kernels.
I have not found a solution to this. There is probably another extension or tool I am supposed to use (Gateway?), but this seems like something that should be provided with the REST API. This extension adds endpoints to the jupyter_server REST API to get connection files for kernels. This eliminates the need to use alternative methods to communicate the connection files to clients, such as Network File System (NFS).
Installation
-
Install the
jupyter_server_connectionspackage usingpipand the public package repository (PyPI).pip install jupyter_server_connections
Contributing
-
Clone this repository.
git clone https://github.com/Theia-Scientific/jupyter_server_connections.git && cd jupyter_server_connections
-
Create a virtual environment.
python3 -m venv .venv
-
Activate the virtual environment.
source .venv/bin/activate
or if direnv is installed:
cp .envrc.example .envrc
followed by:
direnv allow -
Install the package, utility, the required dependencies, and the development dependencies.
python3 -m pip install -e ".[dev]"
-
Create a local branch.
git checkout -b feature-awesome-new-feature
-
Modify the code.
-
Manually test features by starting the Jupyter server.
jupyter server --ServerApp.jpserver_extensions="{'jupyter_server_connections': True}"
Information will be printed to the console, e.g.,
[I 2025-12-13 13:35:01.795 ServerApp] jupyter_server_connections | extension was successfully linked. [I 2025-12-13 13:35:01.797 ServerApp] jupyter_server_terminals | extension was successfully linked. [I 2025-12-13 13:35:01.810 ConnectionsExtensionApp] Initialize settings [I 2025-12-13 13:35:01.810 ServerApp] jupyter_server_connections | extension was successfully loaded. [I 2025-12-13 13:35:01.810 ServerApp] jupyter_server_terminals | extension was successfully loaded. [I 2025-12-13 13:35:01.812 ServerApp] Serving notebooks from local directory: /home/cfield/Code/jupyter_server_connections [I 2025-12-13 13:35:01.812 ServerApp] Jupyter Server 2.17.0 is running at: [I 2025-12-13 13:35:01.812 ServerApp] http://localhost:8888/?token=<TOKEN> [I 2025-12-13 13:35:01.812 ServerApp] http://127.0.0.1:8888/?token=<TOKEN> [I 2025-12-13 13:35:01.812 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 2025-12-13 13:35:01.814 ServerApp] To access the server, open this file in a browser: file:///home/cfield/.local/share/jupyter/runtime/jpserver-<ID>-open.html Or copy and paste one of these URLs: http://localhost:8888/?token=<TOKEN> http://127.0.0.1:8888/?token=<TOKEN>
Copy the
<TOKEN>value and save for later. It will be needed for executing curl commands.Start a new terminal while leaving the previous terminal running, and create a shell variable for the
<TOKEN>value copied earlier from the previous terminal still running thejupyter serverapplication.export TOKEN=<TOKEN>
Check if any kernels already exist.
curl "http://localhost:8888/api/kernels?token=${TOKEN}" []
Create a new kernel.
curl -X POST -d '{"name":"python3"}' "http://localhost:8888/api/kernels?token=${TOKEN}" [{"id": "b2042229-7c6c-416b-9ae2-97ae16017cf5", "name": "python3", "last_activity": "2025-12-13T18:11:28.731478Z", "execution_state": "starting", "connections": 0}]
Copy the value for the
idfield and export to a shell variable.export ID=b2042229-7c6c-416b-9ae2-97ae16017cf5
Try the endpoints from this extension.
$ curl "http://localhost:8888/api/kernels/${ID}/connection?token=${TOKEN}" {"shell_port": 42679, "iopub_port": 35375, "stdin_port": 58141, "control_port": 48063, "hb_port": 55541, "ip": "127.0.0.1", "key": "6a553a72-a32a994e0a70400ae68a6922", "transport": "tcp", "signature_scheme": "hmac-sha256", "kernel_name": "python3"}
When done testing, close the current terminal that was used to invoke
curlcommands. Change back to the terminal running thejupyter servercommand. PressCTRL+Cand enterYto stop the process. -
Run automated tests locally on developer machine, and add tests to maintain 100% coverage as needed.
pytest --color=yes --cov=jupyter_server_connections --cov-report=term-missing
-
Run linter for style conformity and minimize potential bugs.
flake8 . --exclude .venv --count --max-complexity=10 --max-line-length=127 --statistics
-
Commit changes to your local branch.
git add -A && git commit -m "Add new feature"
-
Push your local branch to GitHub to create a Pull Request (PR).
git push origin feature-awesome-new-feature
-
Create a Pull Request (PR) in GitHub.
-
Wait for CI to complete.
-
Add comment to PR that it is ready to review.
License
This project is licensed under either the 3-Clause BSD license See the LICENSE file for information about licensing and copyright.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyter_server_connections-0.1.1.tar.gz.
File metadata
- Download URL: jupyter_server_connections-0.1.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fbb066d1eec27943ed449f590f6ee0b2cc3d67f081210693e508bf872717c6a
|
|
| MD5 |
65d3994b0d5ccb452d3a2b01ac1079f0
|
|
| BLAKE2b-256 |
85bd43ecdc347f7f5c17396afc9a7cda8e3dc191750d2933f845a200609dac43
|
Provenance
The following attestation bundles were made for jupyter_server_connections-0.1.1.tar.gz:
Publisher:
publish.yml on Theia-Scientific/jupyter-server-connections
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jupyter_server_connections-0.1.1.tar.gz -
Subject digest:
9fbb066d1eec27943ed449f590f6ee0b2cc3d67f081210693e508bf872717c6a - Sigstore transparency entry: 1940171857
- Sigstore integration time:
-
Permalink:
Theia-Scientific/jupyter-server-connections@73baf80bfbba517b6ae4509d2ad6532c8eed466b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Theia-Scientific
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@73baf80bfbba517b6ae4509d2ad6532c8eed466b -
Trigger Event:
push
-
Statement type:
File details
Details for the file jupyter_server_connections-0.1.1-py3-none-any.whl.
File metadata
- Download URL: jupyter_server_connections-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d3408cb1fd807e92490a7e7997887c12bda8fc5734c1b6364819ec6166b462e
|
|
| MD5 |
db121c3e3188cfa1034b3f1a1aed8bcd
|
|
| BLAKE2b-256 |
aea7045e9ca8e31a0968e627d30c4739e7789d4a53718169788efb8c0609e0b8
|
Provenance
The following attestation bundles were made for jupyter_server_connections-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Theia-Scientific/jupyter-server-connections
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jupyter_server_connections-0.1.1-py3-none-any.whl -
Subject digest:
2d3408cb1fd807e92490a7e7997887c12bda8fc5734c1b6364819ec6166b462e - Sigstore transparency entry: 1940171954
- Sigstore integration time:
-
Permalink:
Theia-Scientific/jupyter-server-connections@73baf80bfbba517b6ae4509d2ad6532c8eed466b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Theia-Scientific
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@73baf80bfbba517b6ae4509d2ad6532c8eed466b -
Trigger Event:
push
-
Statement type: