A Python client for the Aerol.ai MicroVM sandbox API.
Project description
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,
},
"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)
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())
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
aerolvm_sdk-0.1.8.tar.gz
(16.5 kB
view details)
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 aerolvm_sdk-0.1.8.tar.gz.
File metadata
- Download URL: aerolvm_sdk-0.1.8.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d184844e1b60768f66707acee9d1aaf66a455b0d7a6a58aabc3867820681d07
|
|
| MD5 |
15095d63e82001fee0690bff7f9581ab
|
|
| BLAKE2b-256 |
b6c1f2e301ddfa58ca0bc167eb5a7fe4aa2c0fdca84c88a8c435ed8416477af9
|
File details
Details for the file aerolvm_sdk-0.1.8-py3-none-any.whl.
File metadata
- Download URL: aerolvm_sdk-0.1.8-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
738345c0933967f4f8dceaaba194e16e152a35fe232177861f97f7f7d41f8a94
|
|
| MD5 |
dba6d8c9de9efc95270460e0faaa7a4b
|
|
| BLAKE2b-256 |
1e063d541d2901703538a321c3476b6294e758a45f265a433458c1f9f8fa8135
|