Skip to main content

Multi-kernel Manager

Project description

Silik Kernel

A Jupyter Multi Kernel Manager, wrapped in a Jupyter Kernel 🙂 Because "who is more qualified to relay kernel messages than a kernel itself ?"

This is a jupyter kernel that allows to interface with multiple kernels, you can:

  • start, stop and restart kernels,

  • switch between kernels,

  • list available kernels,

  • connect to a living kernel,

  • "store" kernels in fictive "directories"

All of this with simple command lines

A Silik Kernel can be in two modes :

  • command mode : manage kernels (start, stop, ...),

  • connect mode : connects to one kernel, and acts as a gateway with this kernel. Support for TAB completion, and propagation of most sockets messages is implemented here.

Any jupyter kernel can be accessed through silik-kernel

But managing interaction between kernels seems to be a nightmare ?

Not with Agents and LLM. In order to allow users to easily manage multi-kernels, we present a way to access AI agents through jupyter kernels. To do so, we provide a wrapper of a pydantic-ai agent in a kernel. This allows to interact easily with these agents, through ipython for example, and let them manage the output of cells.

It also allows to share agents easily (with pypi for example); because they can be shipped in a python module. We split properly the agent and the interaction framework with the agent, by reusing the ones from jupyter kernels.

Getting started

pip install silik-kernel

The kernel is then installed on the current python venv.

Any jupyter frontend should be able to access the kernel, for example :

Notebook (you might need to restart the IDE) : select 'silik' on top right of the notebook

CLI : Install jupyter-console (pip install jupyter-console); and run jupyter console --kernel silik

Silik Signal Messaging : Access the kernel through Signal Message Application.

To use diverse kernels through silik, you can install some example kernels : https://github.com/Tariqve/jupyter-kernels. You can also create new agent-based kernel by subclassing pydantic-ai base kernel.

You can list the available kernels by running jupyter kernelspec list in a terminal. Or with TAB completion of start command in a cell of a silik kernel.

Usage

Example

Install and start silik-kernel :

python -m venv .venv
source .venv/bin/activate
pip install silik-kernel
jupyter console --kernel silik

Within a cell :

start python3 --label k1
run "x = 19" k1.py
run "print(x)" k1.py

For persistent connection :

> k1.py

Now, all cells of silik kernel are directly transmitted to kernel k1.py. Try:

print(x)

Usage Guide

To go from command mode to connect mode, you have to use the command :

> path_to_kernel

Since this changes the language of the following cells, it must not be mixed with the language of the kernel you connects to. The > path_to_kernel needs to run in a 'silik' cell. And silik cells can only contain silik code - not python, R, ... !

To run code on sub-kernel in a silik cell, you can use run "code" path_to_kernel command.

The following code :

start python3 --label k1
> k1.py
1+1

will stop at the second line; and not execute the last line.

You can not mix languages in a single cell

In command mode :

When you are in command mode, you can use TAB completion to display all commands and values for the arguments. Send help to silik kernel, or see here for the list of commands.

In connect mode

In connect mode, silik kernel acts as a gateway to the kernel selected on command mode.

Code execution : code from the cell is sent to the kernel through its shell channel, using Jupyter MultiKernelManager. Output is retrieved from the iopub channel, and sent to the front-end of silik-kernel. This comprises error messages, stream, display_data, execute_result, ... See jupyter_client documentation.

Code completion : TAB completion of the selected kernel is also connected to the silik frontend;

The only code which is not sent to sub kernel is /cmd. This is the exit of connect mode.

Recursive

You can start a silik kernel from a silik kernel. But you can only control the children-silik with run "code" path_to_sub_silik; and not directly /cmd (because it is catched before by the first silik).

You can hence implement your own sub-class of silik kernel, and add any method for spreading silik input to sub-kernels, and merging output of sub-kernels to produce silik output.

Similar projects

Existing projects involving multi kernel management already exists :

  • jupyter-mcp-server : a server that is accessible through the MCP protocol, to manage multiple kernels and notebooks. To our knowledge, the MCP server does not interact with a Jupyter Kernel, but directly manages Kernels.

  • SoS Polyglot Notebook : an other multi-kernel manager, through jupyter notebook. Uses a 'Super Kernel' to manage all sub-kernels. To our knowledge, the Super Kernel is not a Jupyter Kernel.

  • jupyter-kernel-mcp: MCP server that allows to manage multi kernels. Unlike jupyter-mcp-server, it interact directly with jupyter kernels.

  • jupyter-code-executor-mcp-server : MCP server that allows to manage multi-kernels. Deals with notebooks and not with kernels directly.

The difference between these projects and silik-kernel is the fact that we wrapped the Kernel Manager itself in a Jupyter Kernel. Moreover, the interaction with sub-kernels is not necessarly made by LLMs through an MCP server (as in jupyter-kernel-mcp) - kernels can be managed by humans first, and LLMs after :-).

Both jupyter-mcp-server and SoS Polyglot Notebook interacts with notebooks. We propose here an interaction at a lower level : directly with the jupyter-kernel. Instead of using high-level commands to manage kernels (like SoS Polyglot Notebook), we use a lightweight bash-like language. This allows to reuse existing jupyter messaging protocol for multi-kernel management (and hence branching any front-end to it). In SoS, the interaction between kernels is dealt with a protocol that allows to share variables, files, ...

We are betting here to use 'text-only' interactions : fewer features but deployment is easier. This is possible thanks to LLM and Agent.

Help

See help.md !

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

silik_kernel-1.6.0.tar.gz (26.6 kB view details)

Uploaded Source

File details

Details for the file silik_kernel-1.6.0.tar.gz.

File metadata

  • Download URL: silik_kernel-1.6.0.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for silik_kernel-1.6.0.tar.gz
Algorithm Hash digest
SHA256 a59dafbb61db97a6cb7855b12df02ca84b4e769c9e8794ea73fc149785a5149c
MD5 917c14f87719c54f4d449c35e4719aad
BLAKE2b-256 f3d089dc8d4694ecf5b738b65f036bfa07bc05e06a4c22d8eae97aef8b740446

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