Skip to main content

Client library for the Sandai Operator SDK

Project description

Sandai Operator Client

Lightweight Python client for submitting tasks to a Sandai operator over Celery.

Installation

pip install sandai-operator-client

For local development:

pip install -e ".[dev]"

Quick Start

from sandai.operator_client import create_client

client = create_client("video-clipper", "v1")

artifacts, results = client.sync(
    input_artifacts=[{"uri": "file:///tmp/input.mp4", "slot": "video"}],
    options={"clip_duration": 10},
)

Core API

  • create_client(operator_name, operator_version, **kwargs) constructs an OperatorClient.
  • async_call(...) submits a task and returns a Celery AsyncResult.
  • sync(...) submits a task and waits for (artifacts, results).
  • desc fetches the operator description payload, validates its status, and caches it per client instance.
  • batch_async(...) preserves the legacy best-effort behavior and returns AsyncResult | None per task.
  • batch_sync(...) preserves the legacy best-effort behavior and returns legacy tuples per task.
  • batch_submit(...) returns structured submission objects with explicit send errors.
  • batch_collect(...) resolves structured submission objects into per-task structured results.
  • batch_sync_detailed(...) returns structured per-task execution results directly.
  • probe() performs a stronger transport/protocol health probe.
  • ping() is a compatibility helper that only confirms the submit path is reachable.
  • get_queue_info() returns the queue names used for each priority.

Task Controls

The client supports the same task-control fields used by the operator runtime:

  • timeout: converted into an absolute deadline before sending the task.
  • cancel_key: propagated to the operator so tasks can be skipped before compute starts.
  • persistent_output: stored under meta["persistent-output"] for runtimes that preserve uploaded outputs.

Batch APIs

The package now exposes two batch styles:

  • Legacy compatibility APIs: batch_async(...) and batch_sync(...) keep the previous best-effort semantics.
  • Structured APIs: batch_submit(...), batch_collect(...), and batch_sync_detailed(...) expose explicit per-task submission/execution status instead of collapsing failures into empty results.

Prefer the structured APIs for new integrations.

Health Checks

ping() and probe() are intentionally different:

  • ping() returns True when task submission succeeds.
  • probe() returns a structured HealthCheckResult with submit_ok, retrieval_ok, response_ok, and optional error details.

Use probe() when you need a meaningful health signal.

Priority Model

Supported priorities are:

  • high
  • normal
  • low
  • very_low

Queue names follow this pattern:

<priority>.<operator_name>.<operator_version>

Environment Variables

The client reads these settings when explicit connection arguments are not provided:

  • SANDAI_OPERATOR_CELERY_BROKER_URL
  • SANDAI_OPERATOR_CELERY_RESULT_BACKEND
  • SANDAI_OPERATOR_CELERY_TASK_SERIALIZER
  • SANDAI_OPERATOR_CELERY_RESULT_SERIALIZER
  • SANDAI_OPERATOR_AUTO_FORGET_RESULT

If broker/backend are not configured, the client falls back to local Redis defaults:

redis://localhost:6379/0

By default the client now submits and stores Celery payloads with msgpack, while advertising accept_content=["json", "msgpack"] so it can still interoperate with older JSON-based operators during rollout.

Error Model

sync() and desc normalize failures into typed exceptions where possible:

  • TaskTimeoutError
  • TaskExecutionError
  • TaskDeadlineExceededError
  • TaskCancelledError
  • InvalidTaskStatusError
  • InvalidResultFormatError
  • InvalidPriorityError

Structured batch APIs surface task errors directly on each result object instead of converting them into empty legacy tuples.

Testing

Run the client regression suite from the repository root:

python operator-client/tests/run_all_tests.py

The suite is mock-based and does not require a live Celery or Redis deployment.

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

sandai_operator_client-0.4.3.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

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

sandai_operator_client-0.4.3-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file sandai_operator_client-0.4.3.tar.gz.

File metadata

  • Download URL: sandai_operator_client-0.4.3.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for sandai_operator_client-0.4.3.tar.gz
Algorithm Hash digest
SHA256 d354dbab87dddff98396ef96c550fe16d456471fbbe76d2c99db85600248a98d
MD5 5f6c70b098797a0615baf7644b9034e9
BLAKE2b-256 ba046eebac9a220e6087a4f9d787210275e69953384d9f2281ea53a020061296

See more details on using hashes here.

File details

Details for the file sandai_operator_client-0.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for sandai_operator_client-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 09c66eeaa03dcc81ef213f0b24eb15d6d04de0797a7905b60e74f10e072239af
MD5 11c67cd78c9f93dbc57bcb41d0e7dae1
BLAKE2b-256 83aea6e67c91a1a708d0eb26d2d5496d02145408eb4aeeb6206c5064f364b740

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