Skip to main content

Python client SDK for the Orchard Flow REST API

Project description

orchard-sdk

Python client SDK for the Orchard Flow REST API.

Call Groves, list providers, and trigger webhooks from any Python application. Supports both sync and async usage.

Install

pip install orchard-sdk

Or with test dependencies:

pip install "orchard-sdk[test]"

Quick Start

from orchard_sdk import OrchardClient

# Connect to an Orchard Flow API server
client = OrchardClient(
    base_url="http://localhost:8000",
    api_key="of_your_api_key_here",
)

# Run a Grove
result = client.run_grove("my_grove", soil={"key": "value"}, seed=42)
print(result["harvest"])

# List available providers
providers = client.list_providers()
print(providers)

# Check server health
if client.is_healthy():
    print("Server is online")

Async Usage

import asyncio
from orchard_sdk import OrchardClient

async def main():
    async with OrchardClient(
        base_url="http://localhost:8000",
        api_key="of_your_api_key_here",
    ) as client:
        # Run a Grove asynchronously
        result = await client.async_run_grove("my_grove", soil={"key": "value"})
        print(result)

        # List providers asynchronously
        providers = await client.async_list_providers()
        print(providers)

asyncio.run(main())

Trigger Webhooks

client = OrchardClient(base_url="http://localhost:8000", api_key="of_xxx")
result = client.trigger_webhook("my_grove", event="file.uploaded", data={"path": "/tmp/file.mp4"})

Error Handling

from orchard_sdk import OrchardClient
from orchard_sdk.errors import (
    OrchardNotFoundError,
    OrchardAuthenticationError,
    OrchardServerError,
    OrchardConnectionError,
    OrchardTimeoutError,
)

client = OrchardClient(base_url="http://localhost:8000", api_key="of_xxx")

try:
    result = client.run_grove("missing_grove")
except OrchardNotFoundError:
    print("Grove not found")
except OrchardAuthenticationError:
    print("Check your API key")
except OrchardConnectionError:
    print("Server is unreachable")
except OrchardTimeoutError:
    print("Request timed out")

API Reference

OrchardClient

Method Description
run_grove(name, soil, seed) Execute a Grove and return results
run_grove_model(name, soil, seed) Same but returns typed GroveRunResponse
list_providers() List all registered providers
trigger_webhook(name, event, data) Trigger a Grove via webhook
is_healthy() Check server connectivity

Async variants (prefixed async_) available for all methods.

Requirements

  • Python 3.11+
  • httpx >= 0.27
  • pydantic >= 2.0

Development

git clone https://github.com/MegistusAI/orchard-flow
cd orchard/sdks/python
pip install -e ".[test]"
pytest tests/

License

MIT

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

orchard_sdk-0.1.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.

orchard_sdk-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file orchard_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: orchard_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for orchard_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ca374f30ba5502e3fc171a9308e205f5f50279dae9e1e2c86187b3c3daa01879
MD5 a1f6ad186cbf51850d338692503c46da
BLAKE2b-256 86e4b8883b6c5d1930e3394067924bb57edddcf67ed870de3d6b6bf3f9da56a1

See more details on using hashes here.

File details

Details for the file orchard_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: orchard_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for orchard_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d150c4335bdf96e5a65ca8f7d6c2499509af6ca0b64a5e58809ff84009a4cc3
MD5 ff0695f3ea67562f0140e23414da095e
BLAKE2b-256 6bb3c9a336ad39e2978ffcc09d30492d17a0c5ca17139a719030be186ae2cc5c

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