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. Python 3.9 or newer, standard library only.

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. Paid plan; 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.4.1

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.4.1
File Size Uploaded Provenance Actions
groundbox-0.4.1.tar.gz 15.9 kB Without provenance Details for groundbox-0.4.1.tar.gz

Built distribution (wheel)

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

Total release size: 32.9 kB

Release files / groundbox-0.4.1.tar.gz

Download URL groundbox-0.4.1.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fc7c3ab5ad33de9f1402f0f44106723c433bb12656d4dad588f3fd033a48a3fc
BLAKE2b-256 checksum
How to use checksums
ddb5c522ecd2ea96d10046cf3542737a32f07e705e41e21e0965019f1ba894a2
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.4.1-py3-none-any.whl

Download URL groundbox-0.4.1-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
539ea21ad0beb9332706ce6a3323134be83347673a813676ed33b2d0bc745c72
BLAKE2b-256 checksum
How to use checksums
390239497ded3bc965d923b7f6f5ce0fe679f93192478a60227770b49c59867c
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.4.1

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