Skip to main content

Python SDK for Mocra's Observe API - observability for video generation workflows

Project description

Mocra Python SDK

Python SDK for Mocra's Observe API — observability for video generation workflows. The API mirrors the TypeScript SDK so you can switch between languages easily.

Installation

pip install -e .

Requirements

Quick Start

from mocra import VideoObservabilityApi, ExtraCriterion

api = VideoObservabilityApi("YOUR_API_KEY")
result = api.score_video(
    "https://example.org/video.mp4",
    extra_criteria=[
        ExtraCriterion(
            criterion_name="Blur",
            criterion_description="The video should not be blurry",
        ),
    ],
    ignore_criteria=["UNNATURAL PHYSICS"],
)

print(f"Overall score: {result.severity}")
for criterion in result.criteria:
    print(f"  {criterion.name}: {criterion.score}")

API Mapping (TypeScript ↔ Python)

TypeScript Python
VideoObservabilityApi VideoObservabilityApi
scoreVideo(videoUrl, extraCriteria?, ignoreCriteria?) score_video(video_url, extra_criteria?, ignore_criteria?)
ExtraCriterion { criterionName, criterionDescription } ExtraCriterion(criterion_name=..., criterion_description=...)
ignoreCriteria: ["UNNATURAL PHYSICS", ...] ignore_criteria=["UNNATURAL PHYSICS"] or [DefaultCriterion.UNNATURAL_PHYSICS]
ScoreMap { severity, criteria } ObserveResponse

Default criteria (for ignore_criteria): UNNATURAL PHYSICS, MORPHING, FLICKERING, ARTIFACTING, TEXT ISSUES

API Reference

VideoObservabilityApi

Parameter Type Description
api_key str Your Mocra API key (get one)
base_url str Override API URL (default: https://api.mocra.io)
timeout float Request timeout in seconds
http_client httpx.Client Optional pre-configured client

score_video()

Parameter Type Description
video_url str URL of the video to analyze
extra_criteria list[ExtraCriterion] Extra criteria (default: [])
ignore_criteria list[str | DefaultCriterion] Default criteria to exclude (default: [])

Returns: { severity, criteria: [{ name, score }] } (1–100 scale)

Context Manager

with VideoObservabilityApi("YOUR_API_KEY") as api:
    result = api.score_video("https://example.org/video.mp4")

Development

Setup

pip install -e ".[dev]"
pre-commit install  # Run lint on git commit

Lint

ruff check mocra tests

Test

pytest tests/ -v

Publishing to PyPI

  1. Create an API token at pypi.org/manage/account/token
  2. Add PYPI_API_TOKEN as a repository secret in GitHub
  3. Create a release or run the workflow manually — the publish workflow runs on release publish and workflow_dispatch

License

MIT

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

mocra-0.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

mocra-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mocra-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mocra-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a11394d0162722a25e093302394faf4ad58974428de7bb43ac959708047e9179
MD5 56a33c1dfd4a4863e0a1692e9d0b0b30
BLAKE2b-256 f11cc30d3b41558019a97427d61443662c977d02082df10a739f66ab2c7bb352

See more details on using hashes here.

Provenance

The following attestation bundles were made for mocra-0.1.0.tar.gz:

Publisher: publish.yml on Mocra-AI/Mocra-Py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: mocra-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mocra-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6e58864a4b1bf6b44e99f9794435ec12b207771389af038d73967ffbcdf26c4
MD5 363735bc752bfa0b1e464585c645a7b8
BLAKE2b-256 cb050d4e3991dd8defd28e16a9a7f8d0b68f28a451ea580e016a0c3a01875972

See more details on using hashes here.

Provenance

The following attestation bundles were made for mocra-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Mocra-AI/Mocra-Py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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