Prefect Collection for interacting with Dask in your flows: prefect-dask

Docs

https://prefecthq.github.io/prefect-dask/

Code

Examples

from prefect import flow, task
from prefect_dask.task_runners import DaskTaskRunner
from typing import List

@task
def say_hello(name):
    print(f"hello {name}")

@task
def say_goodbye(name):
    print(f"goodbye {name}")

@flow(task_runner=DaskTaskRunner())
def greetings(names: List[str]):
    for name in names:
        say_hello(name)
        say_goodbye(name)

if __name__ == "__main__":
    greetings(["arthur", "trillian", "ford", "marvin"])

# truncated output
...
goodbye trillian
goodbye arthur
hello trillian
hello ford
hello marvin
hello arthur
goodbye ford
goodbye marvin
...

1 Like