Skip to main content

A tool that converts a plain dictionary into a NotebookNode object using nbformat, facilitating programmatic notebook creation.

Project description

Swarmauri Logo

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


Swarmauri Tool Jupyter From Dict

Creates a validated Jupyter NotebookNode from a Python dictionary using nbformat.

Features

  • Validates notebook structure against nbformat schema.
  • Returns {"notebook_node": ...} on success or {"error": ...} when conversion fails.
  • Useful for programmatically building notebooks before executing/exporting them with other Swarmauri tools.

Prerequisites

  • Python 3.10 or newer.
  • nbformat installed (pulled automatically).

Installation

# pip
pip install swarmauri_tool_jupyterfromdict

# poetry
poetry add swarmauri_tool_jupyterfromdict

# uv (pyproject-based projects)
uv add swarmauri_tool_jupyterfromdict

Quickstart

import json
from swarmauri_tool_jupyterfromdict import JupyterFromDictTool

notebook_dict = {
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {},
    "cells": [
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": ["# Hello World\n", "This is a generated notebook."],
        }
    ],
}

result = JupyterFromDictTool()(notebook_dict)
if "notebook_node" in result:
    print("NotebookNode ready", type(result["notebook_node"]))
else:
    print("Error:", result["error"])

Tips

  • Feed the resulting NotebookNode directly into execution/export tools such as JupyterExecuteNotebookTool or nbconvert exporters.
  • Use json.dumps/json.loads if you need to persist or transmit the notebook dictionary before conversion.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

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.10.0.dev3.tar.gz (7.7 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.10.0.dev3.tar.gz.

File metadata

  • Download URL: swarmauri_tool_jupyterfromdict-0.10.0.dev3.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.10.0.dev3.tar.gz
Algorithm Hash digest
SHA256 8239717e1e6f682e0bb8216bf8125f8e71d1bedddacd5e6e72e508f36a07cab6
MD5 58d43434e97e2d2ca65c5aef3a7f48b0
BLAKE2b-256 6b26b692706c971f385daf00d1b546c891c74d216b67d644de0df6ab83ef79d7

See more details on using hashes here.

File details

Details for the file swarmauri_tool_jupyterfromdict-0.10.0.dev3-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_jupyterfromdict-0.10.0.dev3-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.10.0.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 a08feb2820f1a1b68947333b216abfae44e989c7240fb431646116795f8233e4
MD5 76ff5657ad21dd6643782ba6e85dc74c
BLAKE2b-256 d99588a3da905117497b1b12ad80bb9bf07b209d8b310d03f2591a095b829c61

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