Skip to content

Instantly share code, notes, and snippets.

@jcrist
Last active December 17, 2021 19:48
Show Gist options
  • Save jcrist/58c8ab358f998129c536e80dc0c19f04 to your computer and use it in GitHub Desktop.
Save jcrist/58c8ab358f998129c536e80dc0c19f04 to your computer and use it in GitHub Desktop.
Prefect Examples with RunConfigs and Executors
from prefect import Flow
from prefect.storage import S3
from prefect.run_configs import ECSRun
from prefect.executors import DaskExecutor
with Flow("example") as flow:
...
flow.storage = S3("my-flows")
flow.run_config = ECSRun() # Run job on ECS instead of locally
flow.executor = DaskExecutor(
cluster_class="dask_cloudprovider.aws.FargateCluster",
cluster_kwargs={"image": "prefecthq/prefect", "n_workers": 5}
)
from prefect import Flow
from prefect.storage import S3
from prefect.run_configs import ECSRun
from prefect.executors import LocalDaskExecutor
with Flow("example") as flow:
...
flow.storage = S3("my-flows")
flow.run_config = ECSRun(cpu="2 vcpu", memory="4 GB") # increase resource limits
flow.executor = LocalDaskExecutor(num_workers=8) # Use a local dask cluster
from prefect import Flow
from prefect.storage import S3
from prefect.run_configs import LocalRun
from prefect.executors import DaskExecutor
with Flow("example") as flow:
...
flow.storage = S3("my-flows")
flow.run_config = LocalRun()
flow.executor = DaskExecutor(
cluster_class="dask_cloudprovider.aws.FargateCluster",
cluster_kwargs={"image": "prefecthq/prefect", "n_workers": 5}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment