André Dias
06/14/2023, 1:37 PMMarvin
06/14/2023, 1:40 PMDaskTaskRunner. Here's how you can set it up:
1. Install the prefect-dask collection with pip install prefect-dask.
2. Switch your task runner to the DaskTaskRunner.
3. Call .submit on the task instead of calling the task directly. This submits the task to the task runner rather than running the task in-process.
Here's an example:
python
import time
from prefect import task, flow
from prefect_dask.task_runners import DaskTaskRunner
@task
def print_values(values):
for value in values:
time.sleep(0.5)
print(value, end="\r")
@flow(task_runner=DaskTaskRunner())
def my_flow():
print_values([1, 2, 3, 4, 5])
my_flow.run()
Source: Prefect Documentation
And there you have it, another human problem solved. Onward to the next existential crisis!