swarmauri_tool_jupyterexportpython 0.10.1.dev2__py3-none-any.whl → 0.11.0.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,12 @@
1
1
  """
2
2
  JupyterExportPythonTool.py
3
3
 
4
- This module defines the JupyterExportPythonTool, a component that exports a Jupyter Notebook
5
- (NotebookNode) to a Python script. It leverages the swarmauri tool architecture and nbconvert
6
- to perform the notebook-to-script conversion, supports optional custom templates, and logs
4
+ This module defines the JupyterExportPythonTool, a component that exports a
5
+ Jupyter Notebook
6
+ (NotebookNode) to a Python script. It leverages the swarmauri tool architecture
7
+ and nbconvert
8
+ to perform the notebook-to-script conversion, supports optional custom
9
+ templates, and logs
7
10
  errors as needed.
8
11
  """
9
12
 
@@ -24,16 +27,20 @@ logger = logging.getLogger(__name__)
24
27
  @ComponentBase.register_type(ToolBase, "JupyterExportPythonTool")
25
28
  class JupyterExportPythonTool(ToolBase):
26
29
  """
27
- JupyterExportPythonTool is a tool that converts a Jupyter Notebook (NotebookNode) into
28
- a Python script. It supports custom templates for export, logs operations and errors,
30
+ JupyterExportPythonTool is a tool that converts a Jupyter Notebook
31
+ (NotebookNode) into
32
+ a Python script. It supports custom templates for export, logs operations
33
+ and errors,
29
34
  and returns the exported Python script as a string.
30
35
 
31
36
  Attributes:
32
37
  version (str): The version of the JupyterExportPythonTool.
33
- parameters (List[Parameter]): A list of parameters required to perform the export.
38
+ parameters (List[Parameter]): A list of parameters required to perform
39
+ the export.
34
40
  name (str): The name of the tool.
35
41
  description (str): A brief description of the tool's functionality.
36
- type (Literal["JupyterExportPythonTool"]): The type identifier for the tool.
42
+ type (Literal["JupyterExportPythonTool"]): The type identifier for the
43
+ tool.
37
44
  """
38
45
 
39
46
  version: str = "1.0.0"
@@ -42,13 +49,21 @@ class JupyterExportPythonTool(ToolBase):
42
49
  Parameter(
43
50
  name="notebook",
44
51
  input_type="object",
45
- description="The NotebookNode object representing the Jupyter Notebook to export.",
52
+ description=(
53
+ "The NotebookNode object representing the Jupyter Notebook " # noqa: E501
54
+ "to "
55
+ "export."
56
+ ),
46
57
  required=True,
47
58
  ),
48
59
  Parameter(
49
60
  name="template_file",
50
61
  input_type="string",
51
- description="Optional custom template path for exporting the notebook to a Python script.",
62
+ description=(
63
+ "Optional custom template path for exporting the notebook "
64
+ "to "
65
+ "a Python script."
66
+ ),
52
67
  required=False,
53
68
  ),
54
69
  ]
@@ -61,17 +76,22 @@ class JupyterExportPythonTool(ToolBase):
61
76
  self, notebook: NotebookNode, template_file: Optional[str] = None
62
77
  ) -> Dict[str, Any]:
