Skip to main content

Simple HTTP client for Orkera distributed task runner

Project description

Taskflow SDK

Simple Python SDK for the Taskflow distributed task runner platform.

🚀 Quick Start

Using the SDK

from orkera import OrkeraClient
from datetime import datetime, timedelta

# Initialize client (API URL is automatically set to https://api.orkera.com)
client = OrkeraClient(
    api_key="vgBSGW6A1zYDNHVIPB1Ctry2rR8DOCvg"
)

# Schedule a task
task_id = client.schedule_task(
    task_name="calculate_sum",
    task_kwargs={"a": 10, "b": 20},
    timeout=300
)

print(f"Task scheduled: {task_id}")

# List all tasks
tasks = client.list_tasks()
print(f"Total tasks: {len(tasks)}")

# Get specific task
task = client.get_task(task_id)
print(f"Task status: {task['status']}")

Using Raw HTTP Requests

import requests

response = requests.post(
    "http://localhost:8000/api/tasks/",
    json={
        "task_name": "calculate_sum",
        "task_kwargs": {"a": 10, "b": 20},
        "timeout": 300
    },
    headers={
        "Authorization": "Bearer vgBSGW6A1zYDNHVIPB1Ctry2rR8DOCvg",
        "Content-Type": "application/json"
    }
)

task_id = response.json()["task_id"]
print(f"Task scheduled: {task_id}")

📦 Installation

Install from source

pip install -e .

Install dependencies only

pip install -r requirements.txt

🔧 Usage

SDK Client

The OrkeraClient provides a clean interface for interacting with the Orkera server:

from orkera import OrkeraClient

client = OrkeraClient("your-api-key")

# Schedule immediate task
task_id = client.schedule_task("my_task", task_kwargs={"param": "value"})

# Schedule delayed task
from datetime import datetime, timedelta
future_time = datetime.now() + timedelta(minutes=5)
task_id = client.schedule_task("my_task", schedule_time=future_time)

# Schedule with callback
task_id = client.schedule_task(
    "my_task", 
    callback_url="http://myserver.com/webhook"
)

FastAPI Example

Run the included FastAPI example:

python examples/rest_example.py

This starts a server on port 8080 with endpoints:

  • GET / - API documentation
  • POST /schedule - Schedule a test task
  • GET /status - Check server status

📝 Examples

The examples/ directory contains:

  • rest_example.py - Complete FastAPI server showing task scheduling

🔐 Requirements

  • Python 3.7+
  • requests>=2.25.0
  • fastapi>=0.68.0 (for examples)
  • uvicorn>=0.15.0 (for examples)

🚨 Server Setup

Make sure your Django Taskflow server is running on http://localhost:8000 with a valid API key.

API Reference

TaskflowClient

__init__(server_url, api_key, timeout=30)

Initialize the client with server URL and API key.

schedule_task(task_name, task_args=None, task_kwargs=None, schedule_time=None, timeout=300, retry_count=0, callback_url=None)

Schedule a task for execution.

list_tasks()

List all tasks for the authenticated user.

get_task(task_id)

Get details of a specific task.

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

orkera-0.2.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

orkera-0.2.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: orkera-0.2.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for orkera-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f8361d4b75ff4e965bf44bbcd8c791f346b46f34d9fa5f488e0e981b1e89b669
MD5 8833c038039485b09c569b3d6759d07a
BLAKE2b-256 e6b0a818ef5be42df4df7897e39b793b4dddd4a9690fdec09ad9166c49e4017f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: orkera-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for orkera-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fdc8217cb4f81f20588684bccd6a81b560f952e33096dae3d076d8768da5e8a3
MD5 49f530f08245cd21c6dca2734dd1afa2
BLAKE2b-256 513d6416226c036393ce2956a09d3bf6f7c3d9a7120d95d39d51f77328a660d8

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