水平扩展
跟随终端演示:
cd examples/tutorial python 06_parallel_execution.py
让我们调整flow以将其task分配到Dask集群上并行执行。听起来可能要做很多,但实际上这是迄今为止最简单的调整:
from prefect.engine.executors import DaskExecutor
# ...task definitions...
# ...flow definition...
flow.run(executor=DaskExecutor())
这将启动系统上的Local Dask Cluster以并行化task。如果你已经在其他地方部署Dask集群,则可以通过在DaskExecutor构造函数中指定地址参数来使用该集群:
flow.run(
executor=DaskExecutor(
address='some-ip:port/to-your-dask-scheduler'
)
)
此外,只要提供的对象实现Executor接口(即Submit,Map和Wait函数,等同于Python的current.futures.Executor接口),可以定制化Executor以用于任何Prefect flow。这样可算是没有使用的天花板!
接下来,Prefect还能做什么呢?
Last updated
Was this helpful?