Run Metaflow steps in isolated cloud sandboxes — instant container spinup via Daytona, E2B, or custom backends
Project description
metaflow-sandbox
Run selected Metaflow steps in fast remote sandboxes (Daytona or E2B) while keeping normal Metaflow behavior for artifacts, retries, and flow state.
Why Use It
- ⚡ Speed + scale: launch sandboxes in milliseconds (
<100ms) and fan out to thousands of containers. - 🔒 Isolation: run tool-heavy or untrusted code without polluting the launcher machine.
- 📦 Dependency management: keep runtime dependencies consistent across local runs, CI, and remote execution.
- 🧪 Throughput for evals: run many short-lived agent tasks in parallel for benchmark and regression loops.
- 🔁 Continuity: keep normal step-to-step state and result passing.
Quick Start (Daytona) 🚀
pip install metaflow-sandbox[daytona]
export DAYTONA_API_KEY=...
export METAFLOW_DEFAULT_DATASTORE=s3
export METAFLOW_DATASTORE_SYSROOT_S3=s3://your-bucket/metaflow
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
python my_flow.py run
Minimal example:
from metaflow import FlowSpec, step, daytona
class Demo(FlowSpec):
@step
def start(self):
self.msg = "hello"
self.next(self.remote)
@daytona(cpu=1, memory=2048)
@step
def remote(self):
self.msg = self.msg + " from sandbox"
self.next(self.end)
@step
def end(self):
print(self.msg)
if __name__ == "__main__":
Demo()
R2 / S3-Compatible Setup ☁️
For Cloudflare R2, set:
export METAFLOW_S3_ENDPOINT_URL=https://<accountid>.r2.cloudflarestorage.com
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
# optional for R2:
export AWS_DEFAULT_REGION=auto
Dependency Hydration in Sandbox 📦
Use your normal Metaflow decorators:
@daytona
@pypi(packages={"pydash": "==8.0.5"})
@step
def pypi_step(self):
import pydash
self.x = pydash.camel_case("hello_world")
self.next(self.conda_step)
@daytona
@conda(libraries={"numpy": "1.26.4"}, python="3.12.12")
@step
def conda_step(self):
import numpy as np
print(self.x, int(np.array([1, 2, 3]).sum()))
Backends 🔌
- Daytona:
pip install metaflow-sandbox[daytona], use@daytona - E2B:
pip install metaflow-sandbox[e2b], use@e2b - Generic:
@sandbox(backend="daytona", cpu=2, memory=4096)
Configuration 🧭
For the full list of decorator parameters, environment variables, defaults, and advanced toggles, see docs/configuration.md.
Troubleshooting 🛠️
-
Symptom: auth error from backend API
-
Fix: set the right key (
DAYTONA_API_KEYorE2B_API_KEY) in the shell that runs the flow. -
Symptom:
@sandbox/@daytonasays remote datastore is required -
Fix: set
METAFLOW_DEFAULT_DATASTOREand its remote datastore root. -
Symptom: datastore access errors (
403, missing objects, endpoint errors) -
Fix: verify cloud credentials and endpoint config (
METAFLOW_S3_ENDPOINT_URLfor R2/custom S3).
Development 🧪
ruff check src/ tests/
pytest tests/unit/ tests/structural/
pytest tests/integration/ -m integration
Architecture details: docs/architecture.md
Backend interface: docs/adding-a-backend.md
License
Apache License 2.0. See 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 metaflow_sandbox-0.1.0.tar.gz.
File metadata
- Download URL: metaflow_sandbox-0.1.0.tar.gz
- Upload date:
- Size: 35.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5003fd8a46f2d37ef1dab0eab0ebb31cfcddfd78e7073e15a03f8c9770117ceb
|
|
| MD5 |
6b0ff06e86a4a347881fd55ce40393ea
|
|
| BLAKE2b-256 |
3a530b9dc12079c72671f0b26ac0be36920d9bf8e78a1e8beff6e0e07f945cb7
|
Provenance
The following attestation bundles were made for metaflow_sandbox-0.1.0.tar.gz:
Publisher:
publish.yml on npow/metaflow-sandbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaflow_sandbox-0.1.0.tar.gz -
Subject digest:
5003fd8a46f2d37ef1dab0eab0ebb31cfcddfd78e7073e15a03f8c9770117ceb - Sigstore transparency entry: 995158609
- Sigstore integration time:
-
Permalink:
npow/metaflow-sandbox@34e050eb1b1f5707e97d0224949efe56841783ed -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/npow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@34e050eb1b1f5707e97d0224949efe56841783ed -
Trigger Event:
push
-
Statement type:
File details
Details for the file metaflow_sandbox-0.1.0-py3-none-any.whl.
File metadata
- Download URL: metaflow_sandbox-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.8 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 |
0726fb2d708c0cbdb981e3861b4cf2986cda1ab336e6b5dc282a0c12f15026ea
|
|
| MD5 |
e569553f39559ae308b119a2362fbb7d
|
|
| BLAKE2b-256 |
c64a1c4e31aad485d7e1a5f8c2ae41f0276fc8e17c6fddb885fd3d65674cf5c3
|
Provenance
The following attestation bundles were made for metaflow_sandbox-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on npow/metaflow-sandbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaflow_sandbox-0.1.0-py3-none-any.whl -
Subject digest:
0726fb2d708c0cbdb981e3861b4cf2986cda1ab336e6b5dc282a0c12f15026ea - Sigstore transparency entry: 995158612
- Sigstore integration time:
-
Permalink:
npow/metaflow-sandbox@34e050eb1b1f5707e97d0224949efe56841783ed -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/npow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@34e050eb1b1f5707e97d0224949efe56841783ed -
Trigger Event:
push
-
Statement type: