Dask - 如何连接到正在运行的集群调度程序并访问“total_occupancy”?

Dav*_*idK 6 python scheduler dask jupyter-notebook

我使用以下命令从 Jupyter 笔记本创建本地集群:

from dask.distributed import Client, LocalCluster

cluster = LocalCluster(n_workers=24)
c = Client(cluster)
Run Code Online (Sandbox Code Playgroud)

当内核被占用时(计算操作)是否可以从另一台笔记本连接?

例如,我的目标是访问“total_occupancy”。

MRo*_*lin 4

正如 @moshevi 所建议的,您可以通过提供地址来连接到调度程序。

client = Client("address-of-scheduler")
Run Code Online (Sandbox Code Playgroud)

然后就可以使用client.run_on_scheduler命令对远程调度器执行操作

client.run_on_scheduler(lambda dask_scheduler: dask_scheduler.total_occupancy)
Run Code Online (Sandbox Code Playgroud)

https://docs.dask.org/en/latest/futures.html#distributed.Client.run_on_scheduler