Skip to main content

guplet-sdk — the Python SDK of guplet

Thin, dependency-free client of the gup API (ARCHITECTURE.md D-23, REQUIREMENTS.md PR-12). Python ≥ 3.9.

Install (from this repository)

scripts/build-sdk.sh            # stamps the platform's API URL, installs into the active venv

Get a team API key from the console (API keys page; shown once) or, as the operator, scripts/supabase-seed.sh --api-key <team>. The public API cannot mint keys.

Use

import guplet

client = guplet.Client()                           # key: api_key= > GUPLET_TOKEN > GUPLET_API_KEY_FILE; URL: api= > GUPLET_API > built in

with client.create(image="python:3.12-slim", ttl=600) as gup:  # kind container
    gup.wait()                                                # phase Running (polls every 2 s)
    r = gup.run("python -c 'print(6*7)'", cwd="/tmp", env={"A": "1"}, timeout=60)
    print(r.stdout, r.exit_code)                              # "42\n" 0
    print(gup.port_url(8080))                                 # https://8080-<id>.<domain>/?token=... (token kept from create)

vm = client.create(kind="microvm", os="ubuntu-24.04", size="s", ttl=900, wait=True)   # the API holds the
# response until the VM is Running (a warm slot answers in under a second); without wait=True, vm.wait() polls
for stream, text in vm.run_stream("for i in 1 2 3; do echo $i; sleep 1; done"):
    print(stream, text, end="")
vm.pause(wait=True); vm.resume(wait=True)
snap = vm.snapshot()
vm.kill()

vm.pause() acknowledges an asynchronous pause. Refresh to read vm.pause_status: frozenAt confirms execution and compute billing have stopped; stage, mode, attempts, error and timings describe background persistence. Paused means durable completion. pause(wait=True) waits up to the API's time cap; check vm.phase and use vm.wait("Paused") if still Pausing. Resume raises Conflict until persistence and billing settlement complete. Snapshot failures remain frozen and unbilled while retrying; they never automatically resume the guest.

Files

gup.files reads and writes the gup's filesystem through the in-guest agent (REQUIREMENTS.md PR-3, ARCHITECTURE.md D-24). Paths are absolute or relative to the gup user's working directory; mode is an octal string as in chmod.

files = gup.files
files.write("notes.txt", "hello\n")                     # str is UTF-8; bytes pass through; parents created -> bytes written
files.read_text("notes.txt")                            # "hello\n"   (files.read() -> bytes)
files.upload("local.tar.gz", "/tmp/in.tar.gz", mode="0600")   # streamed, no buffering
files.download("/tmp/out.log", "out.log")
for e in files.list("."):                               # FileEntry: name, path, size, mode, mtime, is_dir, is_symlink
    print(e.name, e.size, e.mode, e.is_dir)
files.stat("src").is_dir                                # True
files.mkdir("build/cache", mode="0755", parents=True)   # mkdir -p
files.remove("build", recursive=True)
files.rename("notes.txt", "docs/notes.txt")             # rename or move inside the gup

Big files (ARCHITECTURE.md D-66): upload sends a file larger than guplet.UPLOAD_PART_THRESHOLD (16 MiB) in parts of the server's part size. A part whose connection drops resumes from what the gup received, and the upload completes with the file's sha256. chunked=True forces this path for any size. download resumes a dropped body with a Range request. Both give up after max_retries failures in a row.

A missing path raises NotFound; a path outside the gup or a permission error raises GupletError with status 403; a gup that is not running raises Conflict; a gup without the in-guest agent raises NotEnabled.

Background processes

gup.processes starts a command that outlives the call (ARCHITECTURE.md D-62). The in-guest agent keeps the process and its output on the gup's disk.

p = gup.processes.start("npm run dev", cwd="/app", stdin=True)   # or gup.run(cmd, background=True)
for name, text in p.output():                           # ("stdout"|"stderr", text) until it ends; follow=False stops when caught up
    print(name, text, end="")
p.send_stdin("y\n"); p.send_stdin(b"\x00raw")           # bytes are sent base64; p.close_stdin() sends EOF
p.kill("TERM")                                          # KILL by default; returns the record (state, exit_code)
done = gup.processes.start("make test").wait(timeout=600)   # the final record, with .stdout / .stderr
gup.processes.list(); gup.processes.get(p.id); p.refresh()

output() reconnects by byte offset after a dropped connection, a 5xx or an error frame, up to max_retries failures in a row. start carries an Idempotency-Key, so retrying it is safe. send_stdin is not retried after a network error. A gup created before D-62 raises NotEnabled with code agent_too_old.

Errors: GupletError(status, message) with subclasses Unauthorized (401), InsufficientCredits (402), NotFound (404), Conflict (409, e.g. not running), NotEnabled (501, feature not deployed on this cluster). A command whose session broke or hit the server timeout raises ExecError / ExecTimeout; a non-zero exit is just ExecResult.exit_code.

Not in v1 (FUTURE.md): binary-safe exec output, async, PyPI. Tests: scripts/test-sdk.sh (offline, against sdk/fixtures), scripts/sdk-smoke.sh (live).

Metadata

Release files for guplet-sdk 1.0.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 guplet-sdk 1.0.0
File Size Uploaded Provenance Actions
guplet_sdk-1.0.0.tar.gz 52.0 kB Without provenance Details for guplet_sdk-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for guplet-sdk 1.0.0
File Interpreter ABI Platform Actions
guplet_sdk-1.0.0-py3-none-any.whl Python 3 none any Details for guplet_sdk-1.0.0-py3-none-any.whl

Total release size: 88.9 kB

Release files / guplet_sdk-1.0.0.tar.gz

Download URL guplet_sdk-1.0.0.tar.gz
Size 52.0 kB
Tags Source
SHA-256 checksum
How to use checksums
adcfcfaa6a901912245332a1989eadbead128613eedf196c1f8137ca4e4ca0c9
BLAKE2b-256 checksum
How to use checksums
6245408deef9dbdca80d8fdc4c20d45b418ca683af86b04e2ba8f744cb5f6978
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / guplet_sdk-1.0.0-py3-none-any.whl

Download URL guplet_sdk-1.0.0-py3-none-any.whl
Size 36.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa75f84d9c4563a7610b870ca846fadbf45066f6ae50eb0401b04f9267aa0317
BLAKE2b-256 checksum
How to use checksums
d39e1f3d624deb0c43c85b512f626dbed8ded0ba249c85e845f8ec6127e2e0f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for guplet-sdk 1.0.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