【问题标题】:How to find the concurrent.future input arguments for a Dask distributed function call如何找到 Dask 分布式函数调用的 concurrent.future 输入参数
【发布时间】:2019-02-20 08:32:19
【问题描述】:

我正在使用 Dask 将工作分配到集群。我正在创建一个集群并调用.submit() 向调度程序提交一个函数。它返回一个 Futures 对象。我试图弄清楚一旦完成后如何获取该未来对象的输入参数。

例如:

from dask.distributed import Client
from dask_yarn import YarnCluster

def somefunc(a,b,c ..., n ):
    # do something
    return


cluster = YarnCluster.from_specification(spec)
client = Client(cluster)

future = client.submit(somefunc, arg1, arg2, ..., argn)

# ^^^ how do I obtain the input arguments for this future object?
# `future.args` doesn't work

【问题讨论】:

    标签: dask dask-distributed


    【解决方案1】:

    期货不会保留其输入。不过你可以自己做。

    futures = {}
    future = client.submit(func, *args)
    
    futures[future] = args
    

    【讨论】:

    • 有没有办法用client.map()做到这一点?
    【解决方案2】:

    未来只知道它在调度程序上唯一知道的密钥。提交时,如果有依赖,会暂时找到并发送到调度器,但如果保存在本地则没有副本。

    您所追求的模式听起来更像delayed,它保留了它的图表,并且确实client.compute(delayed_thing) 返回了一个未来。

    d = delayed(somefunc)(a, b, c)
    future = client.compute(d)
    dict(d.dask)  # graph of things needed by d
    

    您可以直接与调度程序通信以查找某些键的依赖关系,这些键通常也是键,因此对图形进行逆向工程,但这听起来不是一条好路,所以我不会尝试在这里描述一下。

    【讨论】:

      猜你喜欢
      • 2017-06-13
      • 1970-01-01
      • 1970-01-01
      • 2017-05-19
      • 2020-09-09
      • 2020-08-19
      • 1970-01-01
      • 2019-11-06
      • 2020-07-14
      相关资源
      最近更新 更多