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.0.dev6.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.0.dev6.tar.gz.

File metadata

  • Download URL: swarmauri_tool_jupyterfromdict-0.9.0.dev6.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","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.0.dev6.tar.gz
Algorithm Hash digest
SHA256 89b29a7916e418d69764f9e17996e19debd6530c091797716ad7ddee3f5a4b77
MD5 bc18f8262485245b0713819b5da17003
BLAKE2b-256 506a3107edebc510d10369c204d867f6eb5fee1d7f961515e3d884f9a11323ae

See more details on using hashes here.

File details

Details for the file swarmauri_tool_jupyterfromdict-0.9.0.dev6-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_jupyterfromdict-0.9.0.dev6-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","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.0.dev6-py3-none-any.whl
Algorithm Hash digest
SHA256 2eb7a73b0aa9357e8a96aeee23c4af471bf9c1da16fa0180d0332359bac7f4af
MD5 ec0cf7aa9f773189a1dfeee293060071
BLAKE2b-256 e1c71a01a9fddde7b33f1983b175da54af1b48a5524f95ce4f69a7f2ec71e903

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