Skip to main content

IQ SDK for creating and managing distributed workers in IQ Flow orchestration platform.

Project description

iq-sdk

A Python SDK for creating and managing distributed workers in IQ Flow orchestration platform.

PyPI version CI License: MIT

Quickstart

# Create project directory
mkdir my_iq_tools_project
cd my_iq_tools_project

# Set up virtual environment
python -m venv .venv
source .venv/bin/activate

# Install iq-sdk
pip install iq-sdk

# Initialize project
iq init .

This creates a complete project with configuration, Docker setup, GitHub Actions, and more.

Next steps:

# Set your password in .env
echo "IQ_SITE_DEFAULT_API_SECRET=secret" >> .env

# Create a tool
iq tool create hello

# Create a worker
iq worker create main --tools hello

# Start the worker
iq worker start main

Full Quickstart Guide

Features

  • Site-Based Configuration - Manage multiple sites with host/env/user/password
  • CLI for Project Scaffolding - Complete setup with iq init
  • Socket.IO Worker Connectivity - Workers connect to one or more sites
  • Secure Secrets Handling - Passwords via ENV or K8s-style file references
  • Configurable Threading - Set thread counts, enable autoscaling
  • Docker Integration - Built-in support for baker-cli

Project Structure

After iq init, you get:

my-project/
├── config/
│   └── settings.yml      # Sites and tool configuration
├── .env                  # Secrets (passwords)
├── .gitignore
├── pyproject.toml
├── build-settings.yml    # Docker build config
├── tools/                # Your tool implementations
├── .devcontainer/        # VS Code DevContainer
├── .github/workflows/    # GitHub Actions
└── docker/               # Dockerfile & compose

CLI Reference

Site Management

iq site list              # List all sites
iq site list --check      # Check connectivity
iq site add prod --host http://prod:3000
iq site drop prod

Tool Management

iq tool create NAME       # Create a tool
iq tool list              # List tools

Worker Management

iq worker list            # Show configured tools/workers
iq worker list --check    # Check tool availability
iq worker run [OPTIONS]   # Start a worker

Options:
  --threads, -t INT      Thread count
  --max-threads INT      Max threads (autoscaling)
  --autoscale            Enable autoscaling
  --tool TOOL            Tools to register (repeatable)
  --site, -s SITE        Sites to connect (repeatable)
  --config, -c FILE      Config file

Output Queue

When task output submission fails (host unreachable, errors), outputs are queued locally for retry:

iq worker queue           # List pending outputs
iq worker queue --failed  # List failed (max retries exceeded)
iq worker queue -t tool   # Filter by tool name
iq worker queue --retry   # Manually retry all pending
iq worker queue --retry -y  # Retry without confirmation

Queue files are stored in ./data/{site}/queue-output/.

Configuration

Sites (config/settings.yml)

site:
  id: "default"
  host: "http://localhost:3000"
  api_key: "worker"
  tools:
    - "my-tool"

sites:
  - id: "production"
    host: "http://prod:3000"
    api_key: "prod-worker"
    tools:
      - "my-tool"

Secrets (.env)

# Direct password
IQ_SITE_DEFAULT_PASSWORD=secret
IQ_SITE_PRODUCTION_PASSWORD=prod-secret

# Or file reference (K8s/Docker secrets)
IQ_SITE_PRODUCTION_API_SECRET_FILE=/run/secrets/prod-password

# For JSON/YAML secrets, extract with _PASSWORD_KEY
IQ_SITE_STAGING_API_SECRET_FILE=/etc/secrets/creds.json
IQ_SITE_STAGING_API_SECRET_KEY=database.password

Worker Settings (config/settings.yml)

worker:
  threads: 2              # Default threads per tool
  autoscale: false        # Enable autoscaling
  min_threads: 1          # Min threads (autoscaling)
  max_threads: 16         # Max threads (autoscaling)

  # Retry settings for failed output submissions
  retry:
    max_retries: 10       # Max retry attempts before moving to failed queue
    initial_delay: 10     # Initial retry delay in seconds
    max_delay: 3600       # Maximum retry delay (1 hour)
    backoff_multiplier: 2.0  # Exponential backoff multiplier

Environment Override

export IQ_SITE_PRODUCTION_HOST='http://new-host:3000'
export IQ_WORKER__THREADS=8
export IQ_WORKER__RETRY__MAX_RETRIES=20

Documentation

Development

For contributing or local development:

git clone https://github.com/iq-company/iq-sdk.git
cd iq-sdk
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

# Test your changes
iq init demo
cd demo

Development Guide

License

MIT License - see LICENSE for details.

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

iq_sdk-0.1.3.tar.gz (109.4 kB view details)

Uploaded Source

Built Distribution

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

iq_sdk-0.1.3-py3-none-any.whl (118.7 kB view details)

Uploaded Python 3

File details

Details for the file iq_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: iq_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 109.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for iq_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d825cb27840ea6259e914648b27f33a6f7b05a1309613148c8f509f506285ecd
MD5 db902df402ad9e2ae721ea3bf2ea6f4a
BLAKE2b-256 68295c973222ea5810c2b884875173a6aeb7bcfb130853e798d23b5372d11ae4

See more details on using hashes here.

File details

Details for the file iq_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: iq_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 118.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for iq_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 817c808a4d0c84ec19851dd66d06748b74009f28e9b93f86b06f6ad488f8a8e8
MD5 4616a6ede76902b22521ab3b7ca1ad31
BLAKE2b-256 45289442778be4cfd3f8238191e76a1c39a2f9245af77dbd2cefa78cb6c12e0b

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