Skip to main content

Python toolkit for Jupyter runtimes, powered by runtimed Rust binaries

Project description

runtimed

Python bindings for the nteract runtime daemon. Execute code, manage kernels, and interact with notebooks programmatically.

Download the nteract desktop app — it ships the runtimed daemon and gives you a visual interface for your notebooks.

Using runtimed with agents? The nteract MCP server is built on runtimed and provides a ready-made agentic interface for AI assistants. It's also a great example of how to use runtimed in practice.

Installation

pip install runtimed

The stable release matches the nteract desktop stable app. If you're running the nightly desktop app, install the pre-release to match: pip install --pre runtimed (or uv pip install --prerelease allow runtimed). The nightly build automatically discovers the nightly daemon socket.

Client() and the high-level Python API use default_socket_path() by default. That helper respects RUNTIMED_SOCKET_PATH, so exported test or MCP sockets take precedence over the package's default channel.

Quick Start

All examples use await — run them inside asyncio.run(main()), a Jupyter notebook, or a Python REPL with top-level await (e.g. python -m asyncio).

import asyncio
import runtimed

async def main():
    client = runtimed.Client()
    notebook = await client.create_notebook()

    # Create and execute cells
    cell = await notebook.cells.create("print('hello')")
    result = await cell.run()
    print(result.stdout)  # "hello\n"

    # Read cell properties (sync — local CRDT replica)
    print(cell.source)      # "print('hello')"
    print(cell.cell_type)   # "code"

    # Edit cells
    await cell.set_source("x = 42")
    await cell.run()

    # Save the notebook
    path = await notebook.save_as("/tmp/my-notebook.ipynb")

asyncio.run(main())

Features

  • Document-first model with Automerge CRDT sync
  • Sync reads, async writes — reads from local replica, writes sync to peers
  • Multi-client support for shared notebooks
  • Rich output capture (stdout, stderr, display_data, errors)

API Overview

Client

client = runtimed.Client()

# Discover active notebooks
notebooks = await client.list_active_notebooks()
for info in notebooks:
    print(f"{info.name} [{info.status}] ({info.active_peers} peers)")

# Open, create, or join notebooks
notebook = await client.open_notebook("/path/to/notebook.ipynb")
notebook = await client.create_notebook(runtime="python")
notebook = await client.join_notebook(notebook_id)

If you need to target a specific release channel instead of the current process default:

import os
import runtimed

os.environ["RUNTIMED_SOCKET_PATH"] = runtimed.socket_path_for_channel("nightly")
client = runtimed.Client()

Use default_socket_path() for normal current-process behavior. Use socket_path_for_channel("stable"|"nightly") only for explicit channel targeting or cross-channel discovery because it intentionally ignores RUNTIMED_SOCKET_PATH.

Notebook

async with await client.create_notebook() as notebook:
    # Cells collection (sync reads, async writes)
    print(len(notebook.cells))
    for cell in notebook.cells:
        print(f"{cell.id[:8]}: {cell.source[:40]}")

    # Runtime state (sync read from local doc)
    print(notebook.runtime.kernel.status)

    # Runtime lifecycle
    await notebook.start(runtime="python")
    await notebook.restart()
    await notebook.interrupt()
    await notebook.save()
# Session closed automatically on exit

Cells

# Create cells
cell = await notebook.cells.create("import math")
cell = await notebook.cells.insert_at(0, "# Title", cell_type="markdown")

# Access cells
cell = notebook.cells.get_by_index(0)    # by position
cell = notebook.cells.get_by_id(cell_id) # by ID
matches = notebook.cells.find("import")  # search source

# Read properties (sync)
print(cell.source, cell.cell_type, cell.outputs)

# Mutate (async)
await cell.set_source("x = 2")
await cell.append("\ny = 3")
result = await cell.run()
await cell.delete()

Requirements

Documentation

See docs/python-bindings.md for full documentation.

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

runtimed-2.2.0-cp39-abi3-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.9+Windows x86-64

runtimed-2.2.0-cp39-abi3-manylinux_2_39_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.39+ x86-64

runtimed-2.2.0-cp39-abi3-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file runtimed-2.2.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: runtimed-2.2.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for runtimed-2.2.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1245a183668751b8debd1b79bb95cdf60179f573e80f28b50316a2a31073584f
MD5 f0c2829306c9f3f16f7464222c4aeac1
BLAKE2b-256 b5a8fafde80560d5e96c55d5ead0dbfec99c4b84a4f6e1f49055982afe2ee473

See more details on using hashes here.

File details

Details for the file runtimed-2.2.0-cp39-abi3-manylinux_2_39_x86_64.whl.

File metadata

  • Download URL: runtimed-2.2.0-cp39-abi3-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 5.3 MB
  • Tags: CPython 3.9+, manylinux: glibc 2.39+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for runtimed-2.2.0-cp39-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 72aee8ef701755b8939c73272ec5b557a4a714ff69f8a80cc3ed412319200fbd
MD5 6fb32cde5b71912357873e671384c477
BLAKE2b-256 6e47ca258787075db7f9e86e1fa5f899c194970825da149a6ae32a8c3ba1075c

See more details on using hashes here.

File details

Details for the file runtimed-2.2.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: runtimed-2.2.0-cp39-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.9+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for runtimed-2.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 17ed63997b38de009e347116c4f3cffa976d50eb8e5fd93b37a8b126ae96ea21
MD5 ba233d48c25a2ab246fc89824cba9e1c
BLAKE2b-256 509ce3fb937371182c8319f08d368f6fd21085edb94750cd2f601d7af2bb03fd

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