如何查找Dask分布式函数调用的concurrent.future输入参数

问题描述 投票:0回答:2

我正在使用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
2个回答
1
投票

期货不会持有他们的投入。你可以自己做。

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

futures[future] = args

1
投票

未来只知道在调度程序上唯一已知的密钥。在提交时,如果它具有依赖关系,则会暂时找到它们并将其发送到调度程序,但如果保留在本地则不会复制。

你所追求的模式听起来更像是delayed,它保持着它的图形,而且client.compute(delayed_thing)确实会回归未来。

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

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

© www.soinside.com 2019 - 2024. All rights reserved.