Skip to main content

A tool designed to execute all cells in a Jupyter Notebook using nbconvert’s ExecutePreprocessor, capturing outputs for testing and reporting.

Project description

Swarmauri Logo

PyPI - Downloads GitHub Hits PyPI - Python Version PyPI - License
PyPI - swarmauri_tool_jupyterexecutenotebook


swarmauri_tool_jupyterexecutenotebook

The swarmauri_tool_jupyterexecutenotebook package provides a tool for executing all cells in a Jupyter notebook in sequence, capturing outputs and returning the fully updated NotebookNode object. It leverages the Swarmauri framework's base and core components.

Installation

To install swarmauri_tool_jupyterexecutenotebook, make sure you have Python 3.10 or later:

  1. Using pip: • (Recommended) Create and activate a virtual environment.
    • Run:
    pip install swarmauri_tool_jupyterexecutenotebook

  2. Using Poetry in an existing project: • poetry add swarmauri_tool_jupyterexecutenotebook

This will automatically install all dependencies required to run the JupyterExecuteNotebookTool.

Usage

The principal component of this package is the JupyterExecuteNotebookTool, which executes a given notebook, capturing cell outputs and errors. Below is a quick reference for using the tool programmatically in your Python code.

Example usage:


from swarmauri_tool_jupyterexecutenotebook import JupyterExecuteNotebookTool

def execute_my_notebook(): """ Demonstrates how to instantiate and use the JupyterExecuteNotebookTool to execute a Jupyter notebook file. This includes capturing outputs and error messages. """ # Create an instance of the tool tool = JupyterExecuteNotebookTool()

# Execute the Jupyter notebook; specify the path to your notebook
executed_notebook = tool(
    notebook_path="my_notebook.ipynb",
    timeout=60  # Optional: defaults to 30 if not provided
)

# The returned `executed_notebook` is a NotebookNode with outputs captured
return executed_notebook

if name == "main": result_notebook = execute_my_notebook() # You can further analyze 'result_notebook' outputs here

In this example: • The notebook_path parameter is a required string referencing the target notebook file.
• The optional timeout parameter defines how long each cell can take to run before throwing an error (default is 30 seconds).

The executed NotebookNode object will contain both new outputs and any error messages generated during execution.

Dependencies

This package relies on: • swarmauri_core for base components.
• swarmauri_base for the ToolBase class.
• nbconvert, nbformat, and nbclient for handling and executing Jupyter notebooks.

When you install swarmauri_tool_jupyterexecutenotebook via pip or Poetry, these dependencies are automatically handled for you. Refer to the project's pyproject.toml for the full list of dependencies and version requirements.


This README is provided as part of the swarmauri_tool_jupyterexecutenotebook package. If you have any questions or issues, please consult our documentation or open a support request. Thank you for using Swarmauri!

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_jupyterexecutenotebook-0.7.0.dev8.tar.gz.

File metadata

File hashes

Hashes for swarmauri_tool_jupyterexecutenotebook-0.7.0.dev8.tar.gz
Algorithm Hash digest
SHA256 70936cbfab29d7bb0b2a5336121a612be505ce8b6cacdc3c0a85509739be9f20
MD5 dc53bc3b4a5d3b23f5f0e6f033a4dd20
BLAKE2b-256 c1d0eade6735b8f72d9f1b54bb656a4af92a7d2e64f1f9bea6b7c63571a7a4cd

See more details on using hashes here.

File details

Details for the file swarmauri_tool_jupyterexecutenotebook-0.7.0.dev8-py3-none-any.whl.

File metadata

File hashes

Hashes for swarmauri_tool_jupyterexecutenotebook-0.7.0.dev8-py3-none-any.whl
Algorithm Hash digest
SHA256 bcb53c111cb019b76edfbb9e9815424344aff78691696d3c20cfc76ef06300bd
MD5 e1456e8dc383d787b4396f3c9cd98fea
BLAKE2b-256 351136c5f58b1d8fa4643c139acbe18def4e5747252eabaae3c362355428b7c7

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