-
Notifications
You must be signed in to change notification settings - Fork 153
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
Conversation
This pull request was exported from Phabricator. Differential Revision: D37417556 |
1 similar comment
This pull request was exported from Phabricator. Differential Revision: D37417556 |
Summary: 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 Differential Revision: D37417556 fbshipit-source-id: 4877a7de9a2060f6da499dc26b7de64b4a200cd7
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 Differential Revision: D37417556 fbshipit-source-id: 7213ee84b34092e0c2cf293ff8bf1dc56659fc83
This pull request was exported from Phabricator. Differential Revision: D37417556 |
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 Differential Revision: D37417556 fbshipit-source-id: c17e475bde703f2f55af140f2155d41efb45f049
This pull request was exported from Phabricator. Differential Revision: D37417556 |
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
Summary: Pull Request resolved: pytorch#80232 X-link: pytorch/data#547 Fixes pytorch/data#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#79344 Test Plan: ``` buck test //caffe2/test:datapipe buck test //pytorch/data/test:tests ``` Tested in OSS ``` # PT pytest test/test_datapipe.py -v # TD pytest test/test_iterdatapipe.py -v pytest test/test_mapdatapipe.py -v pytest test/test_serialization.py -v # TV pytest test/test_prototype_builtin_datasets.py -v ``` Reviewed By: NivekT Differential Revision: D37417556 fbshipit-source-id: 6fae4059285b8c742feda739cc5fe590b2e20c5e
This pull request was exported from Phabricator. Differential Revision: D37417556 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CI failure is due to pytorch/pytorch#80232 isn't in nightly?
@NivekT You are right. As long as the tests in phabricator pass, we should be fine. |
Summary: X-link: pytorch/data#547 Fixes pytorch/data#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 #79344 Test Plan: CI on PyTorch and TorchData Manually validated the tests from TorchVision Differential Revision: D37417556 Pull Request resolved: #80232 Approved by: https://github.com/NivekT
Summary: Pull Request resolved: #80232 X-link: pytorch/data#547 Fixes pytorch/data#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 #79344 Test Plan: ``` buck test //caffe2/test:datapipe buck test //pytorch/data/test:tests ``` Tested in OSS ``` # PT pytest test/test_datapipe.py -v # TD pytest test/test_iterdatapipe.py -v pytest test/test_mapdatapipe.py -v pytest test/test_serialization.py -v # TV pytest test/test_prototype_builtin_datasets.py -v ``` Reviewed By: NivekT Differential Revision: D37417556 fbshipit-source-id: 388d04004da43aaf14729cbe465a9247bef6c780
Summary:
Fixes #538
This Diff also fixes the Error introduced by pytorch/pytorch#79344
Differential Revision: D37417556