Skip to content

Warn about pickle-ablity when using dp.map(some_local_function) ? #538

@NicolasHug

Description

@NicolasHug

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions