Skip to main content

A tool designed to start a new Jupyter kernel programmatically using jupyter_client, enabling execution of notebook cells.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tool_jupyterstartkernel


Swarmauri Tool · Jupyter Start Kernel

A Swarmauri orchestration tool that spins up Jupyter kernels on demand using jupyter_client. The helper wraps connection-file management, kernel specification, and timeout handling so automation pipelines, notebook CI, or Swarmauri agents can acquire fresh kernels with one function call.

  • Launches kernels with configurable names and kernel-spec overrides.
  • Surfaces ready-to-use connection metadata for downstream orchestration.
  • Keeps a reference to the underlying KernelManager so you can interact with the kernel lifecycle after launch.

Requirements

  • Python 3.10 – 3.13.
  • The environment must have Jupyter kernel specs installed (for example the default python3).
  • Dependencies (jupyter_client, swarmauri_base, swarmauri_standard, pydantic) install automatically.

Installation

Install via the packaging tool that matches your workflow. Each command fetches transitive dependencies.

pip

pip install swarmauri_tool_jupyterstartkernel

Poetry

poetry add swarmauri_tool_jupyterstartkernel

uv

# Add to the current project and update uv.lock
uv add swarmauri_tool_jupyterstartkernel

# or install into the active environment without touching pyproject.toml
uv pip install swarmauri_tool_jupyterstartkernel

Tip: When using uv inside this repository, run commands from the repository root so uv can resolve the shared pyproject.toml.

Quick Start

The tool behaves like a callable. Instantiate it and optionally pass a kernel_name, timeout, or kernel spec.

from swarmauri_tool_jupyterstartkernel import JupyterStartKernelTool

start_kernel = JupyterStartKernelTool()
result = start_kernel()  # defaults to python3

print(result)
# {
#   'status': 'success',
#   'kernel_id': '03c7d8f9-ec4d-4a8a-8a90-cdb35ff9e6c9',
#   'kernel_name': 'python3',
#   'connection_file': '/Users/.../jupyter/runtime/kernel-03c7d8f9.json'
# }

A non-success status signals the kernel failed to spawn (missing kernelspec, permission issue, etc.).

Usage Scenarios

Launch With Custom Specification

from swarmauri_tool_jupyterstartkernel import JupyterStartKernelTool

start_kernel = JupyterStartKernelTool()
config = {
    "env": {"EXPERIMENT_FLAG": "1"},
    "resource_limits": {"memory": "1G"}
}

custom = start_kernel(kernel_name="python3", kernel_spec=config, startup_timeout=20)

if custom["status"] == "success":
    print(f"Kernel ready at {custom['connection_file']}")
else:
    raise RuntimeError(custom["message"])

Pass a kernel_spec dict to tweak environment variables or other launch parameters that the underlying KernelManager accepts.

Pair With the Shutdown Tool in an Automated Flow

from swarmauri_tool_jupyterstartkernel import JupyterStartKernelTool
from swarmauri_tool_jupytershutdownkernel import JupyterShutdownKernelTool

start_kernel = JupyterStartKernelTool()
shutdown_kernel = JupyterShutdownKernelTool()

launch = start_kernel(kernel_name="python3")
if launch["status"] != "success":
    raise RuntimeError(launch["message"])

kernel_id = launch["kernel_id"]
print(f"Kernel started: {kernel_id}")

# ... run your notebook execution workflow ...

cleanup = shutdown_kernel(kernel_id=kernel_id, shutdown_timeout=10)
print(cleanup)

Use this pairing in CI pipelines or agent flows that must guarantee kernels are torn down after execution.

Integrate Inside a Swarmauri Agent

from swarmauri_core.agent.Agent import Agent
from swarmauri_core.messages.HumanMessage import HumanMessage
from swarmauri_standard.tools.registry import ToolRegistry
from swarmauri_tool_jupyterstartkernel import JupyterStartKernelTool

registry = ToolRegistry()
registry.register(JupyterStartKernelTool())

agent = Agent(tool_registry=registry)
message = HumanMessage(content="start a python3 kernel for my notebook batch job")
response = agent.run(message)
print(response)

The agent resolves the registered tool, starts a kernel, and returns the connection metadata to the conversation context.

Troubleshooting

  • No such kernel – The requested kernel_name is not installed. Check jupyter kernelspec list.
  • Kernel start timeout exceeded – Increase startup_timeout for slow environments or pre-warm interpreters.
  • Permission errors – Ensure the process can create files inside Jupyter's runtime directory (usually ~/.local/share/jupyter/runtime).

License

swarmauri_tool_jupyterstartkernel is released under the Apache 2.0 License. See LICENSE for details.

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

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

File details

Details for the file swarmauri_tool_jupyterstartkernel-0.9.3.dev4.tar.gz.

File metadata

  • Download URL: swarmauri_tool_jupyterstartkernel-0.9.3.dev4.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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 swarmauri_tool_jupyterstartkernel-0.9.3.dev4.tar.gz
Algorithm Hash digest
SHA256 fa1230a7527a835c0efb99362b4806b9a7f3feb3f84faf36dc9b22d555aaf54e
MD5 0c5d7c0c6d870a055fe6ec08e203b0ef
BLAKE2b-256 7a7a5b71951c0da43a3f720035b88c8d86478ff08fd4c3686dbbb09d1829827d

See more details on using hashes here.

File details

Details for the file swarmauri_tool_jupyterstartkernel-0.9.3.dev4-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_jupyterstartkernel-0.9.3.dev4-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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 swarmauri_tool_jupyterstartkernel-0.9.3.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 1ea7ffc87b8c6446b03bc57ec2454844e963e3c5b3ee2150f4b86a04f0933657
MD5 6f6459cd2a2ac62c300ccbfc4a9ed403
BLAKE2b-256 bb7ac99226ae3b0442d0e41b886e4339dd457633ae999e38590ed20c7a6c4123

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