Skip to main content

Swarmauri code-extraction tool for converting Jupyter notebooks into Python scripts with nbconvert.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tool_jupyterexportpython Discord

Swarmauri Jupyter Export Python Tool

swarmauri_tool_jupyterexportpython converts notebook objects into Python scripts through nbconvert.PythonExporter, making it useful for code extraction, audit, and migration workflows.

Why

  • Extract runnable Python from notebooks for review or reuse.
  • Bridge notebook prototypes into script-based workflows.
  • Keep notebook-to-script export inside a Swarmauri tool interface.

Features

  • Accepts notebook objects compatible with nbconvert.
  • Exports Python source through nbconvert.PythonExporter.
  • Supports optional custom templates.
  • Returns the generated script as a string.
  • Returns a structured error payload on export failure.

FAQ

Does this package write a .py file?

No. It returns the exported script text in exported_script.

What kind of input does it expect?

It expects a notebook object, not a file path and not a JSON string.

When should I use a custom template?

Use a custom template when you need a specific script layout, preamble, or code-cell transformation strategy.

Installation

uv add swarmauri_tool_jupyterexportpython
pip install swarmauri_tool_jupyterexportpython

Usage

from swarmauri_tool_jupyterexportpython import JupyterExportPythonTool

notebook = {
    "cells": [{"cell_type": "code", "metadata": {}, "source": "print('hello')", "outputs": []}],
    "metadata": {},
    "nbformat": 4,
    "nbformat_minor": 5,
}

result = JupyterExportPythonTool()(notebook=notebook)
print(result["exported_script"])

Examples

Export a notebook to Python

result = JupyterExportPythonTool()(notebook=notebook)
script = result["exported_script"]

Export with a custom template

result = JupyterExportPythonTool()(
    notebook=notebook,
    template_file="templates/python-export.tpl",
)

Related Packages

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

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

File details

Details for the file swarmauri_tool_jupyterexportpython-0.11.0.dev1.tar.gz.

File metadata

  • Download URL: swarmauri_tool_jupyterexportpython-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

Hashes for swarmauri_tool_jupyterexportpython-0.11.0.dev1.tar.gz
Algorithm Hash digest
SHA256 1bc67fc677c8a7cf5c06b05773d1a1830055b889ebc8705e9eb4d4f64be50742
MD5 6963352a65b1e524f4570fb7e9dc022f
BLAKE2b-256 c5ab19e0e9de6a0f727d7e098c39ff55e35487997f399529f3cc864d928cd8a9

See more details on using hashes here.

File details

Details for the file swarmauri_tool_jupyterexportpython-0.11.0.dev1-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_jupyterexportpython-0.11.0.dev1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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

Hashes for swarmauri_tool_jupyterexportpython-0.11.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab27aed1e8e7fa348346e6191d9b35c5ba6d913a387d219ed6afd0f998e058ac
MD5 4d8de391b450b3f3e77661a882609f44
BLAKE2b-256 f0447ab9bd5d0cfae7151b6754923c2382b1360c1baca9b968ee4ef11dd27cb9

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