Skip to main content

An agent to bring cluster kernel to local

Project description

Jupyter Kernel Agent

PyPI version
Python Version
License: MIT

Jupyter Kernel Agent lets you run Jupyter code remotely by forwarding code to an HTTP endpoint and streaming results back in Jupyter’s native format.
Connect your Jupyter environment to clusters, GPU servers, or any backend that implements the Kernel Agent API.


Features

  • 📡 Remote code execution over HTTP
  • 🔑 Bearer token authentication
  • 🖥️ Multiple backends (one kernel per endpoint)
  • 🔄 Built-in magics for session management:
    • %reset — clear remote namespace / start new session
    • %shutdown — shut down remote session
    • %welcome — show kernel info
    • %reconnect — reconnect after disconnect
  • 🛑 Disconnection handling: hold (default) or exit

Installation

pip install jupyter-kernel-agent

This provides two CLI tools:

  • agent-server — run the FastAPI backend for code execution
  • kernel_agent — manage Jupyter kernelspecs (install/list/delete)

Running the Server

Start the server with an API key:

agent-server --host 0.0.0.0 --port 8000 --api_key SECRET123

Test with curl:

curl -sX POST http://127.0.0.1:8000/kernel \
  -H "Authorization: Bearer SECRET123" \
  -H "Content-Type: application/json" \
  -d '{"action":"execute","session_id":"s1","code":"1+1","execution_count":1}'

Expected response:

{"ok":true,"outputs":[{"type":"execute_result","data":{"text/plain":"2"},"execution_count":1,"metadata":{}}]}

Installing a Jupyter Kernel

Install a kernel that connects to your server:

kernel_agent install \
  --endpoint http://127.0.0.1:8000/kernel \
  --name local \
  --api_key SECRET123 --user

List installed kernels:

kernel_agent list

You should see your new kernel listed and available in Jupyter.


System-wide Installation

To install for all users (e.g., JupyterHub):

sudo kernel_agent install \
  --endpoint http://127.0.0.1:8000/kernel \
  --name cluster \
  --api_key SECRET123 \
  --sys-prefix

Or specify a custom prefix:

sudo kernel_agent install \
  --endpoint http://127.0.0.1:8000/kernel \
  --name cluster \
  --api_key SECRET123 \
  --prefix /usr/local

Verify with:

jupyter kernelspec list

Usage in Notebooks

After installation, select your kernel (e.g., local or cluster) in Jupyter and run code as usual:

1+1
!uname -a
%reset

Outputs will be returned from the remote server.


License

Apache-2.0

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_kernel_agent-1.2.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

jupyter_kernel_agent-1.2.2-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_kernel_agent-1.2.2.tar.gz.

File metadata

  • Download URL: jupyter_kernel_agent-1.2.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for jupyter_kernel_agent-1.2.2.tar.gz
Algorithm Hash digest
SHA256 02c2eba0438c80934e429b61b5812c9d385ca0eb6d3e19289448d981daebce92
MD5 b5b0fb0fe462bae6745f19a65c80f469
BLAKE2b-256 9f190de843a0c7a4b172dc2c1b522ecb4128b1064c1fa43d44b724da348189a1

See more details on using hashes here.

File details

Details for the file jupyter_kernel_agent-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_kernel_agent-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ce3105a24a6d676d4604e447ef0fff93f9bc0e9b1921f3bf5c34a794e3824849
MD5 ffe32eefe4b6935a37a9517c95ff9621
BLAKE2b-256 e8cafba4d77c94d3b613f90b05173a76e5852b0eecf77405c28388623538467e

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