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 TaskflowClient
from datetime import datetime, timedelta

# Initialize client
client = TaskflowClient(
    server_url="http://localhost:8000",
    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 TaskflowClient provides a clean interface for interacting with the Taskflow server:

from orkera import TaskflowClient

client = TaskflowClient("http://localhost:8000", "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.1.0.tar.gz (4.6 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.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for orkera-0.1.0.tar.gz
Algorithm Hash digest
SHA256 18bdbd3553740e823bf895e316fbce5f5e7487d9012a739bb6b24d303cfd5645
MD5 c8c9675d9a75b4873d9831ed2d892831
BLAKE2b-256 569e1d4093866058d75095dd0e01df39fe7e703b32bf132cfcceda60bf483fc0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: orkera-0.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6290a1f83afeef16a87219dbed0bbc98a6a038479bb78aef54de74a3f1322a27
MD5 6a3a593a241c4d08a331d5bc493d049b
BLAKE2b-256 31bf4222973660653a0fc5b82e43f737e4cd7c65a70d6166e98e4be293068fc9

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