Claude 5e2094f2ad
feat(media): local inference sidecar for Media Studio
FastAPI service in infra/media-worker implementing every
MediaInferenceProvider operation behind HTTP API v1, plus capabilities.
Bearer auth, MEDIA_ROOT realpath enforcement, strict request schemas,
cancellation on disconnect, GPU/CPU gates with 503 overflow, input
size/duration limits, lazy SHA256-pinned model downloads, fail-closed
redaction with atomic output, offline pytest suite with fake backends,
CPU/CUDA/ROCm Dockerfile and a license review of every model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138YqDj3ttfayRwuMKKrqVj
2026-10-03 18:19:47 +00:00

36 lines
959 B
Python

"""Entry point: `python -m app` serves the API, `python -m app prefetch` warms the model volume."""
from __future__ import annotations
import logging
import sys
import uvicorn
from .config import ConfigError, Settings
from .main import create_app
from .models import Registry
def main(argv: list[str]) -> int:
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s %(message)s")
try:
settings = Settings.from_env()
except ConfigError as error:
print(f"media-worker: {error}", file=sys.stderr)
return 2
if argv[1:] == ["prefetch"]:
Registry(settings).prefetch()
return 0
if argv[1:]:
print("usage: python -m app [prefetch]", file=sys.stderr)
return 2
uvicorn.run(
create_app(settings), host=settings.host, port=settings.port, log_level="info", access_log=False
)
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv))