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
- Create an API token at pypi.org/manage/account/token
- Add
PYPI_API_TOKENas a repository secret in GitHub - Create a release or run the workflow manually — the publish workflow runs on release publish and
workflow_dispatch
License
MIT
Project details
Release history Release notifications | RSS feed
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a11394d0162722a25e093302394faf4ad58974428de7bb43ac959708047e9179
|
|
| MD5 |
56a33c1dfd4a4863e0a1692e9d0b0b30
|
|
| BLAKE2b-256 |
f11cc30d3b41558019a97427d61443662c977d02082df10a739f66ab2c7bb352
|
Provenance
The following attestation bundles were made for mocra-0.1.0.tar.gz:
Publisher:
publish.yml on Mocra-AI/Mocra-Py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mocra-0.1.0.tar.gz -
Subject digest:
a11394d0162722a25e093302394faf4ad58974428de7bb43ac959708047e9179 - Sigstore transparency entry: 976087686
- Sigstore integration time:
-
Permalink:
Mocra-AI/Mocra-Py@93639fcb722f2704f0c802605376528e2fdf84fb -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Mocra-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@93639fcb722f2704f0c802605376528e2fdf84fb -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6e58864a4b1bf6b44e99f9794435ec12b207771389af038d73967ffbcdf26c4
|
|
| MD5 |
363735bc752bfa0b1e464585c645a7b8
|
|
| BLAKE2b-256 |
cb050d4e3991dd8defd28e16a9a7f8d0b68f28a451ea580e016a0c3a01875972
|
Provenance
The following attestation bundles were made for mocra-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Mocra-AI/Mocra-Py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mocra-0.1.0-py3-none-any.whl -
Subject digest:
b6e58864a4b1bf6b44e99f9794435ec12b207771389af038d73967ffbcdf26c4 - Sigstore transparency entry: 976087692
- Sigstore integration time:
-
Permalink:
Mocra-AI/Mocra-Py@93639fcb722f2704f0c802605376528e2fdf84fb -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Mocra-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@93639fcb722f2704f0c802605376528e2fdf84fb -
Trigger Event:
workflow_dispatch
-
Statement type: