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"}])
Metadata
Release files for groundbox 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| groundbox-0.3.0.tar.gz | 15.7 kB | Without provenance | Details for groundbox-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| groundbox-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for groundbox-0.3.0-py3-none-any.whl |
Total release size: 32.5 kB
Release files / groundbox-0.3.0.tar.gz
| Download URL | groundbox-0.3.0.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0a4f71a8aac0cff92085c50e16be08cdacdaf49a52edc17e0ec2e3855fae362
|
|
BLAKE2b-256 checksum How to use checksums |
349dda83122c461883b12df0c3047cb41a055753d0939c4b9c65e67ac8bded6b
|
| 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.3.0-py3-none-any.whl
| Download URL | groundbox-0.3.0-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8305fa4d0ec400b6c98a9b6735193d5cd703d79d24c204cea09b85c90eb5db3
|
|
BLAKE2b-256 checksum How to use checksums |
051c3851444b26a0ca7990885b6904ca65ce1a6580aaa41ecad26a357485a89a
|
| 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.3.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.