Interface and implementations of the Ray Task Runner.
Task Runners
in Prefect are responsible for managing the execution of Prefect task runs.
Generally speaking, users are not expected to interact with
task runners outside of configuring and initializing them for a flow.Example:
import timefrom prefect import flow, task@taskdef shout(number): time.sleep(0.5) print(f"#{number}")@flowdef count_to(highest_number): for number in range(highest_number): shout.submit(number)if __name__ == "__main__": count_to(10)# outputs#0#1#2#3#4#5#6#7#8#9
A parallel task_runner that submits tasks to ray.
By default, a temporary Ray cluster is created for the duration of the flow run.
Alternatively, if you already have a ray instance running, you can provide
the connection URL via the address kwarg.
Args:
address (string, optional): Address of a currently running ray instance; if
one is not provided, a temporary instance will be created.
init_kwargs (dict, optional): Additional kwargs to use when calling ray.init.
Examples:
Using a temporary local ray cluster:
from prefect import flowfrom prefect_ray.task_runners import RayTaskRunner@flow(task_runner=RayTaskRunner())def my_flow(): ...