Skip to main content

The shared contract surface for the lens analyser family — manifest builder + FastAPI/CLI scaffolding every member exposes.

Project description

lens-contract

The shared contract surface for the lens analyser family. Every Python member exposes the same manifest, the same GET /health + GET /manifest routes, and the same serve / manifest CLI subcommands. This package is that common surface, so a contract change is one release here instead of an edit in every analyser.

It is infrastructure, not an analyser (role: library): it does not appear in the family table and is not auto-routable.

What it provides

Helper Replaces the per-repo…
make_manifest(...) _version() try/except + MANIFEST dict in manifest.py
add_contract_routes(app, MANIFEST) hand-written GET /health + GET /manifest
make_app(MANIFEST, analyse) the whole api.py for the path-only common case
upload_tempfile(content, filename) the POST /analyse upload→tempfile→cleanup dance
run_contract_subcommands(...) the serve + manifest dispatch in cli.py

What it deliberately does not provide

Per the family principle share the contract, not forced abstraction: the analyse() business logic, the human-readable CLI output (rich), and the rich analyse-CLI flags stay in each repo. rich is not even a dependency here.

Usage

# manifest.py
from lens_contract import make_manifest
MANIFEST = make_manifest(
    name="name-analyser", accepts=["..."], produces="NameAnalysis",
    extensions=[".ext"], auto_routable=True,
)

# api.py — common case
from lens_contract import make_app
from name_analyser import NameAnalyser
app = make_app(MANIFEST, lambda path: NameAnalyser().analyse(path))

# cli.py
from lens_contract import run_contract_subcommands
def main():
    if run_contract_subcommands(MANIFEST, app_path="name_analyser.api:app",
                                default_port=8010, env_prefix="NAME_ANALYSER"):
        return
    ...  # bespoke analyse argparse + human output

Members needing extra /analyse form fields (e.g. --llm) build their own app with add_contract_routes + upload_tempfile — see conversation-analyser as the reference adopter.

Develop

uv venv && uv pip install -e '.[dev]'
uv run pytest

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

lens_contract-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

lens_contract-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lens_contract-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for lens_contract-0.1.0.tar.gz
Algorithm Hash digest
SHA256 912d4ff165a262d876c24d2a412683fb4890213c2d72a32a3b24789a7665c536
MD5 149237341180e01bfe527fb9eccb1460
BLAKE2b-256 96d5fb857a762c774c70187952c9f44afa363b441cbcfe019ade6a0c5311e81b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lens_contract-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for lens_contract-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f08cbace65efa3ba9d9e11c764fdae356bc6769999bba2c23c2315b64418dcc
MD5 ae0a9c509e7ed908141b89f284c6a507
BLAKE2b-256 8419288d83cd4d3489c2196802dcfe6a3b9cd93f3be97e3bd0e23083c400d15f

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