prefect_dask.task_runners
Interface and implementations of the Dask 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:
DaskTaskRunner:
Classes
PrefectDaskFuture
A Prefect future that wraps a distributed.Future. This future is used
when the task run is submitted to a DaskTaskRunner.
Methods:
result
wait
DaskTaskRunner
A parallel task_runner that submits tasks to the dask.distributed scheduler.
By default a temporary distributed.LocalCluster is created (and
subsequently torn down) within the start() contextmanager. To use a
different cluster class (e.g.
dask_kubernetes.KubeCluster), you can
specify cluster_class/cluster_kwargs.
Alternatively, if you already have a dask cluster running, you can provide
the cluster object via the cluster kwarg or the address of the scheduler
via the address kwarg.
!!! warning “Multiprocessing safety”
Note that, because the DaskTaskRunner uses multiprocessing, calls to flows
in scripts must be guarded with if __name__ == "__main__": or warnings will
be displayed.
Args:
cluster: Currently running dask cluster; if one is not provider (or specified viaaddresskwarg), a temporary cluster will be created inDaskTaskRunner.start(). Defaults toNone.address: Address of a currently running dask scheduler. Defaults toNone.cluster_class: The cluster class to use when creating a temporary dask cluster. Can be either the full class name (e.g."distributed.LocalCluster"), or the class itself.cluster_kwargs: Additional kwargs to pass to thecluster_classwhen creating a temporary dask cluster.adapt_kwargs: Additional kwargs to pass tocluster.adaptwhen creating a temporary dask cluster. Note that adaptive scaling is only enabled ifadapt_kwargsare provided.client_kwargs: Additional kwargs to use when creating adask.distributed.Client.performance_report_path: Path where the Dask performance report will be saved. If not provided, no performance report will be generated.