Module jupiter::pyrun

source ·
Expand description

Executes Python kernels in separate processes and sends JSON messaes back and forth.

Using the pyrun-kernel loader, kernels can be loaded from ZIP archives. Next to all required resources, the ZIP must contain a kernel.py file which contains the actual kernel code.

A kernel roughly looks like this:


VERSION = "v1.2.3"

# (do heavy-lifting here...)...
# use print(..) to signal the progress of the startup sequence...

def kernel(json):
    return { result: json["input"] * 2 }

The kernel is automatically extended by the required glue code (see prelude.py) which takes care of the inter-process communication. This is actually handled by reading and writing lines to stdin from stdout of the forked process.

The command PY.RUN <kernel> <json> can be used to execute a kernel. Note that the process itself always keeps running, so heavy-lifting (like loading language models) should be done outside of the kernel function.

Using PY.STATS a list of all running kernels can be retrieved. This is useful for debugging and monitoring purposes.

Modules

Structs

  • Describes the public API of the framework.

Enums

  • Describes the administrative commands supported by this actor.

Functions

  • Installs the framework into the given platform.