Skip to main content

OpenAaaS Python SDK — Agent orchestration for Science

Project description

OpenAaaS Python SDK

A Pythonic SDK for the OpenAaaS Agent orchestration network, designed for researchers and scientists who want to submit compute tasks, manage results, and interact with AI agents from plain Python or Jupyter notebooks.

Installation

pip install pyopenaaas
# or with uv
uv add pyopenaaas

Development dependencies (optional):

pip install pyopenaaas[dev]   # includes test dependencies
# or
uv add --dev pyopenaaas       # add dev dependencies directly with uv

Quick Start

1. Register & configure

import pyopenaaas

# Option A: explicit credentials
client = pyopenaaas.Client(
    server_url="https://api.open-aaas.com",
    api_key="your-api-key",
)

# Option B: load from environment variables (OPENAAAS_SERVER_URL, OPENAAAS_API_KEY)
client = pyopenaaas.Client()

2. Discover services

with client:
    info = client.discover()
    print(info)

    services = client.list_services()
    for svc in services:
        print(svc.id, svc.name, svc.agent_status)

3. Submit a task

with client:
    task = client.submit_task(
        service_id="quantum-chemistry-v1",
        task_prompt="Calculate the ground state energy of H2O using CCSD(T)/cc-pVTZ",
        output_prompt="Return the total energy in Hartree and a brief summary",
        input_files=["h2o.xyz"],
    )
    print(task)

4. Wait for completion & download results

with client:
    task = client.wait_for_task(task.id, poll_interval=10.0)
    if task.is_success():
        paths = client.download_all_files(task.id, extract_zip=True)
        for p in paths:
            print("Saved:", p)
    else:
        print("Task failed:", task.result)

Async Support

All methods have async counterparts via :class:AsyncClient:

async with pyopenaaas.AsyncClient(
    server_url="https://api.open-aaas.com",
    api_key="your-api-key",
) as client:
    services = await client.list_services()
    task = await client.submit_task("svc-1", "Run MD simulation")
    task = await client.wait_for_task(task.id)
    paths = await client.download_all_files(task.id)

In a Jupyter notebook or REPL you can also use the convenience helper:

info = pyopenaaas.run(
    pyopenaaas.AsyncClient(
        server_url="https://api.open-aaas.com",
        api_key="your-api-key",
    ).discover()
)

Jupyter Notebook users: pyopenaaas.run() uses asyncio.run() under the hood, which cannot be nested inside an existing event loop (the default in Jupyter). Instead, use await directly with :class:AsyncClient:

client = pyopenaaas.AsyncClient(
    server_url="https://api.open-aaas.com",
    api_key="your-api-key",
)
info = await client.discover()
services = await client.list_services()

Typical Research Workflow

import pyopenaaas

# 1. Initialise (reads OPENAAAS_API_KEY from env)
client = pyopenaaas.Client(server_url="https://api.open-aaas.com")

# 2. Pick a service
services = client.list_services()
ml_service = next(s for s in services if "ml" in s.name.lower())

# 3. Get usage instructions
usage = client.get_service_usage(ml_service.id)
print(usage.usage)

# 4. Submit a batch of experiments
session_id = "batch-2024-06-02"
tasks = []
for params in ["exp1.in", "exp2.in", "exp3.in"]:
    t = client.submit_task(
        service_id=ml_service.id,
        task_prompt="Train a GNN on the attached dataset",
        input_files=[params],
        session_id=session_id,
    )
    tasks.append(t)

# 5. Wait for all tasks
for t in tasks:
    final = client.wait_for_task(t.id, poll_interval=5.0)
    print(f"{final.id}: {final.status}")

# 6. Collect results
for t in tasks:
    if client.get_task(t.id).is_success():
        client.download_all_files(t.id, save_dir=f"results/{t.id}")

Configuration Priority

The SDK resolves settings in the following order (highest first):

  1. Code kwargsClient(server_url="...", api_key="...")
  2. Environment variablesOPENAAAS_SERVER_URL, OPENAAAS_API_KEY
  3. Defaultshttps://api.open-aaas.com

Exception Hierarchy

OpenAaaSError
├── AuthenticationError  (401 / 403)
├── NotFoundError        (404)
├── ConflictError        (409)
├── RequestValidationError      (400)
├── NetworkError         (connectivity)
└── RequestTimeoutError         (request timeout)

Catch the base class to handle any SDK error:

from pyopenaaas.exceptions import OpenAaaSError

try:
    client.submit_task("bad-id", "...")
except OpenAaaSError as exc:
    print("SDK error:", exc)

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

pyopenaaas-0.1.0.tar.gz (34.3 kB view details)

Uploaded Source

Built Distribution

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

pyopenaaas-0.1.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyopenaaas-0.1.0.tar.gz
  • Upload date:
  • Size: 34.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pyopenaaas-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5488c451226c872903132eda541eb3809b9080d02066464debf1451c67ed87b9
MD5 60ed5f5ea31d7aca77165977f61960e2
BLAKE2b-256 ed2fac896b95b0f426580e61566f9527bc20480e95aa1fd9987f78ce6925a80b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyopenaaas-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pyopenaaas-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c65c9a7f176d5e5ea0988dad42c2a829d663a6798c09034cfc7066aa38987747
MD5 5a6fe5d3117b0c6a62d356bfe8f4c63a
BLAKE2b-256 22ecaf3dfe0c4c182af5e071edf213c247af1574ea1e11d869fbe612b4e2632c

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