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

File metadata

  • Download URL: swarmauri_tool_jupyterfromdict-0.9.2.dev8.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.9.2.dev8.tar.gz
Algorithm Hash digest
SHA256 1cb84695a666b942e1e60f0c089770c3293ffeff80cae3ddbb41cd88728bc7e3
MD5 f2e7e13288c95d6f952db14ef86137a1
BLAKE2b-256 e29c233040d9e536bed09a40d4e5754119cd4dc426f98aa0b88fd1478cd03faf

See more details on using hashes here.

File details

Details for the file swarmauri_tool_jupyterfromdict-0.9.2.dev8-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_jupyterfromdict-0.9.2.dev8-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.9.2.dev8-py3-none-any.whl
Algorithm Hash digest
SHA256 8341285ff2fe9c6edebb271201a2a1fffddde3cd4ed6f8d6000fa255af64c4a5
MD5 1ef6846ca24ecbdcd223070fa3b05da5
BLAKE2b-256 94fc5c94cc5c0b5bb5c08374a5515248384cc70896d288b1972a87a984306e21

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