简体   繁体   中英

Force a Dask Delayed object to compute all parameters before applying the function

I am really enjoying using Dask.

Is there a way that I can force a Delayed object to require all it's arguments to be computed before applying the delayed function?

easy example (the use-case is more interesting with a collection):

def inc(x, y):
    return x + y

dinc = dask.delayed(inc, pure=True)

to something like

def inc(x, y):
    if hasattr(x, compute):
        x = x.compute()
    if hasattr(y, compute):
        y = y.compute()
    return x + y

dinc = dask.delayed(inc, pure=True)

In this way the function will act according to a reduce pattern. Thanks!

Dask.delayed automatically does this. Any delayed object or dask collection (array, dataframe, bag) will be computed before they enter the delayed function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM