Skip to main content

Explicit function registry with JSON schema generation

Project description

wt-registry

codecov

Explicit function registry with JSON schema generation for Python.

Overview

wt-registry provides a simple, explicit decorator-based approach to registering functions with rich metadata and automatic JSON schema generation using Pydantic.

Features

  • Explicit Registration: Use @register decorator with metadata (title, description, tags)
  • Type Safety: Requires complete type annotations for all registered functions
  • JSON Schema Generation: Automatically generates JSON schemas using Pydantic TypeAdapter
  • Minimal Dependencies: Only requires Python 3.10+ and Pydantic
  • CLI Tool: Export registry contents as JSON via command-line interface
  • Fully Serializable: Registry stores metadata and schemas, not function objects

Quick Start with Examples

The fastest way to see wt-registry in action:

# Clone the repository
git clone https://github.com/USERNAME/wt-registry.git
cd wt-registry

# One-time setup
uv sync

# Run an example
uv run python examples/basic_registration.py

See examples/README.md for more examples demonstrating:

  • Basic function registration
  • JSON and pretty output formats
  • Function filtering
  • Deprecated function handling
  • Multi-module scenarios

Installation

uv pip install wt-registry

Quick Start

from wt_registry import register, get_registry

@register(
    title="Calculate Statistics",
    description="Calculate mean, median, and stdev of numeric values",
    tags=["statistics", "analysis"]
)
def calculate_statistics(
    values: list[float],
    precision: int = 2
) -> dict[str, float]:
    import statistics
    return {
        "mean": round(statistics.mean(values), precision),
        "median": round(statistics.median(values), precision),
        "stdev": round(statistics.stdev(values), precision) if len(values) > 1 else 0.0,
    }

# Access the registry
registry = get_registry()
for fqn, entry in registry.items():
    print(f"{entry.metadata.title}: {fqn}")
    print(f"  Schema: {entry.json_schema}")

CLI Usage

Export the entire registry as JSON:

wt-registry > registry.json

Filter by tags:

wt-registry --filter-tag statistics --format pretty

Filter by module:

wt-registry --module "myapp.tasks.*"

Requirements

  • Python 3.10+
  • Pydantic 2.0+

Development

Install development dependencies:

# IMPORTANT: Use --group dev (not --extra dev) with dependency-groups
uv sync --group dev

Note: This project uses [dependency-groups] instead of [project.optional-dependencies]. You must use --group dev to install dev dependencies (pytest, mypy, ruff, etc.). Running uv sync alone will not install dev dependencies.

Set up pre-commit hooks (automatically runs ruff linting and formatting on every commit):

uv run pre-commit install

Run tests:

uv run pytest

Run type checking:

uv run mypy src/wt_registry

License

BSD-3-Clause

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

wt_registry-0.1.0.tar.gz (86.9 kB view details)

Uploaded Source

Built Distribution

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

wt_registry-0.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file wt_registry-0.1.0.tar.gz.

File metadata

  • Download URL: wt_registry-0.1.0.tar.gz
  • Upload date:
  • Size: 86.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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 wt_registry-0.1.0.tar.gz
Algorithm Hash digest
SHA256 80cf524ea5b858c558f49dd394fc0651e86f740c319dd5216a6a6d70a3c6e3d6
MD5 7abae9c846091f9b9b41a516f59eff26
BLAKE2b-256 993c5c84df65704475db2717b6005ba75186d4edc48761ed07925232cb85667a

See more details on using hashes here.

File details

Details for the file wt_registry-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wt_registry-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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 wt_registry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4a84a9156c81c015f7404d56a4c5d078de2f74ab286837cd6646b6cba385bca
MD5 bc456a97a1702fb7518789150a908da1
BLAKE2b-256 fa2085485903f2769cfecf5c021482e502801540560dc3880fc0bd2dc5535b6f

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