I want to use delayed function from DASK. Unfortunately, Using delayed function on modules with multiple return values is not clear to me. For example, if I run following snippet, there is no way to point out to the first return value of inc module after computing final result.
from dask import delayed
from time import sleep
def inc(x):
sleep(1)
return x+1, x+2
def add(x, y):
sleep(1)
return x + y
x = delayed(inc)(1)
y = delayed(inc)(2)
z = delayed(add)(x[0], y[0])
print(z.compute())
Correctly, the result of this snippet is as follow. This indicates pointing is working.
(3, 5)
However, I can not read x return's value.
%%time
result=z.compute()
print('Result is :', result)
print(x[0])
output:
Result is : 5
Delayed('getitem-f80cf501fe43d6cbd50e0bec71c91c12')
CPU times: user 7.46 ms, sys: 2.13 ms, total: 9.59 ms
Wall time: 2 s
It would be nice to read delayed function's return value without computing them if they are already computed because of dependency.