如何将多个参数传递给dask.Distributed.Client().map? [英] How to pass multiple arguments to dask.distributed.Client().map?
本文介绍了如何将多个参数传递给dask.Distributed.Client().map?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import dask.distributed
def f(x, y):
return x, y
client = dask.distributed.Client()
client.map(f, [(1, 2), (2, 3)])
不起作用。
[<Future: status: pending, key: f-137239e2f6eafbe900c0087f550bc0ca>,
<Future: status: pending, key: f-64f918a0c730c63955da91694fcf7acc>]
distributed.worker - WARNING - Compute Failed
Function: f
args: ((1, 2))
kwargs: {}
Exception: TypeError("f() missing 1 required positional argument: 'y'",)
distributed.worker - WARNING - Compute Failed
Function: f
args: ((2, 3))
kwargs: {}
Exception: TypeError("f() missing 1 required positional argument: 'y'",)
推荐答案
您没有完全的签名权限-可能文档不清楚(欢迎提出建议)。Client.map()
为提交的每个任务获取(数量可变的)参数集,而不是一个可迭代的东西。您应该将其表述为
client.map(f, (1, 2), (2, 3))
或者,如果您想更接近您的原始模式
client.map(f, *[(1, 2), (2, 3)])
这篇关于如何将多个参数传递给dask.Distributed.Client().map?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文