swarmauri_tool_jupyterexportpython 0.10.1.dev3__tar.gz → 0.11.0.dev1__tar.gz
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.
- swarmauri_tool_jupyterexportpython-0.11.0.dev1/PKG-INFO +148 -0
- swarmauri_tool_jupyterexportpython-0.11.0.dev1/README.md +112 -0
- {swarmauri_tool_jupyterexportpython-0.10.1.dev3 → swarmauri_tool_jupyterexportpython-0.11.0.dev1}/pyproject.toml +19 -15
- {swarmauri_tool_jupyterexportpython-0.10.1.dev3 → swarmauri_tool_jupyterexportpython-0.11.0.dev1}/swarmauri_tool_jupyterexportpython/JupyterExportPythonTool.py +34 -14
- swarmauri_tool_jupyterexportpython-0.10.1.dev3/PKG-INFO +0 -97
- swarmauri_tool_jupyterexportpython-0.10.1.dev3/README.md +0 -67
- {swarmauri_tool_jupyterexportpython-0.10.1.dev3 → swarmauri_tool_jupyterexportpython-0.11.0.dev1}/LICENSE +0 -0
- {swarmauri_tool_jupyterexportpython-0.10.1.dev3 → swarmauri_tool_jupyterexportpython-0.11.0.dev1}/swarmauri_tool_jupyterexportpython/__init__.py +0 -0
|
@@ -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
|
+

