如何从 Dask 调度程序获取仪表板地址

How to get the dashboard address from the Dask scheduler

启动dask分布式本地集群时,可以为dashboard_address设置随机端口或地址。

如果以后得到scheduler对象。有没有办法提取仪表板的地址。

我有这个:

cluster = dask.distributed.LocalCluster(scheduler_port=0,
                                        dashboard_address='localhost:0')
scheduler = dask.distributed.Client(cluster, set_as_default=False)
scheduler_info = scheduler.scheduler_info()
logger.info('Scheduler: %s', scheduler_info['address'])
logger.info('Status Port: %s', scheduler_info['services']['dashboard'])

但是那只能获取dashboard的端口,不能获取dashboard的IP。如果我将仪表板地址放在调度程序以外的单独 IP 上,似乎很难知道它绑定到哪个 IP。

如果您定义了 dashboard_address,您可以通过以下方式获取该信息:

In [1]: from dask.distributed import LocalCluster, Client

In [2]: cluster = LocalCluster(dashboard_address='172.22.1.26:8782')

In [3]: cluster.scheduler.services['dashboard'].server.address
Out[3]: '172.22.1.26'

In [4]: cluster.scheduler.services['dashboard'].server.port
Out[4]: 8782

注意:当未定义 dashboard_address 时,仪表板将位于调度程序地址——通常是 127.0.0.1

# if you have the cluster object
cluster.dashboard_link

# or if you have a client
client.dashboard_link