Skip to main content

Python SDK for Flame, a distributed system for Agentic AI

Project description

Flame Python SDK

Python SDK for the Flame, a distributed system for Agentic AI.

For the user guide, see Flame Python SDK. For the detailed API surface, see API.md.

Installation

pip install flamepy

Quick Start

import flamepy

def main():
    # Create a session with the application, e.g. Agent
    session = flamepy.create_session("flmping")
    
    # Create and run a task
    resp = session.invoke(b"task input data")

    # Handle the output of task
    print(resp)

    # Close session
    session.close()

if __name__ == "__main__":
    main()

Verify A Runner Cluster

After configuring ~/.flame/flame.yaml for a running cluster with session manager, object cache, executor manager, and the flmrun template application, run:

python -m flamepy.runner.e2e

Installed wheels also provide:

flamepy-runner-e2e

The check packages a tiny temporary project and verifies Runner function calls, ObjectFuture chaining, and a stateful instance service. Use --json for machine-readable output and --python-version 3.12 to verify a specific executor Python runtime.

API Reference

Session

Represents a computing session with application, e.g. Agent, Tools.

# Create a session
session = flamepy.create_session("my-app")

# Close a session
session.close()

Task

Represents individual computing tasks within a session.

from concurrent.futures import wait

# Run a task synchronously (blocks until complete)
result = session.invoke(b"input data")

# Run a task asynchronously (returns Future immediately)
future = session.run(b"input data")
result = future.result()  # Wait for completion

# Run multiple tasks in parallel
futures = [session.run(f"input {i}".encode()) for i in range(10)]
wait(futures)  # Wait for all tasks to complete
results = [f.result() for f in futures]

# Create a task and get task object
task = session.create_task(b"input data")

# Get task status
task = session.get_task(task.id)

# Watch task progress
for update in session.watch_task(task.id):
    print(f"Task state: {update.state}")
    if update.is_completed():
        break

Error Handling

The SDK provides custom exception types for different error scenarios:

from flamepy import FlameError, FlameErrorCode

try:
    session = flamepy.create_session("flmping")
except FlameError as e:
    if e.code == FlameErrorCode.INVALID_CONFIG:
        print("Configuration error:", e.message)
    elif e.code == FlameErrorCode.INVALID_STATE:
        print("State error:", e.message)

Development

To set up the development environment:

# Clone the repository
git clone https://github.com/xflops/flame.git
cd flame/sdk/python

# Install in development mode
# Note: Use --no-build-isolation if you have setuptools>=61.0 installed
python3 -m pip install -e . --user --no-build-isolation

# Or build and install the wheel
python3 -m build --wheel --no-isolation
python3 -m pip install dist/flamepy-0.6.0rc1-py3-none-any.whl --user

# Install development dependencies
pip install -e .[dev]

# Run tests
pytest

# Format code
ruff format

# Type checking
mypy flamepy/

Requirements

  • Python >= 3.9
  • setuptools >= 61.0 (for building from source)

Troubleshooting

If you encounter issues with the package name showing as "UNKNOWN":

  1. Make sure you have setuptools>=61.0 installed:

    python3 -m pip install --user --upgrade "setuptools>=61.0"
    
  2. Clean any stale build artifacts:

    rm -rf dist build src/flamepy.egg-info *.egg-info
    
  3. Use --no-build-isolation flag when installing:

    python3 -m pip install . --user --no-build-isolation
    

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

flamepy-0.6.0rc1.tar.gz (89.9 kB view details)

Uploaded Source

Built Distribution

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

flamepy-0.6.0rc1-py3-none-any.whl (80.0 kB view details)

Uploaded Python 3

File details

Details for the file flamepy-0.6.0rc1.tar.gz.

File metadata

  • Download URL: flamepy-0.6.0rc1.tar.gz
  • Upload date:
  • Size: 89.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","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 flamepy-0.6.0rc1.tar.gz
Algorithm Hash digest
SHA256 8372c4cbc5515dab142e465f3c53e4759a91fa68fc2ae32e1fbb52c771493e87
MD5 a76f3f038bcb366ac4158a27a9a76eae
BLAKE2b-256 af9c52b7285b27cda788ec47c9a41c65a104002616cef720bc667329be31a5a0

See more details on using hashes here.

File details

Details for the file flamepy-0.6.0rc1-py3-none-any.whl.

File metadata

  • Download URL: flamepy-0.6.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 80.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","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 flamepy-0.6.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 6fb731439bcc110e5c6078addd8d50cf97e99727f7ff9ae3c0ee0a7f5a0e8028
MD5 4f42bedd418cb58e744a414df5222989
BLAKE2b-256 d60a9a72e6d0f857ac02fbc3046970e60c408076d477c2a75cc0779e56cf7274

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