Skip to main content

Python SDK for Oomol Cloud Task API

Project description

Oomol Cloud Task SDK (Python)

A lightweight, developer-friendly Python SDK for Oomol Cloud Task API.

Installation

pip install oomol-cloud-task-sdk

Requirements

  • Python >= 3.7
  • requests >= 2.25.0

Quick Start

from oomol_cloud_task import OomolTaskClient, BackoffStrategy

client = OomolTaskClient(api_key="YOUR_API_KEY")

task_id, result = client.create_and_wait(
    applet_id="your-applet-id",
    input_values={
        "input_pdf": "...",
        "output_path": "..."
    },
    on_progress=lambda p, s: print(f"Status: {s}, Progress: {p}%")
)

print(f"Task {task_id} completed!")
print(result)

Features

  • Automatic polling with create_and_wait
  • Fixed and exponential backoff strategies
  • Progress callback support
  • Full type hints

API Reference

OomolTaskClient

Constructor

client = OomolTaskClient(
    api_key="YOUR_API_KEY",
    base_url="https://cloud-task.oomol.com/v1",  # optional
    default_headers={"X-Custom-Header": "value"}  # optional
)

Methods

create_task()

Creates a task and returns the task ID.

task_id = client.create_task(
    applet_id="your-applet-id",
    input_values={"key": "value"},
    webhook_url="https://your-webhook.com",  # optional
    metadata={"custom": "data"}  # optional
)
get_task_result()

Fetches the current result/status of a task.

result = client.get_task_result(task_id)
await_result()

Polls for the task result until completion or timeout.

result = client.await_result(
    task_id="your-task-id",
    interval_ms=3000,           # polling interval (default: 3000)
    timeout_ms=60000,           # optional timeout
    backoff_strategy=BackoffStrategy.EXPONENTIAL,
    max_interval_ms=3000,       # max interval for exponential backoff
    on_progress=callback_fn     # optional progress callback
)
create_and_wait()

Creates a task and waits for its completion. Returns (task_id, result).

task_id, result = client.create_and_wait(
    applet_id="your-applet-id",
    input_values={"key": "value"},
    webhook_url=None,           # optional
    metadata=None,              # optional
    interval_ms=3000,
    timeout_ms=None,
    backoff_strategy=BackoffStrategy.EXPONENTIAL,
    max_interval_ms=3000,
    on_progress=None
)

Types

BackoffStrategy

from oomol_cloud_task import BackoffStrategy

BackoffStrategy.FIXED        # Fixed interval polling
BackoffStrategy.EXPONENTIAL  # Exponential backoff (1.5x multiplier)

TaskStatus

from oomol_cloud_task import TaskStatus

TaskStatus.PENDING   # Task is pending
TaskStatus.RUNNING   # Task is running
TaskStatus.SUCCESS   # Task completed successfully
TaskStatus.FAILED    # Task failed

Exceptions

from oomol_cloud_task import ApiError, TaskFailedError, TimeoutError

try:
    task_id, result = client.create_and_wait(...)
except ApiError as e:
    print(f"API Error: {e}, Status: {e.status}, Body: {e.body}")
except TaskFailedError as e:
    print(f"Task {e.task_id} failed: {e.detail}")
except TimeoutError as e:
    print(f"Operation timed out: {e}")

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

oomol_cloud_task_sdk-0.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

oomol_cloud_task_sdk-0.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file oomol_cloud_task_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: oomol_cloud_task_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for oomol_cloud_task_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ae37c45fe00b9832e43a45820255b840b987b24ef4e5b88084b36b5e6007643f
MD5 ba3fa4ebcb89d6823d94235f4c348314
BLAKE2b-256 9498afab9f6e1a66f12c96172be69ea8e6d75e94cc840eae428e7f1b38fd5df4

See more details on using hashes here.

File details

Details for the file oomol_cloud_task_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for oomol_cloud_task_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 67fa3d60936f60db6c9e2b5cbbb6a4c7aa40c4983898535d8fe989f35a462646
MD5 caf583bc831e9677d4949aafb372a6d0
BLAKE2b-256 bce76383bb29a5518f516c67067824ff50a371ed031c9d3b2fb3432075fb687c

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