Skip to main content

Autonoma SDK — automate the Autonoma Environment Factory endpoint

Project description

Autonoma Python SDK

Python implementation of the Autonoma Environment Factory SDK.

Package

Package Description
autonoma-ai Core protocol (HMAC, refs, graph, handler)
autonoma-ai[sqlalchemy] SQLAlchemy executor adapter
autonoma-ai[django] Django executor adapter and server handler
autonoma-ai[flask] Flask server adapter
autonoma-ai[fastapi] FastAPI server adapter
autonoma-ai[postgres] PostgreSQL driver (psycopg2)
autonoma-ai[all] All adapters and drivers

Quick Start

Install

pip install autonoma-ai
# With extras:
pip install "autonoma-ai[sqlalchemy,fastapi,postgres]"
# Or everything:
pip install "autonoma-ai[all]"

FastAPI + SQLAlchemy

from autonoma.types import HandlerConfig
from autonoma_fastapi import create_fastapi_handler
from autonoma_sqlalchemy import sqlalchemy_executor
from sqlalchemy import create_engine

engine = create_engine("postgresql://user:pass@localhost/mydb")

config = HandlerConfig(
    executor=sqlalchemy_executor(engine),
    scope_field="organization_id",
    shared_secret="your-shared-secret",
    signing_secret="your-signing-secret",
    auth=lambda user, context: {
        "headers": {"Authorization": f"Bearer {create_session_token(user['id'])}"}
    },
)

router = create_fastapi_handler(config)
app.include_router(router, prefix="/api/autonoma")

Model name ↔ table name

By default, the SDK derives a model name from each SQL table by splitting on _ and PascalCasing each part — no pluralization. Examples:

SQL table Auto-derived model name
user User
api_key ApiKey
branch_deployment BranchDeployment
organizations Organizations (stays plural)
api_keys ApiKeys (stays plural)

If every factory you register is keyed under the auto-derived name, omit table_name_map entirely. The SDK handles the mapping.

You only need table_name_map when a factory key disagrees with the auto-derived name. Common reasons:

  • Your tables are plural but you want singular factory keys: organizations table ↔ Organization key.
  • Legacy short names: usr table ↔ User key, acl table ↔ AccessControl key.

The map is sparse, not exhaustive: only list entries that actually differ. Auto-derivation covers the rest.

# Tables in DB: organization, user, api_key, deal   (singular)
# Factories keyed: Organization, User, ApiKey, Deal
# table_name_map = None  # auto-derive is exact; omit the kwarg

# Tables in DB: organizations, users, api_keys
# Factories keyed singular → every entry disagrees:
config = HandlerConfig(
    ...,
    table_name_map={
        "Organization": "organizations",
        "User": "users",
        "ApiKey": "api_keys",
    },
    factories={"Organization": ..., "User": ..., "ApiKey": ...},
)

Red flag: if your table_name_map has one entry per factory and every entry is just a plural↔singular rename, consider keeping factory keys plural (Organizations) and dropping the map entirely. Plural keys are valid — pick whichever convention your scenarios use.

Commands

poetry install --all-extras   # install with all adapters
poetry run pytest              # run tests
poetry run pytest -k "sqlalchemy"  # tests matching pattern

Documentation

For protocol-level documentation, see the root protocol/ directory. For runnable examples, see examples/python/.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autonoma_ai-0.2.1.dev1777188802.tar.gz (29.8 kB view details)

Uploaded Source

Built Distribution

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

autonoma_ai-0.2.1.dev1777188802-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

Details for the file autonoma_ai-0.2.1.dev1777188802.tar.gz.

File metadata

File hashes

Hashes for autonoma_ai-0.2.1.dev1777188802.tar.gz
Algorithm Hash digest
SHA256 99ff76ff34d9f729f29287b74aa7d472ff2bb2b04ef4ec95317bb35679d1d4f9
MD5 9a21ac9dfc8dfd395780c9a26360562c
BLAKE2b-256 15ee03c05b7ce3412fdb13cfa6f1338952a42185b3c634d0cf9d058d71c8ee29

See more details on using hashes here.

Provenance

The following attestation bundles were made for autonoma_ai-0.2.1.dev1777188802.tar.gz:

Publisher: canary.yml on Autonoma-AI/sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autonoma_ai-0.2.1.dev1777188802-py3-none-any.whl.

File metadata

File hashes

Hashes for autonoma_ai-0.2.1.dev1777188802-py3-none-any.whl
Algorithm Hash digest
SHA256 0f17e38b248e41308e21aeb1720851dd56b4bf58b1f5fea9a320ba74ba1a7dbd
MD5 5163669221e900b1fee7188f9fb12b68
BLAKE2b-256 4202b8edc2ee65b7b07cb3510d0b3893d42d1872f5752c76404866bdda3175c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for autonoma_ai-0.2.1.dev1777188802-py3-none-any.whl:

Publisher: canary.yml on Autonoma-AI/sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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