Repository navigation
Fix worker deserialization of interactive class methods - #1942
Open
harshitdeora wants to merge 1 commit into
Open
harshitdeora wants to merge 1 commit into
harshitdeora wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1942 +/- ##
==========================================
+ Coverage 93.54% 93.55% +0.01%
==========================================
Files 46 46
Lines 8655 8660 +5
==========================================
+ Hits 8096 8102 +6
+ Misses 559 558 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1732.
When a class defined in
__main__keeps a bound class method in its state, Loky'sgetattrbased method reducer can try to find that method while the class is still being reconstructed in a worker. Deserialization fails withAttributeError, surfaced byParallelasBrokenProcessPool. Pydantic models with@model_validator(mode='before')hit this path.Keep Cloudpickle's own method reducer when Cloudpickle is the selected Loky pickler. It reconstructs the method from its function and bound instance, so it does not require the method to be discoverable on a partially restored class. Other Loky reducers and the non Cloudpickle pickler path stay as before.
The new subprocess regression uses a small class with a bound method in class state, without requiring Pydantic as a test dependency. On unchanged
main, the exact test fails withAttributeError: validate; with this commit it passes. The issue's Pydantic reproducer likewise failed on base and returned[1001001]with the fix on Windows / Python 3.13 / Pydantic 2.14.3.Validation: 4 related interactive serialization tests passed (1 skipped), plus
test_parallel_picklingandtest_cloudpickle_wrapperpassed. All applicable pre-commit hooks andgit diff --checkpassed. The broadertest_parallel.pyrun was stopped after initial passing cases because of its runtime; the full suite was not completed locally.