Mark Reyes
11/01/2024, 6:30 AMMarvin
11/01/2024, 6:30 AM.submit
method for asynchronous execution. Here's a basic example:
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.