Swarmauri notebook-ingestion tool for reading and validating Jupyter notebooks with nbformat.
Project description
Swarmauri Jupyter Read Notebook Tool
swarmauri_tool_jupyterreadnotebook reads a Jupyter .ipynb file from disk, parses it with nbformat, validates the notebook schema, and returns the resulting NotebookNode inside a Swarmauri tool response.
Why
- Load notebooks into Swarmauri pipelines before execution, export, or cleanup steps.
- Normalize notebook ingestion around a simple tool contract.
- Catch missing files and notebook schema issues before later notebook-processing stages.
Features
- Reads
.ipynbfiles withnbformat.read. - Validates the parsed notebook with
nbformat.validate. - Returns
{"notebook_node": ...}on success. - Returns
{"error": ...}on file and validation failures. - Supports an
as_versionargument for controlled notebook parsing.
FAQ
What does this tool return?
It returns a dictionary with either notebook_node containing the parsed notebook or error containing a failure message.
Does this tool execute the notebook?
No. It only reads and validates notebook content. Pair it with execution tools when you need code-cell outputs.
When should I change as_version?
Use as_version when you need to coerce notebook parsing to a specific nbformat version for compatibility with downstream tooling.
Installation
uv add swarmauri_tool_jupyterreadnotebook
pip install swarmauri_tool_jupyterreadnotebook
Usage
from swarmauri_tool_jupyterreadnotebook import JupyterReadNotebookTool
tool = JupyterReadNotebookTool()
result = tool(
notebook_file_path="notebooks/example.ipynb",
as_version=4,
)
if "notebook_node" in result:
notebook = result["notebook_node"]
print(len(notebook.cells))
else:
print(result["error"])
Examples
Read a notebook before execution
from swarmauri_tool_jupyterreadnotebook import JupyterReadNotebookTool
reader = JupyterReadNotebookTool()
payload = reader("reports/daily_report.ipynb")
if "notebook_node" in payload:
metadata = payload["notebook_node"].metadata
print(metadata)
Guard against invalid notebook files
response = JupyterReadNotebookTool()("broken.ipynb")
if "error" in response:
print("Notebook ingestion failed:", response["error"])
Related Packages
swarmauri_tool_jupyterwritenotebookswarmauri_tool_jupyterexecutenotebookswarmauri_tool_jupyterexecutenotebookwithparametersswarmauri_tool_jupyterexecuteandconvertswarmauri_tool_jupyterclearoutput
Foundational Swarmauri Packages
More 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 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_jupyterreadnotebook-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_tool_jupyterreadnotebook-0.11.0.dev1.tar.gz
- Upload date:
- Size: 8.5 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 |
ef772f1a2ea829be78aa6c056c0b03d09f4cf7665129e57cc8ef36278c869d93
|
|
| MD5 |
9817ae85b352efb7971ede1d3067fb7d
|
|
| BLAKE2b-256 |
d4becb614d758507b206fca3b91e0edd91c1c166247b217f2b221678d8e61c84
|
File details
Details for the file swarmauri_tool_jupyterreadnotebook-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_jupyterreadnotebook-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 9.6 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 |
f6d8b7ecb5f2864cf475786ff5d835d904d206491d6c0399d3cc640f837936f9
|
|
| MD5 |
671f7480e4edd74a455e61bed2cfbeca
|
|
| BLAKE2b-256 |
f3f45e2ba28b1e4ca23ea75232ccb064a2e6543462e4da663a4cc832ded92000
|