Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise warning for unpickable local function #547

Closed
wants to merge 1 commit into from

Commits on Jun 27, 2022

  1. Raise warning for unpickable local function (#80232)

    Summary:
    X-link: pytorch/pytorch#80232
    
    Pull Request resolved: pytorch#547
    
    Fixes pytorch#538
    - Improve the validation function to raise warning about unpickable function when either lambda or local function is provided to DataPipe.
    - The inner function from functools.partial object is extracted as well for validation
    - Mimic the behavior of pickle module for local lambda function: It would only raise Error for the local function rather than lambda function. So, we will raise warning about local function not lambda function.
    ```py
    
    >>> import pickle
    >>> def fn():
    ...     lf = lambda x: x
    ...     pickle.dumps(lf)
    >>> pickle.dumps(fn)
    AttributeError: Can't pickle local object 'fn.<locals>.<lambda>'
    ```
    
    This Diff also fixes the Error introduced by pytorch/pytorch#79344
    
    Reviewed By: NivekT
    
    Differential Revision: D37417556
    
    fbshipit-source-id: 6babb73a7daad470ec93c3bd0a0c08d71849d3c8
    ejguan authored and facebook-github-bot committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    ad3474e View commit details
    Browse the repository at this point in the history