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.2.2.tar.gz (102.0 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.2.2-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wt_registry-0.2.2.tar.gz
  • Upload date:
  • Size: 102.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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.2.2.tar.gz
Algorithm Hash digest
SHA256 24be6288e8a938691da3a9e14ac5b50112b30c49cec6da01309a255a1611de18
MD5 99818ce627b61e68dbf0fd6b217411c2
BLAKE2b-256 1abdc9254c369031708805c95f7dc53ed856581d73198a03b1b73c48a9e6f32a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wt_registry-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea426851f799aac4f5a9a83f23b1803a6848908ce9ae1705b71a075a6e9e2344
MD5 df3c12264477741d47a8a512b63116c0
BLAKE2b-256 806102285d5eb1ac70f5c77b6632a0dc85cb9cd1bf90f1073515420e498f4ac1

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