Skypilot extension for Metaflow
Project description
SkyPilot extension for Metaflow
This extension adds support for executing steps in Metaflow flows on any cloud provider via SkyPilot.
Installation
pip install metaflow-skypilot
SkyPilot also requires cloud credentials to be configured. Follow the SkyPilot setup guide for your cloud provider.
Basic Usage
Add the @skypilot decorator to any step you want to run on the cloud:
from metaflow import FlowSpec, step, skypilot
class MyFlow(FlowSpec):
@step
def start(self):
self.next(self.train)
@skypilot(cpus='2+', memory='8+')
@step
def train(self):
# This step runs on cloud via SkyPilot
print("Training on the cloud!")
self.next(self.end)
@step
def end(self):
print("Done!")
if __name__ == '__main__':
MyFlow()
Resource Configuration
The @skypilot decorator accepts all sky.Resources parameters directly, an example with a few of them is given below:
@skypilot(
infra='aws',
cpus='4+',
memory='16+',
accelerators='A100:1',
)
@step
def gpu_step(self):
...
Reusing a Named Cluster
By default, each run provisions a fresh ephemeral cluster that is torn down after the job finishes. To reuse a persistent cluster across runs, pass a cluster_name:
@skypilot(
cpus='2+',
cluster_name='my-persistent-cluster',
)
@step
def my_step(self):
...
- Without
cluster_name: a new cluster is provisioned, runs the job, and is terminated after 10 idle minutes. - With
cluster_name: the cluster is reused across runs (auto-started if stopped). It stops automatically after 10 idle minutes but is not terminated — it will be restarted on the next run.
Each task always runs in an isolated working directory (~/metaflow/assets/<job_name>/) regardless of cluster type, so there are no filesystem clashes when reusing a cluster.
Using with @pypi
Use @pypi to install Python dependencies on the remote VM:
@skypilot(cpus='2+')
@pypi(python='3.9', packages={'numpy': '1.24.0', 'pandas': '2.0.0'})
@step
def my_step(self):
import numpy as np
...
Supplying Credentials
Cloud credentials for accessing the Metaflow datastore (e.g. S3) can be supplied in three ways:
- Instance IAM role / cloud identity: if the provisioned resource has access to the datastore via its cloud identity, no extra configuration is needed.
- Environment variables via the
@environmentdecorator:
@environment(vars={
"AWS_ACCESS_KEY_ID": "XXXX",
"AWS_SECRET_ACCESS_KEY": "YYYY"
})
@skypilot(cpus='2+')
@step
def my_step(self):
...
- Secrets manager via the
@secretsdecorator.
If you are on the Outerbounds platform, authentication is handled automatically.
Things to Note
@skypilotcannot be combined with@kubernetes,@batch, or@slurmon the same step.@parallelis not supported with@skypilot.- The minimum step timeout is 60 seconds.
Fin.
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_skypilot-0.0.1.tar.gz.
File metadata
- Download URL: metaflow_skypilot-0.0.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4443856ad00a538d7e0fe921c31935e9d3dae8772579145d4f0ec13cf7e72ac
|
|
| MD5 |
4481870cbbe4670bac3836b44af0ff58
|
|
| BLAKE2b-256 |
195175ed9f6eac001fae5abe1bf5876c52bc2df851a342f196e79914ecafc5bd
|
Provenance
The following attestation bundles were made for metaflow_skypilot-0.0.1.tar.gz:
Publisher:
publish.yml on outerbounds/metaflow-skypilot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaflow_skypilot-0.0.1.tar.gz -
Subject digest:
e4443856ad00a538d7e0fe921c31935e9d3dae8772579145d4f0ec13cf7e72ac - Sigstore transparency entry: 1039265588
- Sigstore integration time:
-
Permalink:
outerbounds/metaflow-skypilot@e05ea01852b531d49b655b6b1040cac78fd1ad1c -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/outerbounds
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e05ea01852b531d49b655b6b1040cac78fd1ad1c -
Trigger Event:
release
-
Statement type:
File details
Details for the file metaflow_skypilot-0.0.1-py3-none-any.whl.
File metadata
- Download URL: metaflow_skypilot-0.0.1-py3-none-any.whl
- Upload date:
- Size: 19.3 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 |
8d1d33cb2da7e2d66286f0eb2e599bace475fd4e940ccadcd3621d990ad214f1
|
|
| MD5 |
35a7630e108c867345ee61596dc4b31e
|
|
| BLAKE2b-256 |
d65ec84894fe53670be300aa08e7e64ea9f1df65d829313b8efe1e82b7bec2c8
|
Provenance
The following attestation bundles were made for metaflow_skypilot-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on outerbounds/metaflow-skypilot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaflow_skypilot-0.0.1-py3-none-any.whl -
Subject digest:
8d1d33cb2da7e2d66286f0eb2e599bace475fd4e940ccadcd3621d990ad214f1 - Sigstore transparency entry: 1039265701
- Sigstore integration time:
-
Permalink:
outerbounds/metaflow-skypilot@e05ea01852b531d49b655b6b1040cac78fd1ad1c -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/outerbounds
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e05ea01852b531d49b655b6b1040cac78fd1ad1c -
Trigger Event:
release
-
Statement type: