Skip to main content

Aerol.ai MicroVM Python SDK

A lightweight Python SDK for the Aerol.ai MicroVM sandbox API.

Install

pip install aerolvm-sdk

For local development from this repository:

cd sdk/python
pip install .

Usage

from microvm import MicroVM

client = MicroVM(pat_token="${SB_PAT_TOKEN}", api_url="https://sandbox.example.com")
health = client.health()
print(health)
print(health["sshGateway"])

sandbox = client.create(
	{
		"image": "ghcr.io/aerol-ai/ubuntu:22.04",
		"lifecycle": {
			"stopIfIdleFor": 3_600_000_000_000,
			"destroyAtAge": 86_400_000_000_000,
		},
		"failover": {"policy": "recreate"},
		"mounts": [
			{
				"type": "s3",
				"target": "/workspace",
				"source": "s3://bucket/prefix",
				"credentials": {"access_key_id": "AKIA...", "secret_access_key": "SECRET"},
			}
		],
	}
)
print(sandbox.sshPublicKey)
print(sandbox.sshPrivateKey)  # only returned by create()
print(client.mounts(sandbox.id))

sandbox.update_lifecycle(
	{
		"stopIfIdleFor": 7_200_000_000_000,
		"destroyAtAge": 172_800_000_000_000,
	}
)
print(sandbox.lifecycle)

Build Images

from microvm import Image, MicroVM

client = MicroVM(pat_token="${SB_PAT_TOKEN}", api_url="https://sandbox.example.com")
image = Image.base("ubuntu:22.04").run_commands("apt-get update", "apt-get install -y curl")

# create() accepts an Image directly
sandbox = client.create({"image": image})

# or build it explicitly and reuse the content-addressed tag
tag = client.build_image(image)
print(tag)

Example

python examples/create_sandbox.py --api-url http://127.0.0.1:21212 --pat-token test --image ghcr.io/aerol-ai/ubuntu:22.04

Streaming exec

import sys

handle = sandbox.exec_stream(
	{
		"command": "bash",
		"tty": True,
		"cols": 120,
		"rows": 40,
		"onStdout": lambda chunk: sys.stdout.buffer.write(chunk),
	}
)

handle.write("echo hello\n")
result = handle.wait()
print(result)

Sessions

import sys

session = sandbox.create_session(
	{
		"name": "shell",
		"command": "bash",
		"workDir": "/workspace",
		"pty": True,
		"cols": 120,
		"rows": 40,
	}
)

print(session)
print(sandbox.list_sessions())
print(sandbox.session_log(session["id"]).decode("utf-8"))

handle = sandbox.attach_session(
	session["id"],
	{
		"cols": 120,
		"rows": 40,
		"onStdout": lambda chunk: sys.stdout.buffer.write(chunk),
	}
)
handle.write("echo attached\n")
print(handle.wait())

Release files for aerolvm-sdk 0.5.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aerolvm-sdk 0.5.4
File Size Uploaded
aerolvm_sdk-0.5.4.tar.gz 33.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aerolvm-sdk 0.5.4
File Interpreter ABI Platform
aerolvm_sdk-0.5.4-py3-none-any.whl Python 3 none any Details

Total release size: 69.1 kB

Release files / aerolvm_sdk-0.5.4.tar.gz

Download URL aerolvm_sdk-0.5.4.tar.gz
Size 33.4 kB
Tags Source
SHA-256 checksum
How to use checksums
77ad9730d191dd515be774f20db3388f1282540ab8849b1907c4260c170811bf
BLAKE2b-256 checksum
How to use checksums
f94ec5f347fc03e7c693a23d58bf440f7b654c8f58ba0bae7617b436ae3155f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / aerolvm_sdk-0.5.4-py3-none-any.whl

Download URL aerolvm_sdk-0.5.4-py3-none-any.whl
Size 35.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66732f0574b173db9520468b603c182e1d4dbe970ea4c3ce224aa61045fcd49d
BLAKE2b-256 checksum
How to use checksums
adbd150faab3ada9e78ba0c452cece693bb70f2be397ef74a2905ce9604c9024
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.5.4 This release

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.4.1

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page