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

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,                         # default: 3000
    timeout_ms=60000,                         # optional
    backoff_strategy=BackoffStrategy.EXPONENTIAL,  # default: EXPONENTIAL
    max_interval_ms=3000,                     # default: 3000
    on_progress=callback_fn                   # optional
)
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,           # default: 3000
    timeout_ms=None,
    backoff_strategy=BackoffStrategy.EXPONENTIAL,  # default: EXPONENTIAL
    max_interval_ms=3000,       # default: 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.2.0.tar.gz (4.3 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.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oomol_cloud_task_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 4.3 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.2.0.tar.gz
Algorithm Hash digest
SHA256 a11bde8b232cc5d0f3fab7ee9a4187b68db3cd16b2003e7d443dc40e4d6cdf53
MD5 1a98d729b31e873bcca92a7f3d1beef8
BLAKE2b-256 d24b174f73e289cd3fdd0d84b33ffcbbb87bf76c7548eb0b12315130eba36553

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oomol_cloud_task_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44ad1634b1a83ed314961b5b82f33c3655281814f6344d01f2e737a8a1ee4271
MD5 737dd7aef57e9f0e7a3e28a9c8d9536f
BLAKE2b-256 d3214f2740ebf5546a872aedc580cf00a28c1747e503939fa843158c21b968c5

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