Prefect Collection for interacting with Ray in your flows: prefect-ray

Docs

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

Code

Examples

from prefect import flow, task
from prefect_ray.task_runners import RayTaskRunner
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=RayTaskRunner())
def greetings(names: List[str]):
    for name in names:
        say_hello(name)
        say_goodbye(name)


greetings(["arthur", "trillian", "ford", "marvin"])

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