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.3.1.tar.gz (5.2 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.3.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for orkera-0.3.1.tar.gz
Algorithm Hash digest
SHA256 5416247ad7626bd01c386b78dd80c45ec0829697065fb40e57487b64a85ba49d
MD5 c9bbc0c3d3c538d099ab39737de01f7a
BLAKE2b-256 7ac4a817d4fdebd18fb98307b344567af734014082d66a9df7265863ebeddaaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: orkera-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f5c9161ff8c592c113e197868f6931703f9bd07b26d0322a2b936ab9ff4107b
MD5 4e31a99fbd5560549255b25ea30483a7
BLAKE2b-256 f5826995cdbfb00e00abd9abb632eee67d3007910828ea98f9f5503a6459569f

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