swarmauri_tool_jupyterreadnotebook 0.9.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_jupyterreadnotebook-0.11.0.dev1/PKG-INFO +156 -0
- swarmauri_tool_jupyterreadnotebook-0.11.0.dev1/README.md +120 -0
- {swarmauri_tool_jupyterreadnotebook-0.9.1.dev3 → swarmauri_tool_jupyterreadnotebook-0.11.0.dev1}/pyproject.toml +17 -13
- {swarmauri_tool_jupyterreadnotebook-0.9.1.dev3 → swarmauri_tool_jupyterreadnotebook-0.11.0.dev1}/swarmauri_tool_jupyterreadnotebook/JupyterReadNotebookTool.py +36 -16
- swarmauri_tool_jupyterreadnotebook-0.9.1.dev3/PKG-INFO +0 -99
- swarmauri_tool_jupyterreadnotebook-0.9.1.dev3/README.md +0 -69
- {swarmauri_tool_jupyterreadnotebook-0.9.1.dev3 → swarmauri_tool_jupyterreadnotebook-0.11.0.dev1}/LICENSE +0 -0
- {swarmauri_tool_jupyterreadnotebook-0.9.1.dev3 → swarmauri_tool_jupyterreadnotebook-0.11.0.dev1}/swarmauri_tool_jupyterreadnotebook/__init__.py +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_tool_jupyterreadnotebook
|
|
3
|
+
Version: 0.11.0.dev1
|
|
4
|
+
Summary: Swarmauri notebook-ingestion tool for reading and validating Jupyter notebooks with nbformat.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: jupyter,nbformat,notebook,notebook validation,notebook ingestion,ipynb,notebooknode,schema validation,json notebook
|
|
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 :: File Formats :: JSON
|
|
20
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
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: nbformat (>=5.10.4)
|
|
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_jupyterreadnotebook/">
|
|
40
|
+
<img src="https://static.pepy.tech/badge/swarmauri_tool_jupyterreadnotebook/month" alt="PyPI - Downloads"/></a>
|
|
41
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterreadnotebook/">
|
|
42
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterreadnotebook.svg"/></a>
|
|
43
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterreadnotebook/">
|
|
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_jupyterreadnotebook/">
|
|
46
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterreadnotebook" alt="PyPI - License"/></a>
|
|
47
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterreadnotebook/">
|
|
48
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterreadnotebook?label=swarmauri_tool_jupyterreadnotebook&color=green" alt="PyPI - swarmauri_tool_jupyterreadnotebook"/></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 Read Notebook Tool
|
|
53
|
+
|
|
54
|
+
`swarmauri_tool_jupyterreadnotebook` reads a Jupyter `.ipynb` file from disk, parses it with `nbformat`, validates the notebook schema, and returns the resulting `NotebookNode` inside a Swarmauri tool response.
|
|
55
|
+
|
|
56
|
+
## Why
|
|
57
|
+
|
|
58
|
+
- Load notebooks into Swarmauri pipelines before execution, export, or cleanup steps.
|
|
59
|
+
- Normalize notebook ingestion around a simple tool contract.
|
|
60
|
+
- Catch missing files and notebook schema issues before later notebook-processing stages.
|
|
61
|
+
|
|
62
|
+
## Features
|
|
63
|
+
|
|
64
|
+
- Reads `.ipynb` files with `nbformat.read`.
|
|
65
|
+
- Validates the parsed notebook with `nbformat.validate`.
|
|
66
|
+
- Returns `{"notebook_node": ...}` on success.
|
|
67
|
+
- Returns `{"error": ...}` on file and validation failures.
|
|
68
|
+
- Supports an `as_version` argument for controlled notebook parsing.
|
|
69
|
+
|
|
70
|
+
## FAQ
|
|
71
|
+
|
|
72
|
+
### What does this tool return?
|
|
73
|
+
|
|
74
|
+
It returns a dictionary with either `notebook_node` containing the parsed notebook or `error` containing a failure message.
|
|
75
|
+
|
|
76
|
+
### Does this tool execute the notebook?
|
|
77
|
+
|
|
78
|
+
No. It only reads and validates notebook content. Pair it with execution tools when you need code-cell outputs.
|
|
79
|
+
|
|
80
|
+
### When should I change `as_version`?
|
|
81
|
+
|
|
82
|
+
Use `as_version` when you need to coerce notebook parsing to a specific `nbformat` version for compatibility with downstream tooling.
|
|
83
|
+
|
|
84
|
+
## Installation
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
uv add swarmauri_tool_jupyterreadnotebook
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install swarmauri_tool_jupyterreadnotebook
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Usage
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from swarmauri_tool_jupyterreadnotebook import JupyterReadNotebookTool
|
|
98
|
+
|
|
99
|
+
tool = JupyterReadNotebookTool()
|
|
100
|
+
result = tool(
|
|
101
|
+
notebook_file_path="notebooks/example.ipynb",
|
|
102
|
+
as_version=4,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
if "notebook_node" in result:
|
|
106
|
+
notebook = result["notebook_node"]
|
|
107
|
+
print(len(notebook.cells))
|
|
108
|
+
else:
|
|
109
|
+
print(result["error"])
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Examples
|
|
113
|
+
|
|
114
|
+
### Read a notebook before execution
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from swarmauri_tool_jupyterreadnotebook import JupyterReadNotebookTool
|
|
118
|
+
|
|
119
|
+
reader = JupyterReadNotebookTool()
|
|
120
|
+
payload = reader("reports/daily_report.ipynb")
|
|
121
|
+
|
|
122
|
+
if "notebook_node" in payload:
|
|
123
|
+
metadata = payload["notebook_node"].metadata
|
|
124
|
+
print(metadata)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Guard against invalid notebook files
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
response = JupyterReadNotebookTool()("broken.ipynb")
|
|
131
|
+
|
|
132
|
+
if "error" in response:
|
|
133
|
+
print("Notebook ingestion failed:", response["error"])
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Related Packages
|
|
137
|
+
|
|
138
|
+
- [`swarmauri_tool_jupyterwritenotebook`](https://pypi.org/project/swarmauri_tool_jupyterwritenotebook/)
|
|
139
|
+
- [`swarmauri_tool_jupyterexecutenotebook`](https://pypi.org/project/swarmauri_tool_jupyterexecutenotebook/)
|
|
140
|
+
- [`swarmauri_tool_jupyterexecutenotebookwithparameters`](https://pypi.org/project/swarmauri_tool_jupyterexecutenotebookwithparameters/)
|
|
141
|
+
- [`swarmauri_tool_jupyterexecuteandconvert`](https://pypi.org/project/swarmauri_tool_jupyterexecuteandconvert/)
|
|
142
|
+
- [`swarmauri_tool_jupyterclearoutput`](https://pypi.org/project/swarmauri_tool_jupyterclearoutput/)
|
|
143
|
+
|
|
144
|
+
## Foundational Swarmauri Packages
|
|
145
|
+
|
|
146
|
+
- [`swarmauri`](https://pypi.org/project/swarmauri/)
|
|
147
|
+
- [`swarmauri_core`](https://pypi.org/project/swarmauri_core/)
|
|
148
|
+
- [`swarmauri_base`](https://pypi.org/project/swarmauri_base/)
|
|
149
|
+
- [`swarmauri_standard`](https://pypi.org/project/swarmauri_standard/)
|
|
150
|
+
|
|
151
|
+
## More Documentation
|
|
152
|
+
|
|
153
|
+
- [Swarmauri SDK repository](https://github.com/swarmauri/swarmauri-sdk)
|
|
154
|
+
- [nbformat documentation](https://nbformat.readthedocs.io/)
|
|
155
|
+
- [Jupyter notebook format docs](https://jupyter.org/documentation)
|
|
156
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://pepy.tech/project/swarmauri_tool_jupyterreadnotebook/">
|
|
5
|
+
<img src="https://static.pepy.tech/badge/swarmauri_tool_jupyterreadnotebook/month" alt="PyPI - Downloads"/></a>
|
|
6
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterreadnotebook/">
|
|
7
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterreadnotebook.svg"/></a>
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterreadnotebook/">
|
|
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_jupyterreadnotebook/">
|
|
11
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterreadnotebook" alt="PyPI - License"/></a>
|
|
12
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterreadnotebook/">
|
|
13
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterreadnotebook?label=swarmauri_tool_jupyterreadnotebook&color=green" alt="PyPI - swarmauri_tool_jupyterreadnotebook"/></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 Read Notebook Tool
|
|
18
|
+
|
|
19
|
+
`swarmauri_tool_jupyterreadnotebook` reads a Jupyter `.ipynb` file from disk, parses it with `nbformat`, validates the notebook schema, and returns the resulting `NotebookNode` inside a Swarmauri tool response.
|
|
20
|
+
|
|
21
|
+
## Why
|
|
22
|
+
|
|
23
|
+
- Load notebooks into Swarmauri pipelines before execution, export, or cleanup steps.
|
|
24
|
+
- Normalize notebook ingestion around a simple tool contract.
|
|
25
|
+
- Catch missing files and notebook schema issues before later notebook-processing stages.
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- Reads `.ipynb` files with `nbformat.read`.
|
|
30
|
+
- Validates the parsed notebook with `nbformat.validate`.
|
|
31
|
+
- Returns `{"notebook_node": ...}` on success.
|
|
32
|
+
- Returns `{"error": ...}` on file and validation failures.
|
|
33
|
+
- Supports an `as_version` argument for controlled notebook parsing.
|
|
34
|
+
|
|
35
|
+
## FAQ
|
|
36
|
+
|
|
37
|
+
### What does this tool return?
|
|
38
|
+
|
|
39
|
+
It returns a dictionary with either `notebook_node` containing the parsed notebook or `error` containing a failure message.
|
|
40
|
+
|
|
41
|
+
### Does this tool execute the notebook?
|
|
42
|
+
|
|
43
|
+
No. It only reads and validates notebook content. Pair it with execution tools when you need code-cell outputs.
|
|
44
|
+
|
|
45
|
+
### When should I change `as_version`?
|
|
46
|
+
|
|
47
|
+
Use `as_version` when you need to coerce notebook parsing to a specific `nbformat` version for compatibility with downstream tooling.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv add swarmauri_tool_jupyterreadnotebook
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install swarmauri_tool_jupyterreadnotebook
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from swarmauri_tool_jupyterreadnotebook import JupyterReadNotebookTool
|
|
63
|
+
|
|
64
|
+
tool = JupyterReadNotebookTool()
|
|
65
|
+
result = tool(
|
|
66
|
+
notebook_file_path="notebooks/example.ipynb",
|
|
67
|
+
as_version=4,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
if "notebook_node" in result:
|
|
71
|
+
notebook = result["notebook_node"]
|
|
72
|
+
print(len(notebook.cells))
|
|
73
|
+
else:
|
|
74
|
+
print(result["error"])
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Examples
|
|
78
|
+
|
|
79
|
+
### Read a notebook before execution
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from swarmauri_tool_jupyterreadnotebook import JupyterReadNotebookTool
|
|
83
|
+
|
|
84
|
+
reader = JupyterReadNotebookTool()
|
|
85
|
+
payload = reader("reports/daily_report.ipynb")
|
|
86
|
+
|
|
87
|
+
if "notebook_node" in payload:
|
|
88
|
+
metadata = payload["notebook_node"].metadata
|
|
89
|
+
print(metadata)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Guard against invalid notebook files
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
response = JupyterReadNotebookTool()("broken.ipynb")
|
|
96
|
+
|
|
97
|
+
if "error" in response:
|
|
98
|
+
print("Notebook ingestion failed:", response["error"])
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Related Packages
|
|
102
|
+
|
|
103
|
+
- [`swarmauri_tool_jupyterwritenotebook`](https://pypi.org/project/swarmauri_tool_jupyterwritenotebook/)
|
|
104
|
+
- [`swarmauri_tool_jupyterexecutenotebook`](https://pypi.org/project/swarmauri_tool_jupyterexecutenotebook/)
|
|
105
|
+
- [`swarmauri_tool_jupyterexecutenotebookwithparameters`](https://pypi.org/project/swarmauri_tool_jupyterexecutenotebookwithparameters/)
|
|
106
|
+
- [`swarmauri_tool_jupyterexecuteandconvert`](https://pypi.org/project/swarmauri_tool_jupyterexecuteandconvert/)
|
|
107
|
+
- [`swarmauri_tool_jupyterclearoutput`](https://pypi.org/project/swarmauri_tool_jupyterclearoutput/)
|
|
108
|
+
|
|
109
|
+
## Foundational Swarmauri Packages
|
|
110
|
+
|
|
111
|
+
- [`swarmauri`](https://pypi.org/project/swarmauri/)
|
|
112
|
+
- [`swarmauri_core`](https://pypi.org/project/swarmauri_core/)
|
|
113
|
+
- [`swarmauri_base`](https://pypi.org/project/swarmauri_base/)
|
|
114
|
+
- [`swarmauri_standard`](https://pypi.org/project/swarmauri_standard/)
|
|
115
|
+
|
|
116
|
+
## More Documentation
|
|
117
|
+
|
|
118
|
+
- [Swarmauri SDK repository](https://github.com/swarmauri/swarmauri-sdk)
|
|
119
|
+
- [nbformat documentation](https://nbformat.readthedocs.io/)
|
|
120
|
+
- [Jupyter notebook format docs](https://jupyter.org/documentation)
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_tool_jupyterreadnotebook"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "
|
|
3
|
+
version = "0.11.0.dev1"
|
|
4
|
+
description = "Swarmauri notebook-ingestion tool for reading and validating Jupyter notebooks with nbformat."
|
|
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 :: File Formats :: JSON",
|
|
19
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
14
20
|
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
15
21
|
"Programming Language :: Python",
|
|
16
22
|
"Programming Language :: Python :: 3",
|
|
@@ -29,18 +35,15 @@ dependencies = [
|
|
|
29
35
|
"swarmauri_standard",
|
|
30
36
|
]
|
|
31
37
|
keywords = [
|
|
32
|
-
"swarmauri",
|
|
33
|
-
"tool",
|
|
34
|
-
"jupyterreadnotebook",
|
|
35
|
-
"reads",
|
|
36
38
|
"jupyter",
|
|
37
|
-
"notebook",
|
|
38
|
-
"file",
|
|
39
39
|
"nbformat",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
40
|
+
"notebook",
|
|
41
|
+
"notebook validation",
|
|
42
|
+
"notebook ingestion",
|
|
43
|
+
"ipynb",
|
|
42
44
|
"notebooknode",
|
|
43
|
-
"
|
|
45
|
+
"schema validation",
|
|
46
|
+
"json notebook",
|
|
44
47
|
]
|
|
45
48
|
|
|
46
49
|
[tool.uv.sources]
|
|
@@ -67,6 +70,7 @@ log_cli_level = "INFO"
|
|
|
67
70
|
log_cli_format = "%(asctime)s [%(levelname)s] %(message)s"
|
|
68
71
|
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
|
69
72
|
asyncio_default_fixture_loop_scope = "function"
|
|
73
|
+
addopts = "--pylicense-accept-deps=jsonschema,jsonschema-specifications,referencing,rpds-py"
|
|
70
74
|
|
|
71
75
|
[project.entry-points.'swarmauri.tools']
|
|
72
76
|
JupyterReadNotebookTool = "swarmauri_tool_jupyterreadnotebook:JupyterReadNotebookTool"
|
|
@@ -82,7 +86,7 @@ dev = [
|
|
|
82
86
|
"pytest-xdist>=3.6.1",
|
|
83
87
|
"pytest-json-report>=1.5.0",
|
|
84
88
|
"python-dotenv",
|
|
85
|
-
"
|
|
89
|
+
"httpx>=0.27",
|
|
86
90
|
"flake8>=7.0",
|
|
87
91
|
"pytest-timeout>=2.3.1",
|
|
88
92
|
"ruff>=0.9.9",
|
|
@@ -11,27 +11,36 @@ from swarmauri_base.ComponentBase import ComponentBase
|
|
|
11
11
|
"""
|
|
12
12
|
JupyterReadNotebookTool.py
|
|
13
13
|
|
|
14
|
-
This module defines the JupyterReadNotebookTool, a component that reads a
|
|
15
|
-
|
|
14
|
+
This module defines the JupyterReadNotebookTool, a component that reads a
|
|
15
|
+
Jupyter notebook file
|
|
16
|
+
from the filesystem, parses it into a NotebookNode object (using a specified
|
|
17
|
+
nbformat version),
|
|
16
18
|
|
|
17
|
-
validates its integrity, and returns the resulting node for further processing.
|
|
18
|
-
|
|
19
|
+
validates its integrity, and returns the resulting node for further processing.
|
|
20
|
+
This component
|
|
21
|
+
inherits from the ToolBase class to seamlessly integrate with the system's tool
|
|
22
|
+
architecture.
|
|
19
23
|
"""
|
|
20
24
|
|
|
21
25
|
|
|
22
26
|
@ComponentBase.register_type(ToolBase, "JupyterReadNotebookTool")
|
|
23
27
|
class JupyterReadNotebookTool(ToolBase):
|
|
24
28
|
"""
|
|
25
|
-
JupyterReadNotebookTool is a tool that reads a Jupyter notebook file from
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
JupyterReadNotebookTool is a tool that reads a Jupyter notebook file from
|
|
30
|
+
the filesystem
|
|
31
|
+
and returns a validated NotebookNode object. It supports specifying an
|
|
32
|
+
nbformat version
|
|
33
|
+
for parsing the file, logs the read operation, and handles both file and
|
|
34
|
+
validation errors.
|
|
28
35
|
|
|
29
36
|
Attributes:
|
|
30
37
|
version (str): The version of the JupyterReadNotebookTool.
|
|
31
|
-
parameters (List[Parameter]): A list of parameters required to read the
|
|
38
|
+
parameters (List[Parameter]): A list of parameters required to read the
|
|
39
|
+
notebook file.
|
|
32
40
|
name (str): The name of the tool.
|
|
33
41
|
description (str): A brief description of the tool's functionality.
|
|
34
|
-
type (Literal["JupyterReadNotebookTool"]): The type identifier for the
|
|
42
|
+
type (Literal["JupyterReadNotebookTool"]): The type identifier for the
|
|
43
|
+
tool.
|
|
35
44
|
"""
|
|
36
45
|
|
|
37
46
|
version: str = "1.0.0"
|
|
@@ -46,7 +55,9 @@ class JupyterReadNotebookTool(ToolBase):
|
|
|
46
55
|
Parameter(
|
|
47
56
|
name="as_version",
|
|
48
57
|
input_type="integer",
|
|
49
|
-
description=
|
|
58
|
+
description=(
|
|
59
|
+
"nbformat version to parse the notebook with (e.g., 4)."
|
|
60
|
+
),
|
|
50
61
|
required=False,
|
|
51
62
|
),
|
|
52
63
|
]
|
|
@@ -58,22 +69,31 @@ class JupyterReadNotebookTool(ToolBase):
|
|
|
58
69
|
)
|
|
59
70
|
type: Literal["JupyterReadNotebookTool"] = "JupyterReadNotebookTool"
|
|
60
71
|
|
|
61
|
-
def __call__(
|
|
72
|
+
def __call__(
|
|
73
|
+
self, notebook_file_path: str, as_version: int = 4
|
|
74
|
+
) -> Dict[str, Any]:
|
|
62
75
|
"""
|
|
63
|
-
Reads a Jupyter notebook from the filesystem and returns it as a
|
|
76
|
+
Reads a Jupyter notebook from the filesystem and returns it as a
|
|
77
|
+
validated NotebookNode.
|
|
64
78
|
|
|
65
79
|
Args:
|
|
66
80
|
notebook_file_path (str): The file path to the Jupyter notebook.
|
|
67
|
-
as_version (int, optional): The nbformat version to parse the file
|
|
81
|
+
as_version (int, optional): The nbformat version to parse the file
|
|
82
|
+
as. Defaults to 4.
|
|
68
83
|
|
|
69
84
|
Returns:
|
|
70
|
-
Dict[str, Any]: A dictionary containing either the NotebookNode
|
|
71
|
-
|
|
85
|
+
Dict[str, Any]: A dictionary containing either the NotebookNode
|
|
86
|
+
object under the
|
|
87
|
+
"notebook_node" key or an "error" key with a
|
|
88
|
+
message if an error
|
|
72
89
|
occurred.
|
|
73
90
|
"""
|
|
74
91
|
logger = logging.getLogger(__name__)
|
|
75
92
|
logger.info(
|
|
76
|
-
|
|
93
|
+
(
|
|
94
|
+
"Attempting to read Jupyter notebook from '%s' with nbformat "
|
|
95
|
+
"version '%d'."
|
|
96
|
+
),
|
|
77
97
|
notebook_file_path,
|
|
78
98
|
as_version,
|
|
79
99
|
)
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: swarmauri_tool_jupyterreadnotebook
|
|
3
|
-
Version: 0.9.1.dev3
|
|
4
|
-
Summary: A tool that reads a Jupyter Notebook file using nbformat, converting the JSON file into a NotebookNode object.
|
|
5
|
-
License-Expression: Apache-2.0
|
|
6
|
-
License-File: LICENSE
|
|
7
|
-
Keywords: swarmauri,tool,jupyterreadnotebook,reads,jupyter,notebook,file,nbformat,converting,json,notebooknode,object
|
|
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: nbformat (>=5.10.4)
|
|
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_jupyterreadnotebook/">
|
|
34
|
-
<img src="https://static.pepy.tech/badge/swarmauri_tool_jupyterreadnotebook/month" alt="PyPI - Downloads"/></a>
|
|
35
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterreadnotebook/">
|
|
36
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterreadnotebook.svg"/></a>
|
|
37
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterreadnotebook/">
|
|
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_jupyterreadnotebook/">
|
|
40
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterreadnotebook" alt="PyPI - License"/></a>
|
|
41
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterreadnotebook/">
|
|
42
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterreadnotebook?label=swarmauri_tool_jupyterreadnotebook&color=green" alt="PyPI - swarmauri_tool_jupyterreadnotebook"/></a>
|
|
43
|
-
</p>
|
|
44
|
-
|
|
45
|
-
# Swarmauri Tool Jupyter Read Notebook
|
|
46
|
-
|
|
47
|
-
Reads a `.ipynb` file from disk into a validated nbformat `NotebookNode` for downstream processing.
|
|
48
|
-
|
|
49
|
-
## Features
|
|
50
|
-
|
|
51
|
-
- Wraps nbformat’s `read` + validation workflow in a Swarmauri tool.
|
|
52
|
-
- Returns `{ "notebook_node": NotebookNode }` on success or `{ "error": ... }` on failure.
|
|
53
|
-
- Optional `as_version` argument controls notebook parsing version (default 4).
|
|
54
|
-
|
|
55
|
-
## Prerequisites
|
|
56
|
-
|
|
57
|
-
- Python 3.10 or newer.
|
|
58
|
-
- nbformat installed (pulled automatically).
|
|
59
|
-
|
|
60
|
-
## Installation
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
# pip
|
|
64
|
-
pip install swarmauri_tool_jupyterreadnotebook
|
|
65
|
-
|
|
66
|
-
# poetry
|
|
67
|
-
poetry add swarmauri_tool_jupyterreadnotebook
|
|
68
|
-
|
|
69
|
-
# uv (pyproject-based projects)
|
|
70
|
-
uv add swarmauri_tool_jupyterreadnotebook
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Quickstart
|
|
74
|
-
|
|
75
|
-
```python
|
|
76
|
-
from swarmauri_tool_jupyterreadnotebook import JupyterReadNotebookTool
|
|
77
|
-
|
|
78
|
-
reader = JupyterReadNotebookTool()
|
|
79
|
-
response = reader(
|
|
80
|
-
notebook_file_path="notebooks/example.ipynb",
|
|
81
|
-
as_version=4,
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
if "notebook_node" in response:
|
|
85
|
-
nb = response["notebook_node"]
|
|
86
|
-
print("Cells:", len(nb.cells))
|
|
87
|
-
else:
|
|
88
|
-
print("Error:", response["error"])
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Tips
|
|
92
|
-
|
|
93
|
-
- Use with execution/export tools to build pipelines (read → execute → convert).
|
|
94
|
-
- Handle `error` key gracefully when files are missing or malformed.
|
|
95
|
-
|
|
96
|
-
## Want to help?
|
|
97
|
-
|
|
98
|
-
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.
|
|
99
|
-
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<a href="https://pepy.tech/project/swarmauri_tool_jupyterreadnotebook/">
|
|
5
|
-
<img src="https://static.pepy.tech/badge/swarmauri_tool_jupyterreadnotebook/month" alt="PyPI - Downloads"/></a>
|
|
6
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterreadnotebook/">
|
|
7
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterreadnotebook.svg"/></a>
|
|
8
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterreadnotebook/">
|
|
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_jupyterreadnotebook/">
|
|
11
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterreadnotebook" alt="PyPI - License"/></a>
|
|
12
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterreadnotebook/">
|
|
13
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterreadnotebook?label=swarmauri_tool_jupyterreadnotebook&color=green" alt="PyPI - swarmauri_tool_jupyterreadnotebook"/></a>
|
|
14
|
-
</p>
|
|
15
|
-
|
|
16
|
-
# Swarmauri Tool Jupyter Read Notebook
|
|
17
|
-
|
|
18
|
-
Reads a `.ipynb` file from disk into a validated nbformat `NotebookNode` for downstream processing.
|
|
19
|
-
|
|
20
|
-
## Features
|
|
21
|
-
|
|
22
|
-
- Wraps nbformat’s `read` + validation workflow in a Swarmauri tool.
|
|
23
|
-
- Returns `{ "notebook_node": NotebookNode }` on success or `{ "error": ... }` on failure.
|
|
24
|
-
- Optional `as_version` argument controls notebook parsing version (default 4).
|
|
25
|
-
|
|
26
|
-
## Prerequisites
|
|
27
|
-
|
|
28
|
-
- Python 3.10 or newer.
|
|
29
|
-
- nbformat installed (pulled automatically).
|
|
30
|
-
|
|
31
|
-
## Installation
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
# pip
|
|
35
|
-
pip install swarmauri_tool_jupyterreadnotebook
|
|
36
|
-
|
|
37
|
-
# poetry
|
|
38
|
-
poetry add swarmauri_tool_jupyterreadnotebook
|
|
39
|
-
|
|
40
|
-
# uv (pyproject-based projects)
|
|
41
|
-
uv add swarmauri_tool_jupyterreadnotebook
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Quickstart
|
|
45
|
-
|
|
46
|
-
```python
|
|
47
|
-
from swarmauri_tool_jupyterreadnotebook import JupyterReadNotebookTool
|
|
48
|
-
|
|
49
|
-
reader = JupyterReadNotebookTool()
|
|
50
|
-
response = reader(
|
|
51
|
-
notebook_file_path="notebooks/example.ipynb",
|
|
52
|
-
as_version=4,
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
if "notebook_node" in response:
|
|
56
|
-
nb = response["notebook_node"]
|
|
57
|
-
print("Cells:", len(nb.cells))
|
|
58
|
-
else:
|
|
59
|
-
print("Error:", response["error"])
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Tips
|
|
63
|
-
|
|
64
|
-
- Use with execution/export tools to build pipelines (read → execute → convert).
|
|
65
|
-
- Handle `error` key gracefully when files are missing or malformed.
|
|
66
|
-
|
|
67
|
-
## Want to help?
|
|
68
|
-
|
|
69
|
-
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
|