Skip to main content

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:8080 --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


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.3.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

aerolvm_sdk-0.1.3-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file aerolvm_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: aerolvm_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aerolvm_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f97f6b569cabcc6a52fb492e45401af6660947169aad08ea519a589203c6dd53
MD5 aa77a76b3aedb55adcee77b28ce72da5
BLAKE2b-256 d44eacdfa25e409acc7e96a89367a7142a309ce256043a1c1b8791df6d3956dd

See more details on using hashes here.

File details

Details for the file aerolvm_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: aerolvm_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aerolvm_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a00229bf81ceee5b14f70feb56400eeaced055a823197967240c1c534c3d7e3e
MD5 2086730333fcb2c0bfa7591f362f67be
BLAKE2b-256 234e570c4033644d35a6693b5ed21c0540f9330c70802282c6c8bccaa44d0312

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