具有(本地/多处理)分布的HighLevelGraph

时间:2019-04-29 23:13:29

标签: dask-distributed

如何在本地分布式设置中使用dask.highlevelgraph.HighLevelGraph。

顺序计算

result = dask.get(some_high_level_graph, [some_targets])

有效。


import dask
from dask.highlevelgraph import HighLevelGraph as CG

# from dask import distributed as ddist

def inc(i):
    return i + 1

def add(a, b):
    return a + b

def mult(a, b):
    return a * b

wf = CG(
    layers = {
        1: {
            'inc': (inc, 1),
            'add': (add, 1, 'inc'),
        },
        2: {
            'mult': (mult, 3, 3)
        }
    },
    dependencies=[1, 2]
)

targets = ['add', 'mult']
r = dask.get(wf, targets)
print(r)

targets = ['mult']
r = dask.get(wf, targets)
print(r)

实际上,我想并行计算“ add”和“ mult”。

1 个答案:

答案 0 :(得分:0)

我能够自己解决问题。只需使用:

result = client.get(graph, targets)