Uh oh!
There was an error while loading. Please reload this page.
Restore CloudPickler-scoped globals namespace isolation for pickled functions - #240
Conversation
A bit of background: this PR restores the behavior of cloudpickle from before 0.6.0. In 0.6.0 and 0.6.1 we changed the dynamic module globals handling behavior as we thought it was a bug (lack of consistency with how globals are handled in non-dynamic modules) but user feedback including #214 revealed that the new behavior is surprising/annoying for most users. In #216 we explored the possibility of introducing of a switch on the So to keep things simple, this PR hardcodes the |
ogrisel
commented
Jan 30, 2019
I agree, please feel free to push an empty commit with the |
The failure comes from Edit: the next build passed, so indeed it looks like a random failure. |
Codecov Report
@@ Coverage Diff @@## master #240 +/- ##
==========================================
- Coverage 85.39% 84.91% -0.49%
==========================================
Files 1 1 Lines 589 570 -19 Branches 118 112 -6 ==========================================
- Hits 503 484 -19
Misses 63 63 Partials 23 23
Continue to review full report at Codecov.
|
ogrisel
left a comment
There was a problem hiding this comment.
LGTM. Just a few comments:
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
mitar
commented
Jan 30, 2019
@suquark, can you check this? |
Uh oh!
There was an error while loading. Please reload this page.
suquark
commented
Jan 31, 2019
Uh oh!
There was an error while loading. Please reload this page.
pcmoritz
commented
Feb 6, 2019
This doesn't seem to fix the issue fully for us. Not sure what is going on, do you have an idea @suquark? |
@pcmoritz sorry, I still had a couple fixes to do that I thought I already pushed. This PR now reverts |
pcmoritz
commented
Feb 6, 2019
@pierreglaser Great, I re-ran the Ray test suite on top of your latest commits and it seems to be working now. Thanks a lot for the fix :) |
ogrisel
left a comment
There was a problem hiding this comment.
First pass at reviewing the new version of this PR.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-Authored-By: pierreglaser <pierreglaser@msn.com>
Co-Authored-By: pierreglaser <pierreglaser@msn.com>
13afdd2 to
f4f15e3CompareHere is a gist that loads "old" (e.g created using PS: sorry about the ugly force push, i forgot I resolved some conflicts in the browser... |
Uh oh!
There was an error while loading. Please reload this page.
ogrisel
commented
Feb 7, 2019
@pierreglaser please launch downstream CI on this PR to check that we have not broken anything. |
| variables when loaded in their new environment. This restores the (previously | ||
| untested) behavior of cloudpickle prior to changes done in 0.5.4 for | ||
| functions defined in the `__main__` module, and 0.6.0/1 for other dynamic | ||
| functions. |
There was a problem hiding this comment.
There is no "override" anymore because we create a new empty namespace each time. May I suggest the following:
- Global variables referenced by functions pickled by cloudpickle are now
unpickled in a new and isolated namespace scoped by the CloudPickler instance. This restores the (previously untested) behavior of cloudpickle prior to changes
done in 0.5.4 for functions defined in the `__main__` module, and 0.6.0/1 for
other dynamic functions.
There was a problem hiding this comment.
Yes you are right, this was stale. I'll let the downstream integration test finish before pushing a new commit.
ogrisel
commented
Feb 7, 2019
You can trigger downstream CI again, I merged your PR to fix the broken loky test. |
ogrisel
left a comment
There was a problem hiding this comment.
+1 for merge once the downstream CI has completed and the changelog is updated.
ogrisel
commented
Feb 7, 2019
Merged. Thanks for your work @pierreglaser! Thanks for your feedback @pcmoritz! |
## What changes were proposed in this pull request? After upgrading cloudpickle to 0.6.1 at #20691, one regression was found. Cloudpickle had a critical cloudpipe/cloudpickle#240 for that. Basically, it currently looks existing globals would override globals shipped in a function's, meaning: **Before:** ```python >>> def hey(): ... return "Hi" ... >>> spark.range(1).rdd.map(lambda _: hey()).collect() ['Hi'] >>> def hey(): ... return "Yeah" ... >>> spark.range(1).rdd.map(lambda _: hey()).collect() ['Hi'] ``` **After:** ```python >>> def hey(): ... return "Hi" ... >>> spark.range(1).rdd.map(lambda _: hey()).collect() ['Hi'] >>> >>> def hey(): ... return "Yeah" ... >>> spark.range(1).rdd.map(lambda _: hey()).collect() ['Yeah'] ``` Therefore, this PR upgrades cloudpickle to 0.8.0. Note that cloudpickle's release cycle is quite short. Between 0.6.1 and 0.7.0, it contains minor bug fixes. I don't see notable changes to double check and/or avoid. There is virtually only this fix between 0.7.0 and 0.8.1 - other fixes are about testing. ## How was this patch tested? Manually tested, tests were added. Verified unit tests were added in cloudpickle. Closes#23904 from HyukjinKwon/SPARK-27000. Authored-by: Hyukjin Kwon <gurwls223@apache.org> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
This PR changes the way globals collisions are handled:
The tests are accordingly updated. Note that #216 did not add any new tests, but simply parametrized existing ones.
EDIT: For the record, the previous behavior (silently override globals shipped with the functions) introduced regressions reported by users of downstream projects. Here is the list of issues related to it:
@ogrisel it is a good PR to trigger the new downstream integration builds!