Skip to main content

ARL Infrastructure - Python SDK for Kubernetes-based Agent Runtime Layer

Project description

ARL Wrapper

High-level Python wrapper for the ARL (Agent Runtime Layer) client providing simplified sandbox session management.

Features

  • Context Manager Support: Automatic sandbox lifecycle management
  • Type-Safe API: Full type hints with Pydantic models
  • Kubernetes Integration: Direct CRD interaction
  • Error Handling: Comprehensive error reporting and retry logic

Installation

uv add arl-wrapper

Quick Start

Prerequisites

Ensure you have a WarmPool created. You can create one programmatically:

from arl import WarmPoolManager

# Create WarmPool (one-time setup)
warmpool_mgr = WarmPoolManager(namespace="default")
warmpool_mgr.create_warmpool(
    name="python-39-std",
    image="python:3.9-slim",
    replicas=2  # Number of pre-warmed pods
)
warmpool_mgr.wait_for_warmpool_ready("python-39-std")
print("✓ WarmPool ready!")

Basic Usage

from arl import SandboxSession

# Using context manager (recommended)
with SandboxSession(pool_ref="python-39-std", namespace="default") as session:
    result = session.execute([
        {
            "name": "hello",
            "type": "Command",
            "command": ["echo", "Hello, World!"],
        }
    ])
    
    # Access results
    status = result["status"]
    print(f"Task State: {status.get('state')}")
    print(f"Output: {status.get('stdout')}")

Manual Lifecycle Management

For long-running operations or sandbox reuse:

from arl import SandboxSession

session = SandboxSession(pool_ref="python-39-std", namespace="default", keep_alive=True)

try:
    session.create_sandbox()
    print("✓ Sandbox allocated")
    
    # Task 1: Initialize workspace
    result1 = session.execute([
        {"name": "init", "type": "Command", "command": ["mkdir", "-p", "/workspace"]}
    ])
    
    # Task 2: Reuses same sandbox (fast!)
    result2 = session.execute([
        {"name": "work", "type": "Command", "command": ["ls", "/workspace"]}
    ])
    
finally:
    session.delete_sandbox()
    print("✓ Sandbox cleaned up")

WarmPool Management

WarmPools pre-create pods to eliminate cold-start delays:

from arl import WarmPoolManager

warmpool_mgr = WarmPoolManager(namespace="default")

# Create a new pool
warmpool_mgr.create_warmpool(
    name="python-39-std",
    image="python:3.9-slim",
    sidecar_image="your-registry/arl-sidecar:latest",  # Optional
    replicas=3,
    resources={  # Optional
        "requests": {"cpu": "500m", "memory": "512Mi"},
        "limits": {"cpu": "1", "memory": "1Gi"}
    }
)

# Wait for readiness
warmpool_mgr.wait_for_warmpool_ready("python-39-std", timeout=300)

# List all pools
pools = warmpool_mgr.list_warmpools()
for pool in pools:
    print(f"Pool: {pool['metadata']['name']}, Status: {pool['status']['phase']}")

# Delete a pool
warmpool_mgr.delete_warmpool("python-39-std")

Task Step Types

Command Step

{
    "name": "run_script",
    "type": "Command",
    "command": ["python", "script.py"],
    "env": {"DEBUG": "1"},  # optional
    "workDir": "/workspace",  # optional
}

FilePatch Step

{
    "name": "create_config",
    "type": "FilePatch",
    "path": "/workspace/config.yaml",
    "content": "key: value",
}

Architecture

  • SandboxSession: High-level API using Kubernetes CRDs for task execution
  • Task CRD: Operator watches and executes tasks via sidecar
  • Auto-generated client: arl-client package (CRD models)

Task execution flow:

  1. Client creates Task CRD via Kubernetes API
  2. Operator watches for new tasks
  3. Operator communicates with sidecar to execute steps
  4. Client polls Task status for results

This architecture ensures tasks can be executed from anywhere with cluster access.

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

arl_env-0.2.7.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

arl_env-0.2.7-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file arl_env-0.2.7.tar.gz.

File metadata

  • Download URL: arl_env-0.2.7.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for arl_env-0.2.7.tar.gz
Algorithm Hash digest
SHA256 92e08c23f30cd6009de7dc56e02e747e75d0116fc9c9bace2ec42bee3cd918ee
MD5 01d2d3bdeae1c47e18f35bc65325d2b5
BLAKE2b-256 f74ad7e387900e3677d3aee9d00fea10ae2e9047ea54e2fabc2430616d1a00c2

See more details on using hashes here.

File details

Details for the file arl_env-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: arl_env-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for arl_env-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c8d6e9761d5ce42d2ba14d2229af1b9c91733938b3879912091d33bf1d2ca276
MD5 1bd0c18e5e851df94f84fe888f9a7c96
BLAKE2b-256 4455dbcf2b66b452ab3f63277a48c31ea65a50932e1980be1ded3b1e6ff7bb81

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