Skip to main content

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 @environment decorator:
@environment(vars={
    "AWS_ACCESS_KEY_ID": "XXXX",
    "AWS_SECRET_ACCESS_KEY": "YYYY"
})
@skypilot(cpus='2+')
@step
def my_step(self):
    ...
  • Secrets manager via the @secrets decorator.

If you are on the Outerbounds platform, authentication is handled automatically.

Things to Note

  • @skypilot cannot be combined with @kubernetes, @batch, or @slurm on the same step.
  • @parallel is not supported with @skypilot.
  • The minimum step timeout is 60 seconds.

Fin.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metaflow_skypilot-0.0.1.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metaflow_skypilot-0.0.1-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

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

Hashes for metaflow_skypilot-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e4443856ad00a538d7e0fe921c31935e9d3dae8772579145d4f0ec13cf7e72ac
MD5 4481870cbbe4670bac3836b44af0ff58
BLAKE2b-256 195175ed9f6eac001fae5abe1bf5876c52bc2df851a342f196e79914ecafc5bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaflow_skypilot-0.0.1.tar.gz:

Publisher: publish.yml on outerbounds/metaflow-skypilot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file metaflow_skypilot-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for metaflow_skypilot-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d1d33cb2da7e2d66286f0eb2e599bace475fd4e940ccadcd3621d990ad214f1
MD5 35a7630e108c867345ee61596dc4b31e
BLAKE2b-256 d65ec84894fe53670be300aa08e7e64ea9f1df65d829313b8efe1e82b7bec2c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaflow_skypilot-0.0.1-py3-none-any.whl:

Publisher: publish.yml on outerbounds/metaflow-skypilot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page