Consider the following usage:
In [49]: class MyClass(dict):
...: def __init__(self,a):
...: self.a = a
...: def get(self):
...: return a
...:
In [50]: a = MyClass(10)
In [51]: @delayed(pure=True)
...: def myFunc(a):
...: return a
...:
In [52]: myFunc(a)
Out[52]: Delayed('myFunc-96ed02ea2192c363a45cec74ef5eaefb')
In [53]: myFunc(a)
Out[53]: Delayed('myFunc-96ed02ea2192c363a45cec74ef5eaefb')
In [54]: a = MyClass(10)
In [55]: myFunc(a)
Out[55]: Delayed('myFunc-96ed02ea2192c363a45cec74ef5eaefb')
In [56]: a.a = 1000
In [57]: myFunc(a)
Out[57]: Delayed('myFunc-96ed02ea2192c363a45cec74ef5eaefb')
In [58]: a['foo'] = 'bar'
In [59]: myFunc(a)
Out[59]: Delayed('myFunc-bf4162396d43f090e476de70d30de251')
My intention here is to tell dask which parameters to use when calculating function purity for caching purposes. This is useful in cases, for example, if the object has subroutines which has some data retrieval methods and these methods in turn depend on internal parameters (plotting parameters, for instance). If I pass this data object through dask, I would obviously not want the key of the delayed instance to change upon changing these paramters. However, I do want the data itself to be saved (basically, self[key] = val
here, which is what is happening).
This seems to do the trick.
I want to ask, will this behaviour be supported? Or is there a better way? Or this not compatible with dask's vision? thanks!