63
78
  """
64
- Converts the provided Jupyter Notebook (NotebookNode) to a Python script using
65
- nbconvert. Optionally applies a custom template if template_file is provided.
79
+ Converts the provided Jupyter Notebook (NotebookNode) to a Python
80
+ script using
81
+ nbconvert. Optionally applies a custom template if template_file is
82
+ provided.
66
83
 
67
84
  Args:
68
85
  notebook (NotebookNode): The notebook object to be exported.
69
- template_file (str, optional): Path to a custom template file to structure
86
+ template_file (str, optional): Path to a custom template file to
87
+ structure
70
88
  the exported Python script.
71
89
 
72
90
  Returns:
73
- Dict[str, Any]: A dictionary containing either "exported_script" with the
74
- Python code as a string, or an "error" message if an exception
91
+ Dict[str, Any]: A dictionary containing either "exported_script"
92
+ with the
93
+ Python code as a string, or an "error" message if
94
+ an exception
75
95
  occurred during export.
76
96
 
77
97
  Example:
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_tool_jupyterexportpython
3
+ Version: 0.11.0.dev1
4
+ Summary: Swarmauri code-extraction tool for converting Jupyter notebooks into Python scripts with nbconvert.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: jupyter,python export,notebook conversion,nbconvert,code extraction,ipynb to py,notebook migration,python exporter
8
+ Author: Jacob Stewart
9
+ Author-email: jacob@swarmauri.com
10
+ Requires-Python: >=3.10,<3.15
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Framework :: Jupyter
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Classifier: Topic :: Software Development :: Code Generators
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
+ Classifier: Programming Language :: Python
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: Programming Language :: Python :: 3 :: Only
25
+ Classifier: Programming Language :: Python :: 3.10
26
+ Classifier: Programming Language :: Python :: 3.11
27
+ Classifier: Programming Language :: Python :: 3.12
28
+ Classifier: Programming Language :: Python :: 3.13
29
+ Classifier: Programming Language :: Python :: 3.14
30
+ Requires-Dist: nbconvert (>=7.16.6)
31
+ Requires-Dist: swarmauri_base
32
+ Requires-Dist: swarmauri_core
33
+ Requires-Dist: swarmauri_standard
34
+ Description-Content-Type: text/markdown
35
+
36
+ ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
37
+
38
+ <p align="center">
39
+ <a href="https://pepy.tech/project/swarmauri_tool_jupyterexportpython/">
40
+ <img src="https://static.pepy.tech/badge/swarmauri_tool_jupyterexportpython/month" alt="PyPI - Downloads"/></a>
41
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexportpython/">
42
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexportpython.svg"/></a>
43
+ <a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
44
+ <img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
45
+ <a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
46
+ <img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterexportpython" alt="PyPI - License"/></a>
47
+ <a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
48
+ <img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterexportpython?label=swarmauri_tool_jupyterexportpython&color=green" alt="PyPI - swarmauri_tool_jupyterexportpython"/></a>
49
+ <a href="https://discord.gg/N4UpBuQv8T">
50
+ <img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
51
+
52
+ # Swarmauri Jupyter Export Python Tool
53
+
54
+ `swarmauri_tool_jupyterexportpython` converts notebook objects into Python scripts through `nbconvert.PythonExporter`, making it useful for code extraction, audit, and migration workflows.
55
+
56
+ ## Why
57
+
58
+ - Extract runnable Python from notebooks for review or reuse.
59
+ - Bridge notebook prototypes into script-based workflows.
60
+ - Keep notebook-to-script export inside a Swarmauri tool interface.
61
+
62
+ ## Features
63
+
64
+ - Accepts notebook objects compatible with `nbconvert`.
65
+ - Exports Python source through `nbconvert.PythonExporter`.
66
+ - Supports optional custom templates.
67
+ - Returns the generated script as a string.
68
+ - Returns a structured error payload on export failure.
69
+
70
+ ## FAQ
71
+
72
+ ### Does this package write a `.py` file?
73
+
74
+ No. It returns the exported script text in `exported_script`.
75
+
76
+ ### What kind of input does it expect?
77
+
78
+ It expects a notebook object, not a file path and not a JSON string.
79
+
80
+ ### When should I use a custom template?
81
+
82
+ Use a custom template when you need a specific script layout, preamble, or code-cell transformation strategy.
83
+
84
+ ## Installation
85
+
86
+ ```bash
87
+ uv add swarmauri_tool_jupyterexportpython
88
+ ```
89
+
90
+ ```bash
91
+ pip install swarmauri_tool_jupyterexportpython
92
+ ```
93
+
94
+ ## Usage
95
+
96
+ ```python
97
+ from swarmauri_tool_jupyterexportpython import JupyterExportPythonTool
98
+
99
+ notebook = {
100
+ "cells": [{"cell_type": "code", "metadata": {}, "source": "print('hello')", "outputs": []}],
101
+ "metadata": {},
102
+ "nbformat": 4,
103
+ "nbformat_minor": 5,
104
+ }
105
+
106
+ result = JupyterExportPythonTool()(notebook=notebook)
107
+ print(result["exported_script"])
108
+ ```
109
+
110
+ ## Examples
111
+
112
+ ### Export a notebook to Python
113
+
114
+ ```python
115
+ result = JupyterExportPythonTool()(notebook=notebook)
116
+ script = result["exported_script"]
117
+ ```
118
+
119
+ ### Export with a custom template
120
+
121
+ ```python
122
+ result = JupyterExportPythonTool()(
123
+ notebook=notebook,
124
+ template_file="templates/python-export.tpl",
125
+ )
126
+ ```
127
+
128
+ ## Related Packages
129
+
130
+ - [`swarmauri_tool_jupyterexporthtml`](https://pypi.org/project/swarmauri_tool_jupyterexporthtml/)
131
+ - [`swarmauri_tool_jupyterexportmarkdown`](https://pypi.org/project/swarmauri_tool_jupyterexportmarkdown/)
132
+ - [`swarmauri_tool_jupyterexportlatex`](https://pypi.org/project/swarmauri_tool_jupyterexportlatex/)
133
+ - [`swarmauri_tool_jupyterreadnotebook`](https://pypi.org/project/swarmauri_tool_jupyterreadnotebook/)
134
+ - [`swarmauri_tool_jupyterwritenotebook`](https://pypi.org/project/swarmauri_tool_jupyterwritenotebook/)
135
+
136
+ ## Foundational Swarmauri Packages
137
+
138
+ - [`swarmauri`](https://pypi.org/project/swarmauri/)
139
+ - [`swarmauri_core`](https://pypi.org/project/swarmauri_core/)
140
+ - [`swarmauri_base`](https://pypi.org/project/swarmauri_base/)
141
+ - [`swarmauri_standard`](https://pypi.org/project/swarmauri_standard/)
142
+
143
+ ## More Documentation
144
+
145
+ - [Swarmauri SDK repository](https://github.com/swarmauri/swarmauri-sdk)
146
+ - [nbconvert Python exporter docs](https://nbconvert.readthedocs.io/)
147
+ - [Jupyter documentation](https://jupyter.org/documentation)
148
+
@@ -0,0 +1,7 @@
1
+ swarmauri_tool_jupyterexportpython/JupyterExportPythonTool.py,sha256=RG_y3xl5p7v2dMJghoUX_NrMjUX2BLXZnJfTbuZ_tB8,4366
2
+ swarmauri_tool_jupyterexportpython/__init__.py,sha256=wHP3yvaYRYtyNd2RzXiIyJW051i2QhBOTFUCpxfWMOs,578
3
+ swarmauri_tool_jupyterexportpython-0.11.0.dev1.dist-info/METADATA,sha256=DVg0Hd8a91SEGcva64PJKY2hKBTVy9O2Y9x4pLaeEP0,5988
4
+ swarmauri_tool_jupyterexportpython-0.11.0.dev1.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
5
+ swarmauri_tool_jupyterexportpython-0.11.0.dev1.dist-info/entry_points.txt,sha256=ZlNdomFS-evL1BG5mSTinIz8pW6IKqRylHCgpwiXBAc,102
6
+ swarmauri_tool_jupyterexportpython-0.11.0.dev1.dist-info/licenses/LICENSE,sha256=djUXOlCxLVszShEpZXshZ7v33G-2qIC_j9KXpWKZSzQ,11359
7
+ swarmauri_tool_jupyterexportpython-0.11.0.dev1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.4.0
2
+ Generator: poetry-core 2.4.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,98 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: swarmauri_tool_jupyterexportpython
3
- Version: 0.10.1.dev2
4
- Summary: A tool that exports a Jupyter Notebook to a Python script using nbconvert’s PythonExporter, facilitating code extraction.
5
- License-Expression: Apache-2.0
6
- License-File: LICENSE
7
- Keywords: swarmauri,tool,jupyterexportpython,exports,jupyter,notebook,script,nbconvert,pythonexporter,facilitating,code,extraction,python
8
- Author: Jacob Stewart
9
- Author-email: jacob@swarmauri.com
10
- Requires-Python: >=3.10,<3.15
11
- Classifier: License :: OSI Approved :: Apache Software License
12
- Classifier: Natural Language :: English
13
- Classifier: Development Status :: 3 - Alpha
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
16
- Classifier: Programming Language :: Python
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3 :: Only
19
- Classifier: Programming Language :: Python :: 3.10
20
- Classifier: Programming Language :: Python :: 3.11
21
- Classifier: Programming Language :: Python :: 3.12
22
- Classifier: Programming Language :: Python :: 3.13
23
- Classifier: Programming Language :: Python :: 3.14
24
- Requires-Dist: nbconvert (>=7.16.6)
25
- Requires-Dist: swarmauri_base
26
- Requires-Dist: swarmauri_core
27
- Requires-Dist: swarmauri_standard
28
- Description-Content-Type: text/markdown
29
-
30
- ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
31
-
32
- <p align="center">
33
- <a href="https://pepy.tech/project/swarmauri_tool_jupyterexportpython/">
34
- <img src="https://static.pepy.tech/badge/swarmauri_tool_jupyterexportpython/month" alt="PyPI - Downloads"/></a>
35
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexportpython/">
36
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexportpython.svg"/></a>
37
- <a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
38
- <img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
39
- <a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
40
- <img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterexportpython" alt="PyPI - License"/></a>
41
- <a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
42
- <img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterexportpython?label=swarmauri_tool_jupyterexportpython&color=green" alt="PyPI - swarmauri_tool_jupyterexportpython"/></a>
43
- </p>
44
- ---
45
-
46
- # Swarmauri Tool Jupyter Export Python
47
-
48
- Exports a Jupyter `NotebookNode` to a Python script using nbconvert’s `PythonExporter` with optional custom templates.
49
-
50
- ## Features
51
-
52
- - Accepts a notebook object (`nbformat.NotebookNode`) and returns the rendered `.py` source.
53
- - Supports passing an nbconvert template for custom formatting.
54
- - Returns `{"exported_script": ...}` on success or `{"error": ...}` on failure.
55
-
56
- ## Prerequisites
57
-
58
- - Python 3.10 or newer.
59
- - nbconvert/nbformat installed (pulled automatically).
60
-
61
- ## Installation
62
-
63
- ```bash
64
- # pip
65
- pip install swarmauri_tool_jupyterexportpython
66
-
67
- # poetry
68
- poetry add swarmauri_tool_jupyterexportpython
69
-
70
- # uv (pyproject-based projects)
71
- uv add swarmauri_tool_jupyterexportpython
72
- ```
73
-
74
- ## Quickstart
75
-
76
- ```python
77
- import nbformat
78
- from swarmauri_tool_jupyterexportpython import JupyterExportPythonTool
79
-
80
- notebook = nbformat.read("notebooks/example.ipynb", as_version=4)
81
- exporter = JupyterExportPythonTool()
82
- result = exporter(notebook, template_file=None)
83
-
84
- if "exported_script" in result:
85
- Path("notebooks/example.py").write_text(result["exported_script"], encoding="utf-8")
86
- else:
87
- print("Error:", result["error"])
88
- ```
89
-
90
- ## Tips
91
-
92
- - Use custom templates to control cell separators or code comments—pass a `.tpl` file via `template_file`.
93
- - Pair with notebook execution tools (execute → export to .py) to operationalize notebooks as Python scripts.
94
-
95
- ## Want to help?
96
-
97
- If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
98
-
@@ -1,7 +0,0 @@
1
- swarmauri_tool_jupyterexportpython/JupyterExportPythonTool.py,sha256=KProX34PsEF8uMqY9Qh9jDK6kkBGDFMFypKTSjXtxNo,4088
2
- swarmauri_tool_jupyterexportpython/__init__.py,sha256=wHP3yvaYRYtyNd2RzXiIyJW051i2QhBOTFUCpxfWMOs,578
3
- swarmauri_tool_jupyterexportpython-0.10.1.dev2.dist-info/METADATA,sha256=vjBMwoDe9eGVg6xGW8UTW1ZlvpGzRLC75JOu477p9lY,4261
4
- swarmauri_tool_jupyterexportpython-0.10.1.dev2.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
5
- swarmauri_tool_jupyterexportpython-0.10.1.dev2.dist-info/entry_points.txt,sha256=ZlNdomFS-evL1BG5mSTinIz8pW6IKqRylHCgpwiXBAc,102
6
- swarmauri_tool_jupyterexportpython-0.10.1.dev2.dist-info/licenses/LICENSE,sha256=djUXOlCxLVszShEpZXshZ7v33G-2qIC_j9KXpWKZSzQ,11359
7
- swarmauri_tool_jupyterexportpython-0.10.1.dev2.dist-info/RECORD,,