如何使用 dask.distributed API 指定启动 Bokeh 网页界面的选项?

How to use dask.distributed API to specify the options for starting Bokeh web interface?

我正在尝试使用 dask.distributed Python API 来启动调度程序。 http://distributed.dask.org/en/latest/setup.html#using-the-python-api 中提供的示例按预期工作,但它没有提供有关如何提供启动 Bokeh Web 界面所需的选项的见解。

在查看 dask.distributed 源代码后,我了解到我需要使用 Scheduler(services={}) 提供 Bokeh 选项。不幸的是,我未能找到 services={}.

的正确字典格式

下面是dask scheduler函数的代码。

import dask.distributed as daskd
import tornado
import threading

def create_dask_scheduler(scheduler_options_dict):
    # Define and start tornado
    tornado_loop = tornado.ioloop.IOLoop.current()
    tornado_thread = threading.Thread(target=tornado_loop.start,daemon=True)
    tornado_thread.start()
    # Define and start scheduler
    dask_scheduler = daskd.Scheduler(loop=tornado_loop,synchronize_worker_interval=scheduler_options_dict['synchronize_worker_interval'],allowed_failures=scheduler_options_dict['allowed_failures'],services=scheduler_options_dict['services'])
    dask_scheduler.start('tcp://:8786')
    return dask_scheduler

scheduler_options_dict = collections.OrderedDict()
scheduler_options_dict = {'synchronize_worker_interval':60,'allowed_failures':3,'services':{('http://hpcsrv',8787):8787}}
dask_scheduler = create_dask_scheduler(scheduler_options_dict)

我得到的错误是:

Exception in thread Thread-4: Traceback (most recent call last):
/uf5a/nbobolea/bin/anaconda2019.03_python3.7/envs/optimization/lib/python3.7/site-packages/ipykernel_launcher.py:18:
UserWarning: Could not launch service 'http‍://hpcsrv' on port 8787.
Got the following message: 'int' object is not callable
distributed.scheduler - INFO - Scheduler at:
tcp://xxx.xxx.xxx.xxx:8786

非常感谢您的帮助和见解。

你想要

'services': {('bokeh', dashboard_address): BokehScheduler, {}}

其中 dashboard_address 类似于 "localhost:8787",而 BokehSchedulerdistributed.bokeh.scheduler 中。您将需要在 Bokeh 服务器上阅读以查看可以在该空字典中传递哪些额外的 kwargs。