Skip to main content

A Python client for the Absurd SQL-based durable execution workflow system

Project description

Absurd Python Client

A Python client for the Absurd SQL-based durable execution workflow system. This library provides a Python interface to interact with Absurd's PostgreSQL-based task queue and workflow engine.

Installation

pip install absurd

Quick Start

import psycopg
from absurd_client import AbsurdClient

# Create a client instance
client = AbsurdClient(queue_name="my_queue")

# Connect to your PostgreSQL database and spawn a task
with psycopg.connect("your_connection_string") as conn:
    # Spawn a new task
    task_id, run_id, workflow_run_id = client.spawn_task(
        conn=conn,
        task_name="process_data",
        params={"input": "data"}
    )

    print(f"Spawned task: {task_id}")

    # Claim and process tasks
    claimed_tasks = client.claim_task(conn)
    for task_data in claimed_tasks:
        run_id, task_id, attempt, task_name, params, *_ = task_data

        try:
            # Process the task
            result = {"processed": params}
            
            # Mark as completed
            client.complete_task(conn, run_id, result)
            print(f"Task {task_id} completed successfully")
        except Exception as e:
            # Mark as failed
            client.fail_task(conn, run_id, str(e))
            print(f"Task {task_id} failed: {e}")

Highway DSL Integration

The highway-dsl package provides a Python-based domain-specific language for defining complex workflows that fully supports Absurd:

from highway_dsl import WorkflowBuilder, RetryPolicy
from datetime import timedelta

# Create a workflow with Highway DSL
workflow = (
    WorkflowBuilder("data_pipeline")
    .task("extract", "etl.extract_data", result_key="raw_data")
    .task("transform", "etl.transform_data", args=["{{raw_data}}"], result_key="transformed_data")
    .task("load", "etl.load_data", args=["{{transformed_data}}"])
    .build()
)

# Export to YAML for use with Absurd
print(workflow.to_yaml())

Features

  • Task queuing and processing
  • Event-driven workflow coordination
  • Checkpoint-based state management
  • Retry strategies and failure handling
  • Workflow run tracking
  • Connection pooling for production environments
  • Support for complex workflow patterns

Configuration

The client supports the following environment variables:

  • ABSURD_DEFAULT_QUEUE: Default queue name (default: absurd_default)
  • ABSURD_WORKER_ID: Default worker ID (default: absurd_worker_1)

Support

For support, please open an issue in the GitHub repository.

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

absurd-0.0.8.tar.gz (8.2 MB view details)

Uploaded Source

Built Distribution

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

absurd-0.0.8-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file absurd-0.0.8.tar.gz.

File metadata

  • Download URL: absurd-0.0.8.tar.gz
  • Upload date:
  • Size: 8.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for absurd-0.0.8.tar.gz
Algorithm Hash digest
SHA256 41fd6f975270a87f68fbeef26a4cc2c67f9fd8e28677c64f4ddc3d4ff815c211
MD5 869be3e4b8f177e9a0abbeff10984b6e
BLAKE2b-256 734892339cad5dba0d4256ff383787de521c1b80ba0f3915d317bce1fd963d6c

See more details on using hashes here.

File details

Details for the file absurd-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: absurd-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for absurd-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a5ee6dae6c49894c88446deb19f306f6fad631e4d4ca60e2032c794b58fd6e9a
MD5 cc5bc861e2547631e27177f2f587ede4
BLAKE2b-256 9418c083b303594cae610deb975561eb38872de280044a065caeb36cb2fbd14f

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