Swarmauri notebook-output tool for writing Jupyter notebook data to disk with read-back verification.
Project description
Swarmauri Jupyter Write Notebook Tool
swarmauri_tool_jupyterwritenotebook writes notebook data to disk as JSON, then reads the file back to confirm the notebook artifact is not empty. It is useful when Swarmauri workflows materialize generated or transformed notebooks.
Why
- Persist notebook data generated in memory by other notebook tools.
- Save cleaned, parameterized, or post-processed notebook artifacts to versioned paths.
- Add a simple write-and-verify step to notebook automation pipelines.
Features
- Accepts notebook content as a dictionary or
NotebookNode-compatible structure. - Writes
.ipynbJSON with configurable text encoding. - Performs a read-back verification step after the write.
- Returns a success payload with the output file path.
- Returns
{"error": ...}when writing or verification fails.
FAQ
Does this tool validate notebook schema?
No. It writes the provided structure as JSON and verifies that the file can be read back. Pair it with notebook-read or notebook-validation steps if you need strict schema checks.
What happens if the notebook payload is empty?
The tool writes the file, then fails verification and returns an error because the round-tripped content is empty.
Can I choose the output encoding?
Yes. The encoding parameter defaults to utf-8, but you can override it when needed.
Installation
uv add swarmauri_tool_jupyterwritenotebook
pip install swarmauri_tool_jupyterwritenotebook
Usage
from swarmauri_tool_jupyterwritenotebook import JupyterWriteNotebookTool
tool = JupyterWriteNotebookTool()
result = tool(
notebook_data={
"nbformat": 4,
"nbformat_minor": 5,
"metadata": {},
"cells": [],
},
output_file="artifacts/output.ipynb",
)
print(result)
Examples
Save a transformed notebook
from swarmauri_tool_jupyterwritenotebook import JupyterWriteNotebookTool
notebook = {
"nbformat": 4,
"nbformat_minor": 5,
"metadata": {},
"cells": [
{"cell_type": "markdown", "metadata": {}, "source": ["# Report"]},
],
}
response = JupyterWriteNotebookTool()(
notebook_data=notebook,
output_file="reports/report.ipynb",
)
print(response["file_path"])
Handle write failures
response = JupyterWriteNotebookTool()(
notebook_data={},
output_file="reports/empty.ipynb",
)
if "error" in response:
print(response["error"])
Related Packages
swarmauri_tool_jupyterreadnotebookswarmauri_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_jupyterwritenotebook-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_tool_jupyterwritenotebook-0.11.0.dev1.tar.gz
- Upload date:
- Size: 8.9 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 |
ae1a036ed3f55498980d67be9b6a78d90b9fee9845d3566327b504d3b3b70267
|
|
| MD5 |
081f9ac3561d6ff95d7721015df6a40d
|
|
| BLAKE2b-256 |
70b335960978b6b99e4cf621128543fda95fe0c548411c79d8f253d480c47aeb
|
File details
Details for the file swarmauri_tool_jupyterwritenotebook-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_jupyterwritenotebook-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 10.0 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 |
a9eefbba22c568f60ef49fb9d8152d0fa791d738c361b898d5e53b6adcb2f605
|
|
| MD5 |
c9d3c9e16d541a10fd4c678a704a844c
|
|
| BLAKE2b-256 |
6ddcb1bab5853800a537a014b6f3277cc9790efe032fd5a1e5c6c66db0309db3
|