Skip to main content

groundbox

The Python client for the Groundbox API: sandboxes and CI runners for your agents.

pip install groundbox

Quickstart

from groundbox import Groundbox
gb = Groundbox()  # reads GROUNDBOX_API_KEY
sandbox = gb.create_sandbox(cpus=2)
print(gb.run_command(sandbox["id"], "uname -a")["stdout"])
gb.delete_sandbox(sandbox["id"])

list_sandboxes keeps stopped and failed sandboxes. To get only the ones that are not over, or only some: gb.list_sandboxes(live=True, metadata={"project": "alpha"}), or status=["running", "paused"].

make_dir, stat_file, file_exists and delete_file (with recursive=True for a folder that has files in it) work on single paths.

A failed call raises GroundboxError with the API's code, status and request_id. A version too old for the API raises UpgradeRequiredError (code upgrade_required), with upgrade, the command that fixes it. Python 3.9 or newer, standard library only.

Updates

The SDK never prints. gb.latest_version is the newest version the API has named, or None before the first call. To hear of a newer one, pass a callback:

gb = Groundbox(on_update_available=lambda u: print(f"groundbox {u['latest']} is out (you have {u['current']}): {u['upgrade']}"))

It is called once per new version.

From a Docker image

image starts a sandbox from a Docker image, with no template made first: a public image, or one in your Groundbox registry.

sandbox = gb.create_sandbox(image="python:3.12-slim")
sandbox = gb.wait_for_sandbox(sandbox["id"])  # running, or failed with sandbox["error"]
print(gb.run_command(sandbox["id"], "python -V")["stdout"])

The first sandbox from an image comes back queued while the image is turned into a disk; later ones start like a template's. Commands run as root with the image's ENV. Its ENTRYPOINT, CMD, USER and WORKDIR are not used: start your program with a command and pass cwd. Private images on other registries are not supported.

A command is a string (a shell line, run with sh -c) or a list (a program and its arguments, run with no shell). stdin is text or bytes; encoding="base64" returns the output as base64, byte for byte.

gb.run_command(sandbox["id"], ["git", "commit", "-m", "Fix the $PATH bug"])
print(gb.run_command(sandbox["id"], ["python3", "-"], stdin="print(6 * 7)\n")["stdout"])

Commands in the background: start_command returns at once with the command's id, get_command_output reads what it printed from a position, follow_command yields output until it ends, list_commands shows what runs and ran, and kill_command ends one.

server = gb.start_command(sandbox["id"], "npm run dev", cwd="/home/runner/app")
for part in gb.follow_command(sandbox["id"], server["id"]):
    print(part["stdout"], end="")

Snapshots

A snapshot keeps a sandbox as it is at one moment: memory, disk and running processes. It stays when the sandbox is deleted, and new sandboxes start from it.

snapshot = gb.keep_snapshot(sandbox["id"], label="deps installed")
gb.delete_sandbox(sandbox["id"])
copy = gb.create_sandbox(snapshot_id=snapshot["id"])
gb.list_snapshots()
gb.delete_snapshot(snapshot["id"])

keep_snapshot waits until the snapshot is ready. Pass snapshot_id to keep one of the sandbox's save points instead of the moment now; that also works while the sandbox is paused. Storage is billed per GB-month like a paused sandbox.

Templates and volumes

A template is a ready-made disk (an image, a Dockerfile or a list of packages) built once. Sandboxes of the template's exact size start from its warm snapshot in well under a second.

gb.create_template("python-ml", image="python:3.12-slim", pip=["numpy", "pandas"])
for line in gb.follow_template_logs("python-ml", 1):
    print(line["text"])
gb.create_volume(10, name="data")
sandbox = gb.create_sandbox(template="python-ml", volumes=[{"volume": "data", "path": "/data"}])

Docs: https://groundbox.dev/docs

Metadata

Release files for groundbox 0.5.0

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

Source distribution (sdist)

Source distribution for groundbox 0.5.0
File Size Uploaded Provenance Actions
groundbox-0.5.0.tar.gz 22.0 kB Without provenance Details for groundbox-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for groundbox 0.5.0
File Interpreter ABI Platform Actions
groundbox-0.5.0-py3-none-any.whl Python 3 none any Details for groundbox-0.5.0-py3-none-any.whl

Total release size: 44.9 kB

Release files / groundbox-0.5.0.tar.gz

Download URL groundbox-0.5.0.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bb52e6111e8da7bb4d33fddecd7ade5b7b2ca5cd51ae3e5f748ea5b742833cae
BLAKE2b-256 checksum
How to use checksums
757d41e5e6fd87c9d829a5cabfe11d4d86a0ea4441bcf706259d33b246247628
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / groundbox-0.5.0-py3-none-any.whl

Download URL groundbox-0.5.0-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
565044e285573dd6b770cd31f0d75024abab147d003579a2a95811c0ca8459a3
BLAKE2b-256 checksum
How to use checksums
5d41ff257f9f84c255683f0b43b20cced535a8a5dd00c17bb6786acb51bead94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for groundbox 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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