Explicit function registry with JSON schema generation
Project description
wt-registry
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
@registerdecorator 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wt_registry-0.2.1.tar.gz.
File metadata
- Download URL: wt_registry-0.2.1.tar.gz
- Upload date:
- Size: 88.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7c3b1ed6e3dd560343f1ed6371185346df3c92274ffe70981ab497c5188335d
|
|
| MD5 |
d524f66966af715de355fe47111ce477
|
|
| BLAKE2b-256 |
de0691d4e7931fb33c4d467ca2f5ac52ed23fa293c45919797f277d62bf8e0db
|
File details
Details for the file wt_registry-0.2.1-py3-none-any.whl.
File metadata
- Download URL: wt_registry-0.2.1-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3fa0e15ff5946ae3b2ec5e3261bcc294ee2ac89bea70f04afd8bd9b35318599
|
|
| MD5 |
0e38e6f4c88b7a117ce9a0938725e04d
|
|
| BLAKE2b-256 |
4f1b9a62da16ad4a75a454e3d5de37e4339a01c7ab696c28b93d4897bc0b5b94
|