Skip to main content

Swarmauri notebook-construction tool for converting Python dictionaries into validated Jupyter NotebookNode objects.

Project description

Swarmauri Logo

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

Swarmauri Jupyter From Dict Tool

swarmauri_tool_jupyterfromdict converts a plain Python dictionary into a validated NotebookNode with nbformat, making it useful for programmatic notebook construction inside Swarmauri workflows.

Why

  • Build notebook objects from generated or transformed Python data.
  • Normalize notebook creation behind a simple tool contract.
  • Validate notebook structure at the point of conversion instead of later in the pipeline.

Features

  • Accepts a plain dictionary representing notebook structure.
  • Converts the dictionary with nbformat.from_dict.
  • Validates the resulting notebook object with nbformat.validate.
  • Returns notebook_node on success.
  • Returns a structured error payload when conversion or validation fails.

FAQ

What input does this tool expect?

It expects a Python dictionary that follows notebook structure conventions such as nbformat, nbformat_minor, cells, and metadata.

Does it return JSON?

No. It returns a NotebookNode object in notebook_node.

When should I use this instead of swarmauri_tool_jupyterreadnotebook?

Use this package when your notebook starts as in-memory Python data. Use swarmauri_tool_jupyterreadnotebook when the notebook already exists on disk.

Installation

uv add swarmauri_tool_jupyterfromdict
pip install swarmauri_tool_jupyterfromdict

Usage

from swarmauri_tool_jupyterfromdict import JupyterFromDictTool

payload = {
    "nbformat": 4,
    "nbformat_minor": 5,
    "cells": [],
    "metadata": {},
}

result = JupyterFromDictTool()(notebook_dict=payload)
print(result)

Examples

Create a notebook node from generated data

result = JupyterFromDictTool()(
    notebook_dict={
        "nbformat": 4,
        "nbformat_minor": 5,
        "cells": [
            {
                "cell_type": "markdown",
                "metadata": {},
                "source": ["# Generated notebook"],
            }
        ],
        "metadata": {},
    }
)

node = result["notebook_node"]

Detect invalid notebook structure

result = JupyterFromDictTool()(
    notebook_dict={"cells": [], "metadata": {}}
)

if "error" in result:
    print(result["error"])

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

swarmauri_tool_jupyterfromdict-0.11.0.dev1.tar.gz (8.3 kB view details)

Uploaded Source

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_jupyterfromdict-0.11.0.dev1.tar.gz.

File metadata

  • Download URL: swarmauri_tool_jupyterfromdict-0.11.0.dev1.tar.gz
  • Upload date:
  • Size: 8.3 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_jupyterfromdict-0.11.0.dev1.tar.gz
Algorithm Hash digest
SHA256 b809a3b7cbb8525f998a507dd722c6c997920ef7cd6c3b16fe79091269ed0847
MD5 e4f33b41b4eec3aea5b608f733425546
BLAKE2b-256 84093f514e24c0f6c67177f6512a99f4bda80189353519c9d41aeb4be6f1673a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_tool_jupyterfromdict-0.11.0.dev1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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_jupyterfromdict-0.11.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9ea9e6b30ef56d06208c9311bf198e364a9934c2bae08835d6197ce7e51246f
MD5 229a1ace55c0c34cf52676bf024def9c
BLAKE2b-256 bcab3be5f8d51de502da8afd250a5cf9c0a34bf6a84a55155715e83a2fd5fef2

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