A tool that exports a Jupyter Notebook to a Python script using nbconvert’s PythonExporter, facilitating code extraction.
Project description
Swarmauri Tool Jupyter Export Python
Exports a Jupyter NotebookNode to a Python script using nbconvert’s PythonExporter with optional custom templates.
Features
- Accepts a notebook object (
nbformat.NotebookNode) and returns the rendered.pysource. - Supports passing an nbconvert template for custom formatting.
- Returns
{"exported_script": ...}on success or{"error": ...}on failure.
Prerequisites
- Python 3.10 or newer.
- nbconvert/nbformat installed (pulled automatically).
Installation
# pip
pip install swarmauri_tool_jupyterexportpython
# poetry
poetry add swarmauri_tool_jupyterexportpython
# uv (pyproject-based projects)
uv add swarmauri_tool_jupyterexportpython
Quickstart
import nbformat
from swarmauri_tool_jupyterexportpython import JupyterExportPythonTool
notebook = nbformat.read("notebooks/example.ipynb", as_version=4)
exporter = JupyterExportPythonTool()
result = exporter(notebook, template_file=None)
if "exported_script" in result:
Path("notebooks/example.py").write_text(result["exported_script"], encoding="utf-8")
else:
print("Error:", result["error"])
Tips
- Use custom templates to control cell separators or code comments—pass a
.tplfile viatemplate_file. - Pair with notebook execution tools (execute → export to .py) to operationalize notebooks as Python scripts.
Want to help?
If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.
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_jupyterexportpython-0.10.0.dev5.tar.gz.
File metadata
- Download URL: swarmauri_tool_jupyterexportpython-0.10.0.dev5.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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 |
e6dd5326258a54f884cded52720ae78bd3c6f6e8d178cac976d42878a5f55669
|
|
| MD5 |
6bbb6679291464967d3e1d8050ee2eb0
|
|
| BLAKE2b-256 |
4049d3e4b6d9085b7e9ec35c163d4e10efa16fa5e4ed6d9b95e33e10d3497f09
|
File details
Details for the file swarmauri_tool_jupyterexportpython-0.10.0.dev5-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_jupyterexportpython-0.10.0.dev5-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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 |
80af4989864f4f4ac5151eea280a45e351acd1f775044c02a7334c43a05df6f1
|
|
| MD5 |
65ad786e543a3eed7bcb2b9d019ed7f9
|
|
| BLAKE2b-256 |
f53e5733ed5b77040a9598a373859a0e0db028f8fd0d29d22fcae6e242455c06
|