Run code in fast, isolated cloud sandboxes — zero Metaflow dependency
Project description
sandrun
Run code in fast, isolated cloud sandboxes without touching your local environment.
The problem
You want to execute untrusted or resource-intensive code in an isolated environment, but spinning up a full VM or container pipeline is slow, complex, and tightly coupled to your infrastructure. Existing sandbox SDKs lock you into a single provider — switching from Daytona to E2B means rewriting your integration from scratch.
Quick start
pip install sandrun[daytona]
export DAYTONA_API_KEY=...
from sandrun.backends import get_backend
backend = get_backend("daytona")
sandbox_id = backend.create()
result = backend.exec(sandbox_id, ["python", "-c", "print('hello from sandbox')"])
print(result.stdout) # hello from sandbox
backend.destroy(sandbox_id)
Install
# Daytona backend
pip install sandrun[daytona]
# E2B backend
pip install sandrun[e2b]
# Both
pip install "sandrun[daytona,e2b]"
# Core only (bring your own backend)
pip install sandrun
Usage
Run a bash script and stream output
backend = get_backend("daytona")
sandbox_id = backend.create()
result = backend.exec_script_streaming(
sandbox_id,
"for i in 1 2 3; do echo step $i; sleep 1; done",
on_stdout=print,
)
print("exit code:", result.exit_code)
backend.destroy(sandbox_id)
Upload a file, then execute it
backend = get_backend("e2b")
sandbox_id = backend.create()
backend.upload(sandbox_id, "script.py", "/tmp/script.py")
result = backend.exec(sandbox_id, ["python", "/tmp/script.py"])
backend.destroy(sandbox_id)
Deliver a code package and install deps offline
from sandrun.stager import TarballStager
from sandrun.installer import CondaOfflineInstaller
stager = TarballStager("my-project.tar")
installer = CondaOfflineInstaller.from_staged("staging-dir/")
backend = get_backend("daytona")
sandbox_id = backend.create()
stager.deliver(backend, sandbox_id)
installer.stage(backend, sandbox_id)
backend.exec_script(sandbox_id, "\n".join([
*stager.setup_commands(),
*installer.setup_commands(),
"cd /tmp/.sandrun-workdir && python main.py",
]))
backend.destroy(sandbox_id)
How it works
sandrun is a thin orchestration layer with a provider-agnostic SandboxBackend interface. Each backend wraps a cloud sandbox SDK (Daytona, E2B) behind a uniform API: create, exec, upload, download, destroy. The TarballStager and CondaOfflineInstaller handle code and dependency delivery via backend.upload() — no object storage required.
Development
git clone https://github.com/npow/sandrun
cd sandrun
pip install -e ".[dev]"
pytest
ruff check .
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sandrun-0.1.1.tar.gz.
File metadata
- Download URL: sandrun-0.1.1.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf7c079d1c5ef061df0673fb5214bc18b50ac9639c8b5af00e5621f930fd7770
|
|
| MD5 |
262c7a84cc11b5e1ef1b1896edc8f44b
|
|
| BLAKE2b-256 |
f95f73baba28898ff13dff8b68335da276727e29f6727258d7139a5616eef32d
|
Provenance
The following attestation bundles were made for sandrun-0.1.1.tar.gz:
Publisher:
publish.yml on npow/sandrun
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sandrun-0.1.1.tar.gz -
Subject digest:
cf7c079d1c5ef061df0673fb5214bc18b50ac9639c8b5af00e5621f930fd7770 - Sigstore transparency entry: 1002249733
- Sigstore integration time:
-
Permalink:
npow/sandrun@7f77be708ac6e897b1865c1dfd787739675e281b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/npow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7f77be708ac6e897b1865c1dfd787739675e281b -
Trigger Event:
push
-
Statement type:
File details
Details for the file sandrun-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sandrun-0.1.1-py3-none-any.whl
- Upload date:
- Size: 29.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca836fab2d90400737bf00b85ddf8883dc70cfa5d3058a72ea021503aa3c70ba
|
|
| MD5 |
a5d96d621f3e7c4d224fe5656fa765d2
|
|
| BLAKE2b-256 |
4c65353210816a6618e9617f5088dc4cc862047943032374f7a125d5666afe66
|
Provenance
The following attestation bundles were made for sandrun-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on npow/sandrun
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sandrun-0.1.1-py3-none-any.whl -
Subject digest:
ca836fab2d90400737bf00b85ddf8883dc70cfa5d3058a72ea021503aa3c70ba - Sigstore transparency entry: 1002249819
- Sigstore integration time:
-
Permalink:
npow/sandrun@7f77be708ac6e897b1865c1dfd787739675e281b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/npow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7f77be708ac6e897b1865c1dfd787739675e281b -
Trigger Event:
push
-
Statement type: