Skip to main content

Shared, settings-agnostic media primitives (object storage + job contracts) for m8 media services.

Project description

media-sdk-m8

Shared, settings-agnostic media primitives for the m8 media stack. Consumed by:

  • media-service-m8 — the live API (job producer)
  • media-worker-m8 — the async ARQ worker (job consumer)

The SDK is framework-agnostic (no FastAPI, no auth-sdk, no pydantic-settings) and imgtools-free. It owns no business logic, no database, and no preset knowledge — callers pass an explicit config object; the SDK never reads settings or env.

Contents

Object storage — media_sdk_m8.storage

ObjectStorage is a thin wrapper over the MinIO SDK. It is constructed from an explicit ObjectStorageConfig (endpoint, credentials, region, TLS, and the default presigned-URL lifetime), so it has no dependency on any service's settings module.

from media_sdk_m8 import ObjectStorage, ObjectStorageConfig

config = ObjectStorageConfig(
    endpoint="minio:9000",
    access_key="...",
    secret_key="...",
    secure=False,
    region="us-east-1",
    presigned_expire_seconds=300,
)
storage = ObjectStorage(config)

data = storage.get_object(bucket="private-media", object_key="key")
storage.put_object(
    bucket="public-media",
    object_key="key/variants/thumb_webp/thumb.webp",
    data=variant_bytes,
    content_type="image/webp",
)

Methods: stat_object, remove_object, get_object_head, get_object, put_object, set_object_content_type, copy_object, post_upload_url, presigned_post_object, presigned_get_object.

Presigned-URL expiry defaults to config.presigned_expire_seconds and can be overridden per call via expires_seconds.

Job contracts — media_sdk_m8.contracts

Self-contained Pydantic v2 models that form the producer↔consumer contract. The service builds and enqueues them; the worker deserializes and acts on them.

  • ScanJobPayload{ object_id, bucket, object_key, owner_user_id }
  • VariantSpec{ variant_name, output_options, target_bucket, target_key }; output_options is the imgtools-shaped dict (one format + name) built by the service, so the worker needs no preset or key knowledge.
  • VariantJobPayload{ job_id, media_object_id, source_bucket, source_object_key, specs }

Development

pip install -e ".[dev]"
ruff format . && ruff check .
mypy media_sdk_m8 --ignore-missing-imports
bandit -r media_sdk_m8 --severity-level medium
pytest --cov=media_sdk_m8 --cov-report=term-missing --cov-fail-under=100

Published to PyPI on tagged release.

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

media_sdk_m8-0.1.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

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

media_sdk_m8-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: media_sdk_m8-0.1.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for media_sdk_m8-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c854f073076db88850776003257426cbfbd680d83f98b2274aec246522bbbe95
MD5 c135cd64f76b4bf40307fe7ef0521825
BLAKE2b-256 c245d36c9fa8c200c1e409e866c96dfb73e0be23f69750e6bafc539c15964d8b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: media_sdk_m8-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for media_sdk_m8-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f97f0180d969f5072dad11e2b67a80f41cffee8f1cdc99cdb9fb4c8fbc175a45
MD5 091f63ab89cbd62bbbde374871fc89ee
BLAKE2b-256 568a811f2ec46f82aca5e63d5e6676710d820054057eefd8615c2a28bad4750f

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