Python SDK for Archil Control Plane
Project description
Archil Python SDK
An ergonomic Python SDK for the Archil Control Plane.
Installation
pip install archil
Quick Start
import archil
# Make a client
client = archil.Archil()
# Load a disk
disk = client.disks.get("disk_abc123")
# Create a container on the disk
container = disk.containers.run(
command="python train.py",
vcpu_count=4,
mem_size_mib=8192
)
# Wait for completion
completed = container.wait_for_completion(timeout=600)
print(f"Exit code: {completed.exit_code}")
Making a Client
Create a client to interact with the Archil Control Plane:
import archil
# Simple initialization (uses environment variables)
client = archil.Archil()
# Or specify API key and region explicitly
client = archil.Archil(
api_key="your-api-key",
region="aws-us-east-1"
)
Environment Variables
The client reads these environment variables:
ARCHIL_API_KEY- Your API key for authentication (required)ARCHIL_REGION- Region to connect to (e.g., "aws-us-east-1")
Priority
If you provide multiple configuration options, the priority is:
- Explicit parameters (
api_key=,region=, etc.) - Environment variables (
ARCHIL_API_KEY,ARCHIL_REGION) - Default values (
aws-us-east-1for region)
Examples
# Use environment variable for API key
# export ARCHIL_API_KEY=your-api-key
client = archil.Archil()
# Specify region
client = archil.Archil(region="aws-us-west-2")
# Use custom base URL (advanced)
client = archil.Archil(base_url="https://control.red.us-east-1.aws.test.archil.com")
Loading Your Disk
Once you have a client, you can load your disks:
Get a specific disk
disk = client.disks.get("disk_abc123")
print(f"Disk: {disk.name}")
print(f"Status: {disk.status}")
List all your disks
disks = client.disks.list()
for disk in disks:
print(f"{disk.name}: {disk.disk_id}")
# Use the first disk
disk = disks[0]
Creating a Container
Using a disk
The easiest way to create a container is through a disk object:
# Load your disk
disk = client.disks.get("disk_abc123")
# Run a container on that disk
container = disk.containers.run(
command="python train.py",
vcpu_count=4,
mem_size_mib=8192,
initialization_script="pip install torch"
)
Using the client directly
You can also create containers directly through the client:
# Create an ArchilMount for your disk
mount = archil.ArchilMount(
disk_id="disk_abc123",
env="production"
)
# Create a container with the mount
container = client.containers.create(
archil_mount=mount,
vcpu_count=2,
mem_size_mib=512
)
Run a command and wait for completion
# Start a container
container = disk.containers.run(
command="python train.py --epochs 10",
vcpu_count=4,
mem_size_mib=8192
)
# Wait for it to complete (timeout in seconds)
completed = container.wait_for_completion(timeout=600)
# Check the result
if completed.exit_code == 0:
print("Success!")
else:
print(f"Failed with exit code: {completed.exit_code}")
Container options
All containers support these options:
container = disk.containers.run(
command="python train.py",
vcpu_count=4, # Number of vCPUs
mem_size_mib=8192, # Memory in MiB
kernel="6.11-slim", # Kernel: "6.11-slim" or "6.11-full"
base_image="ubuntu-22.04", # Base image
initialization_script="pip install torch", # Setup script
env={ # Environment variables
"WANDB_API_KEY": "your-key",
"MODEL_VERSION": "v2.0"
},
shared=True # Whether disk mount is shared (True by default)
)
Passing files to containers
You can pass files to containers when creating them:
from pathlib import Path
from archil import FileContent, Glob
container = disk.containers.run(
command="python script.py",
files={
# Single file
"/app/config.json": Path("config.json"),
# Entire folder
"/app": Path("./app_folder"),
# Glob pattern
"/configs": Glob("*.yaml"),
# Inline content
"/app/secret.txt": FileContent("my-secret-key")
}
)
Maximum total file size: 10 MiB across all files.
Complete Example
import archil
# 1. Make a client (uses ARCHIL_API_KEY environment variable)
client = archil.Archil()
# 2. Load your disk
disks = client.disks.list()
disk = disks[0] # Use first disk
# 3. Create a container
container = disk.containers.run(
command="python train.py --epochs 10",
vcpu_count=4,
mem_size_mib=8192,
initialization_script="pip install torch numpy",
env={
"WANDB_API_KEY": "your-key",
"MODEL_VERSION": "v2.0"
}
)
# Wait for completion
print(f"Container {container.container_id} started...")
completed = container.wait_for_completion(timeout=600)
print(f"Completed with exit code: {completed.exit_code}")
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file archil-0.1.4.tar.gz.
File metadata
- Download URL: archil-0.1.4.tar.gz
- Upload date:
- Size: 27.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d307d22e49a80f4af8b12e7a192c4d5951a4a53b8fbc7cc5debaf389b8af551
|
|
| MD5 |
3692b4c7113540c4661c0fc9e5ff17ee
|
|
| BLAKE2b-256 |
4a6e9ce98c08bf3eb97c1b978ad8a5e05fc7ee2e3ef7e4b023df04fcc8cb9f60
|
File details
Details for the file archil-0.1.4-py3-none-any.whl.
File metadata
- Download URL: archil-0.1.4-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7e96ca8182f912c7d8f1dd375e542e9ce5700e075468c672846a1be915f4e93
|
|
| MD5 |
6de3d9201fabf115dffc7ca673904e9f
|
|
| BLAKE2b-256 |
7cb0254aa605b179e1d668eb8d82eb35155bfd0dd9bb554f831d369672871718
|