torchdata issues a warning about pickle when we use lambdas (which is great!)
Another kind of function that isn't compatible with pickle are local functions. Would it be possible to throw the same warning there?
import torchdata
import pickle
def make_dp():
def f(x): # local function, not pickleable
return x
return torchdata.datapipes.iter.IterableWrapper(range(40)).map(f)
dp = make_dp() # no warning
f = "/tmp/dp"
pickle.dump(dp, open(f, "wb")) # fails