Skip to main content

Turn Python execution into structured human-readable stories.

Project description

storytime

storytime turns Python execution into human-readable stories and can also execute a constrained narrative DSL.

Status

This is an early MVP. The current implementation focuses on:

  • @narrate for traced function execution
  • Story and Step models with plain, markdown, JSON, and ELI5 output
  • session() for lightweight interactive tracing
  • run_story() for a simple narrative DSL
  • describe() for semantic hook registration

Install

pip install .

For development:

python3 -m unittest discover -s tests

Quick Start

from storytime import narrate

@narrate(style="markdown")
def process(values):
    total = 0
    for value in values:
        total += value
    return total

story = process([1, 2, 3])
print(story.to_markdown())

DSL Example

from storytime import run_story

story = run_story(
    """
    Start with users
    Keep only active users
    Group by region
    Return the result
    """,
    context={
        "users": [
            {"name": "Ada", "active": True, "region": "US"},
            {"name": "Linus", "active": False, "region": "EU"},
        ]
    },
)

Examples

See examples/basic_usage.py.

Run it from the repository root with:

python3 examples/basic_usage.py

Publish

Manual PyPI publishing from your machine:

python3 -m pip install --upgrade build twine setuptools wheel
python3 -m build
python3 -m twine check dist/*
python3 -m twine upload dist/*

Before uploading:

  • make sure the package name is available on PyPI
  • run python3 -m unittest discover -s tests
  • review the generated files in dist/

Limitations

  • Tracing is heuristic and intentionally lightweight
  • The DSL is keyword-driven, not general natural language
  • Async behavior and deeper semantic analysis are not implemented yet

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tadalabz_storytime-1.0.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tadalabz_storytime-1.0.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file tadalabz_storytime-1.0.0.tar.gz.

File metadata

  • Download URL: tadalabz_storytime-1.0.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for tadalabz_storytime-1.0.0.tar.gz
Algorithm Hash digest
SHA256 10942e9a7add3f0bec28560a1d20f8f1a20539958bd7acb8f96e2e003c9374eb
MD5 f5fb10a83101d05d5141a2087faed0a6
BLAKE2b-256 c558ed3c084354c2332b945af572291643807c164932a20da126936e0ff980e7

See more details on using hashes here.

File details

Details for the file tadalabz_storytime-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tadalabz_storytime-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 352aad6a3c2073491f784548cb9e5ba9ff24579987d1e96c1500b7d4666da463
MD5 aee199f68f16cf886ab82941ba01318e
BLAKE2b-256 1cd71080e454041e49455b3fc9c685a62336672775e965d50a7cf62253397478

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