<@ULVA73B9P> prefect 2 can i use dask task runner and have a task call another task
m
@Marvin prefect 2 can i use dask task runner and have a task call another task
m
Yes, in Prefect 2.x you can use the Dask task runner to run tasks in parallel, and you can also have one task call another task. The Dask task runner is specifically designed for parallel execution and can be used in a flow by specifying it in the flow's decorator. For calling one task from another, Prefect supports this by allowing a task to invoke another task. You can achieve this using the
.submit
method for asynchronous execution. Here's a basic example:
Copy code
python
from prefect import flow, task
from prefect_dask import DaskTaskRunner

@task
def task_a():
    print("Task A")

@task
def task_b():
    print("Task B")

@flow(task_runner=DaskTaskRunner())
def my_flow():
    future_a = task_a.submit()
    future_b = task_b.submit(wait_for=[future_a])

if __name__ == "__main__":
    my_flow()
In this setup,
task_b
will wait for
task_a
to complete before it runs, thanks to the
wait_for
parameter. This example uses a flow configured with the
DaskTaskRunner
, which allows tasks to be distributed and executed in parallel, potentially on a Dask cluster. For more details, you can refer to the Prefect 2.x documentation on Dask Task Runner and task interactions.