|
|
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,112 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://pepy.tech/project/swarmauri_tool_jupyterexportpython/">
|
|
5
|
+
<img src="https://static.pepy.tech/badge/swarmauri_tool_jupyterexportpython/month" alt="PyPI - Downloads"/></a>
|
|
6
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexportpython/">
|
|
7
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexportpython.svg"/></a>
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
|
|
9
|
+
<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>
|
|
10
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
|
|
11
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterexportpython" alt="PyPI - License"/></a>
|
|
12
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
|
|
13
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterexportpython?label=swarmauri_tool_jupyterexportpython&color=green" alt="PyPI - swarmauri_tool_jupyterexportpython"/></a>
|
|
14
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
15
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
16
|
+
|
|
17
|
+
# Swarmauri Jupyter Export Python Tool
|
|
18
|
+
|
|
19
|
+
`swarmauri_tool_jupyterexportpython` converts notebook objects into Python scripts through `nbconvert.PythonExporter`, making it useful for code extraction, audit, and migration workflows.
|
|
20
|
+
|
|
21
|
+
## Why
|
|
22
|
+
|
|
23
|
+
- Extract runnable Python from notebooks for review or reuse.
|
|
24
|
+
- Bridge notebook prototypes into script-based workflows.
|
|
25
|
+
- Keep notebook-to-script export inside a Swarmauri tool interface.
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- Accepts notebook objects compatible with `nbconvert`.
|
|
30
|
+
- Exports Python source through `nbconvert.PythonExporter`.
|
|
31
|
+
- Supports optional custom templates.
|
|
32
|
+
- Returns the generated script as a string.
|
|
33
|
+
- Returns a structured error payload on export failure.
|
|
34
|
+
|
|
35
|
+
## FAQ
|
|
36
|
+
|
|
37
|
+
### Does this package write a `.py` file?
|
|
38
|
+
|
|
39
|
+
No. It returns the exported script text in `exported_script`.
|
|
40
|
+
|
|
41
|
+
### What kind of input does it expect?
|
|
42
|
+
|
|
43
|
+
It expects a notebook object, not a file path and not a JSON string.
|
|
44
|
+
|
|
45
|
+
### When should I use a custom template?
|
|
46
|
+
|
|
47
|
+
Use a custom template when you need a specific script layout, preamble, or code-cell transformation strategy.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv add swarmauri_tool_jupyterexportpython
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install swarmauri_tool_jupyterexportpython
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from swarmauri_tool_jupyterexportpython import JupyterExportPythonTool
|
|
63
|
+
|
|
64
|
+
notebook = {
|
|
65
|
+
"cells": [{"cell_type": "code", "metadata": {}, "source": "print('hello')", "outputs": []}],
|
|
66
|
+
"metadata": {},
|
|
67
|
+
"nbformat": 4,
|
|
68
|
+
"nbformat_minor": 5,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
result = JupyterExportPythonTool()(notebook=notebook)
|
|
72
|
+
print(result["exported_script"])
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Examples
|
|
76
|
+
|
|
77
|
+
### Export a notebook to Python
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
result = JupyterExportPythonTool()(notebook=notebook)
|
|
81
|
+
script = result["exported_script"]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Export with a custom template
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
result = JupyterExportPythonTool()(
|
|
88
|
+
notebook=notebook,
|
|
89
|
+
template_file="templates/python-export.tpl",
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Related Packages
|
|
94
|
+
|
|
95
|
+
- [`swarmauri_tool_jupyterexporthtml`](https://pypi.org/project/swarmauri_tool_jupyterexporthtml/)
|
|
96
|
+
- [`swarmauri_tool_jupyterexportmarkdown`](https://pypi.org/project/swarmauri_tool_jupyterexportmarkdown/)
|
|
97
|
+
- [`swarmauri_tool_jupyterexportlatex`](https://pypi.org/project/swarmauri_tool_jupyterexportlatex/)
|
|
98
|
+
- [`swarmauri_tool_jupyterreadnotebook`](https://pypi.org/project/swarmauri_tool_jupyterreadnotebook/)
|
|
99
|
+
- [`swarmauri_tool_jupyterwritenotebook`](https://pypi.org/project/swarmauri_tool_jupyterwritenotebook/)
|
|
100
|
+
|
|
101
|
+
## Foundational Swarmauri Packages
|
|
102
|
+
|
|
103
|
+
- [`swarmauri`](https://pypi.org/project/swarmauri/)
|
|
104
|
+
- [`swarmauri_core`](https://pypi.org/project/swarmauri_core/)
|
|
105
|
+
- [`swarmauri_base`](https://pypi.org/project/swarmauri_base/)
|
|
106
|
+
- [`swarmauri_standard`](https://pypi.org/project/swarmauri_standard/)
|
|
107
|
+
|
|
108
|
+
## More Documentation
|
|
109
|
+
|
|
110
|
+
- [Swarmauri SDK repository](https://github.com/swarmauri/swarmauri-sdk)
|
|
111
|
+
- [nbconvert Python exporter docs](https://nbconvert.readthedocs.io/)
|
|
112
|
+
- [Jupyter documentation](https://jupyter.org/documentation)
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_tool_jupyterexportpython"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "
|
|
3
|
+
version = "0.11.0.dev1"
|
|
4
|
+
description = "Swarmauri code-extraction tool for converting Jupyter notebooks into Python scripts with nbconvert."
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
7
|
-
repository = "
|
|
7
|
+
repository = "https://github.com/swarmauri/swarmauri-sdk"
|
|
8
8
|
requires-python = ">=3.10,<3.15"
|
|
9
9
|
classifiers = [
|
|
10
10
|
"License :: OSI Approved :: Apache Software License",
|
|
11
11
|
"Natural Language :: English",
|
|
12
12
|
"Development Status :: 3 - Alpha",
|
|
13
13
|
"Intended Audience :: Developers",
|
|
14
|
+
"Intended Audience :: Science/Research",
|
|
15
|
+
"Operating System :: OS Independent",
|
|
16
|
+
"Framework :: Jupyter",
|
|
17
|
+
"Topic :: Scientific/Engineering",
|
|
18
|
+
"Topic :: Software Development :: Code Generators",
|
|
19
|
+
"Topic :: Software Development :: Libraries",
|
|
14
20
|
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
15
21
|
"Programming Language :: Python",
|
|
16
22
|
"Programming Language :: Python :: 3",
|
|
@@ -29,25 +35,21 @@ dependencies = [
|
|
|
29
35
|
"swarmauri_standard",
|
|
30
36
|
]
|
|
31
37
|
keywords = [
|
|
32
|
-
"swarmauri",
|
|
33
|
-
"tool",
|
|
34
|
-
"jupyterexportpython",
|
|
35
|
-
"exports",
|
|
36
38
|
"jupyter",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
+
"python export",
|
|
40
|
+
"notebook conversion",
|
|
39
41
|
"nbconvert",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"python",
|
|
42
|
+
"code extraction",
|
|
43
|
+
"ipynb to py",
|
|
44
|
+
"notebook migration",
|
|
45
|
+
"python exporter",
|
|
45
46
|
]
|
|
46
47
|
|
|
47
48
|
[tool.uv.sources]
|
|
48
49
|
swarmauri_core = { workspace = true }
|
|
49
50
|
swarmauri_base = { workspace = true }
|
|
50
51
|
swarmauri_standard = { workspace = true }
|
|
52
|
+
swarmauri_tests_pylicense = { workspace = true }
|
|
51
53
|
|
|
52
54
|
[tool.pytest.ini_options]
|
|
53
55
|
norecursedirs = ["combined", "scripts"]
|
|
@@ -68,6 +70,7 @@ log_cli_level = "INFO"
|
|
|
68
70
|
log_cli_format = "%(asctime)s [%(levelname)s] %(message)s"
|
|
69
71
|
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
|
70
72
|
asyncio_default_fixture_loop_scope = "function"
|
|
73
|
+
addopts = "--pylicense-accept-deps=defusedxml,jupyterlab-pygments,jsonschema,jsonschema-specifications,referencing,rpds-py"
|
|
71
74
|
|
|
72
75
|
[project.entry-points.'swarmauri.tools']
|
|
73
76
|
JupyterExportPythonTool = "swarmauri_tool_jupyterexportpython:JupyterExportPythonTool"
|
|
@@ -83,9 +86,10 @@ dev = [
|
|
|
83
86
|
"pytest-xdist>=3.6.1",
|
|
84
87
|
"pytest-json-report>=1.5.0",
|
|
85
88
|
"python-dotenv",
|
|
86
|
-
"
|
|
89
|
+
"httpx>=0.27",
|
|
87
90
|
"flake8>=7.0",
|
|
88
91
|
"pytest-timeout>=2.3.1",
|
|
89
92
|
"ruff>=0.9.9",
|
|
90
93
|
"pytest-benchmark>=4.0.0",
|
|
94
|
+
"swarmauri_tests_pylicense",
|
|
91
95
|
]
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"""
|
|
2
2
|
JupyterExportPythonTool.py
|
|
3
3
|
|
|
4
|
-
This module defines the JupyterExportPythonTool, a component that exports a
|
|
5
|
-
|
|
6
|
-
to
|
|
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
|
|
28
|
-
|
|
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
|
|
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
|
|
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=
|
|
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=
|
|
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
|
|
65
|
-
|
|
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
|
|
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"
|
|
74
|
-
|
|
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:
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: swarmauri_tool_jupyterexportpython
|
|
3
|
-
Version: 0.10.1.dev3
|
|
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
|
-

|
|
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
|
-
# Swarmauri Tool Jupyter Export Python
|
|
46
|
-
|
|
47
|
-
Exports a Jupyter `NotebookNode` to a Python script using nbconvert’s `PythonExporter` with optional custom templates.
|
|
48
|
-
|
|
49
|
-
## Features
|
|
50
|
-
|
|
51
|
-
- Accepts a notebook object (`nbformat.NotebookNode`) and returns the rendered `.py` source.
|
|
52
|
-
- Supports passing an nbconvert template for custom formatting.
|
|
53
|
-
- Returns `{"exported_script": ...}` on success or `{"error": ...}` on failure.
|
|
54
|
-
|
|
55
|
-
## Prerequisites
|
|
56
|
-
|
|
57
|
-
- Python 3.10 or newer.
|
|
58
|
-
- nbconvert/nbformat installed (pulled automatically).
|
|
59
|
-
|
|
60
|
-
## Installation
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
# pip
|
|
64
|
-
pip install swarmauri_tool_jupyterexportpython
|
|
65
|
-
|
|
66
|
-
# poetry
|
|
67
|
-
poetry add swarmauri_tool_jupyterexportpython
|
|
68
|
-
|
|
69
|
-
# uv (pyproject-based projects)
|
|
70
|
-
uv add swarmauri_tool_jupyterexportpython
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Quickstart
|
|
74
|
-
|
|
75
|
-
```python
|
|
76
|
-
import nbformat
|
|
77
|
-
from swarmauri_tool_jupyterexportpython import JupyterExportPythonTool
|
|
78
|
-
|
|
79
|
-
notebook = nbformat.read("notebooks/example.ipynb", as_version=4)
|
|
80
|
-
exporter = JupyterExportPythonTool()
|
|
81
|
-
result = exporter(notebook, template_file=None)
|
|
82
|
-
|
|
83
|
-
if "exported_script" in result:
|
|
84
|
-
Path("notebooks/example.py").write_text(result["exported_script"], encoding="utf-8")
|
|
85
|
-
else:
|
|
86
|
-
print("Error:", result["error"])
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## Tips
|
|
90
|
-
|
|
91
|
-
- Use custom templates to control cell separators or code comments—pass a `.tpl` file via `template_file`.
|
|
92
|
-
- Pair with notebook execution tools (execute → export to .py) to operationalize notebooks as Python scripts.
|
|
93
|
-
|
|
94
|
-
## Want to help?
|
|
95
|
-
|
|
96
|
-
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.
|
|
97
|
-
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<a href="https://pepy.tech/project/swarmauri_tool_jupyterexportpython/">
|
|
5
|
-
<img src="https://static.pepy.tech/badge/swarmauri_tool_jupyterexportpython/month" alt="PyPI - Downloads"/></a>
|
|
6
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexportpython/">
|
|
7
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexportpython.svg"/></a>
|
|
8
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
|
|
9
|
-
<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>
|
|
10
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
|
|
11
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterexportpython" alt="PyPI - License"/></a>
|
|
12
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexportpython/">
|
|
13
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterexportpython?label=swarmauri_tool_jupyterexportpython&color=green" alt="PyPI - swarmauri_tool_jupyterexportpython"/></a>
|
|
14
|
-
</p>
|
|
15
|
-
|
|
16
|
-
# Swarmauri Tool Jupyter Export Python
|
|
17
|
-
|
|
18
|
-
Exports a Jupyter `NotebookNode` to a Python script using nbconvert’s `PythonExporter` with optional custom templates.
|
|
19
|
-
|
|
20
|
-
## Features
|
|
21
|
-
|
|
22
|
-
- Accepts a notebook object (`nbformat.NotebookNode`) and returns the rendered `.py` source.
|
|
23
|
-
- Supports passing an nbconvert template for custom formatting.
|
|
24
|
-
- Returns `{"exported_script": ...}` on success or `{"error": ...}` on failure.
|
|
25
|
-
|
|
26
|
-
## Prerequisites
|
|
27
|
-
|
|
28
|
-
- Python 3.10 or newer.
|
|
29
|
-
- nbconvert/nbformat installed (pulled automatically).
|
|
30
|
-
|
|
31
|
-
## Installation
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
# pip
|
|
35
|
-
pip install swarmauri_tool_jupyterexportpython
|
|
36
|
-
|
|
37
|
-
# poetry
|
|
38
|
-
poetry add swarmauri_tool_jupyterexportpython
|
|
39
|
-
|
|
40
|
-
# uv (pyproject-based projects)
|
|
41
|
-
uv add swarmauri_tool_jupyterexportpython
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Quickstart
|
|
45
|
-
|
|
46
|
-
```python
|
|
47
|
-
import nbformat
|
|
48
|
-
from swarmauri_tool_jupyterexportpython import JupyterExportPythonTool
|
|
49
|
-
|
|
50
|
-
notebook = nbformat.read("notebooks/example.ipynb", as_version=4)
|
|
51
|
-
exporter = JupyterExportPythonTool()
|
|
52
|
-
result = exporter(notebook, template_file=None)
|
|
53
|
-
|
|
54
|
-
if "exported_script" in result:
|
|
55
|
-
Path("notebooks/example.py").write_text(result["exported_script"], encoding="utf-8")
|
|
56
|
-
else:
|
|
57
|
-
print("Error:", result["error"])
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Tips
|
|
61
|
-
|
|
62
|
-
- Use custom templates to control cell separators or code comments—pass a `.tpl` file via `template_file`.
|
|
63
|
-
- Pair with notebook execution tools (execute → export to .py) to operationalize notebooks as Python scripts.
|
|
64
|
-
|
|
65
|
-
## Want to help?
|
|
66
|
-
|
|
67
|
-
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.
|
|
File without changes
|