我正在尝试使用 Dask.delayed 来并行计算函数。 函数 BL.BLSN 有 1 个字符串参数。
runs=['forcing.dat','forcing.dat','forcing.dat','forcing.dat','forcing.dat','forcing.dat']
dfs = [delayed(BL.BLSN)(fn) for fn in runs]
当我打印 dfs 时,我得到了延迟对象的列表。这正是我所期待的。
[Delayed('BLSN-630cb6bf-7104-4d41-b5fb-544116fec7ed'), Delayed('BLSN-150a5d45-073a-48af-af03-6e85f809617c'), Delayed('BLSN-484e7d71-af09-4a1f-be28-42358ef745e9'), Delayed('BLSN-2f2f2cc1-76bc-4c29-839d-091255556f35'), Delayed('BLSN-8aae0a06-d607-4a98-89a7-cfd2c877bf11'), Delayed('BLSN-f0131a69-2bfd-4153-94c1-2d3ef4973772')
]
但是,当我尝试时:
dfs.compute()
我得到:
AttributeError: 'list' object has no attribute 'compute'
对列表中的每个对象进行计算操作的最佳方式是什么?
最佳答案
关于python - 在Python中使用Dask并行运行函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58664548/