Swarmauri notebook-lifecycle tool for shutting down Jupyter kernels programmatically with jupyter_client.
Project description
Swarmauri Tool Jupyter Shutdown Kernel
swarmauri_tool_jupytershutdownkernel is a Swarmauri notebook-lifecycle tool
for shutting down Jupyter kernels programmatically. It is useful for notebook
automation cleanup, CI teardown, resource reclamation, and agent workflows that
must terminate kernels after execution.
Why Use Swarmauri Tool Jupyter Shutdown Kernel
- Stop Jupyter kernels cleanly after execution workflows complete.
- Reclaim compute and runtime resources in automated notebook pipelines.
- Provide a standard Swarmauri tool surface for kernel teardown.
- Return structured shutdown status suitable for orchestration and logging.
FAQ
What inputs does the tool expect?
Akernel_idstring and an optionalshutdown_timeout.
What does the tool return?
A dictionary withkernel_id,status, andmessage.
How does it behave when graceful shutdown fails?
It attempts a forced shutdown if the kernel stays alive after the timeout.
What if the kernel cannot be found?
The tool returns an error status with a descriptive message.
Features
- Swarmauri
ToolBaseimplementation registered asJupyterShutdownKernelTool. - Supports graceful shutdown with forced fallback.
- Reports structured success and error states.
- Useful for CI cleanup, notebook automation, and agent-managed kernels.
- Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_tool_jupytershutdownkernel
pip install swarmauri_tool_jupytershutdownkernel
Usage
from swarmauri_tool_jupytershutdownkernel import JupyterShutdownKernelTool
tool = JupyterShutdownKernelTool()
result = tool(kernel_id="example-kernel-id", shutdown_timeout=5)
print(result)
Examples
Shut down a kernel by ID
from swarmauri_tool_jupytershutdownkernel import JupyterShutdownKernelTool
tool = JupyterShutdownKernelTool()
result = tool("kernel-uuid-value", 5)
print(result["status"])
Use after a start-kernel workflow
from swarmauri_tool_jupyterstartkernel import JupyterStartKernelTool
from swarmauri_tool_jupytershutdownkernel import JupyterShutdownKernelTool
starter = JupyterStartKernelTool()
shutdown = JupyterShutdownKernelTool()
launch = starter()
cleanup = shutdown(launch["kernel_id"])
print(cleanup)
Register the tool in a Swarmauri collection
from swarmauri_standard.tools.ToolCollection import ToolCollection
from swarmauri_tool_jupytershutdownkernel import JupyterShutdownKernelTool
tools = ToolCollection(tools=[JupyterShutdownKernelTool()])
print(tools)
Related Packages
- swarmauri_tool_jupyterstartkernel
- swarmauri_tool_jupyterexecutecell
- swarmauri_tool_jupyterruncell
- swarmauri_tool_jupyterclearoutput
Swarmauri Foundations
More Documentation
Best Practices
- Keep track of the kernel ID returned by your startup workflow.
- Use explicit shutdown in CI and automation even when processes are short-lived.
- Increase the timeout for busy kernels that may need a little longer to exit.
- Run shutdown logic on the same host that owns the kernel runtime files.
License
This project is licensed under the Apache-2.0 License.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_tool_jupytershutdownkernel-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_tool_jupytershutdownkernel-0.11.0.dev1.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bf3a4e3efafbbe26b0c1c5a242d23cef5cc971cf4780b65ce8339c59b4856d2
|
|
| MD5 |
3db7ddf6ca2381a8f8602bda8a102736
|
|
| BLAKE2b-256 |
369e7a2a1681f0ebb6edd0a91afc9d934acbf352bcf6dc1d2421aff7a7077a37
|
File details
Details for the file swarmauri_tool_jupytershutdownkernel-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_jupytershutdownkernel-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dff3bfda98222bf679cf84ac9903a2e24abfa342f80d39e60a2f2f56917a9742
|
|
| MD5 |
4af40f7a918bdbbec127b2b54b84cd3b
|
|
| BLAKE2b-256 |
41e57db722c570f7984399f1fb56dedc1c90c4daa35c614c981376a1e67701bd
|