quiet robot

Sandboxes

qr command line

The qr command starts sandboxes, runs commands and code in them, copies files, opens a shell and shares a web server, from your terminal or a script.

View as Markdown

Sandboxes is in early access. It is free to try, some parts are still in testing, and details may change. Sign up free

Install

Terminal
pipx install quietrobot-sandboxes    # just the qr command, in its own environment
pip install quietrobot-sandboxes     # or with the Python SDK
export QR_API_KEY=qr_live_...

It needs Python 3.9 or newer. Standalone qr binaries for Linux, macOS and Windows, which need no Python, are attached to each release on GitHub; check them against SHA256SUMS.txt. macOS and Windows ask before running them the first time, since they aren't signed yet.

qr reads QR_API_KEY, and QR_BASE_URL if set. --api-key and --base-url override them on any command.

One-shot runs

qr run starts a sandbox, copies files in, runs the command, copies results out and destroys the sandbox:

Terminal
qr run -- python3 -c "print(6 * 7)"
qr run --upload . --download out -- pytest -q
qr run --allow pypi.org --allow files.pythonhosted.org --upload . -- sh -c "pip install -r requirements.txt && pytest -q"

--upload copies a file or folder into work (or LOCAL:REMOTE) and the command runs there. qr run exits with the command's exit code, so it works in scripts and CI. Add --keep to leave the sandbox running afterwards.

Working with a sandbox

Terminal
qr create --egress allowlist --allow pypi.org --timeout 600   # prints the id
qr exec sbx_123 python3 -c "print(42)"
qr exec --background sbx_123 -- npm run dev                   # prints the execution id
qr logs -f exe_456                                            # follow its output
qr kill exe_456
qr shell sbx_123                                              # an interactive terminal
echo "1 + 1" | qr code sbx_123                                # the notebook kernel (or a .py file)
qr cp ./src sbx_123:app && qr cp sbx_123:app/dist ./dist      # files or whole folders
qr cat sbx_123 app/out.txt
qr expose sbx_123 8000                                        # prints the preview URL
qr expose sbx_123 3000 --public
qr pause sbx_123 && qr resume sbx_123
qr snapshot sbx_123 --name with-deps
qr fork sbx_123 --count 3
qr fork sbx_123 --cpus 4 --memory-mb 8192   # a bigger copy (how you resize)
qr rewind sbx_123
qr timeout sbx_123 3600
qr rm sbx_123

Looking around

Terminal
qr ls --status running
qr get sbx_123
qr files sbx_123 app
qr metrics sbx_123
qr audit sbx_123          # or qr audit for the whole organization
qr snapshots
qr volumes
qr usage --days 7

Approvals and exit codes

qr exec and qr run wait when one of your approval rules holds a command, and print that it's waiting. --no-wait returns at once instead. Both exit with the command's own exit code; qr itself exits with 1 on an API error and 2 on a usage error.

Add --json after any command for machine-readable output, and run qr <command> --help for all of its options.