-
Notifications
You must be signed in to change notification settings - Fork 167
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
ENH Add a switch to override existing global variables #216
ENH Add a switch to override existing global variables #216
Conversation
Codecov Report
@@ Coverage Diff @@
## master #216 +/- ##
========================================
+ Coverage 84.92% 85% +0.07%
========================================
Files 1 1
Lines 577 580 +3
Branches 114 115 +1
========================================
+ Hits 490 493 +3
Misses 63 63
Partials 24 24
Continue to review full report at Codecov.
|
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.
Overall, this looks good.
I agree that override_existing_globals
should be passed through the state
to ensure compatibility.
Also, some nitpicks on the tests and comments.
@suquark |
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.
LGTM. just a typo.
0b818ac
to
0f49713
Compare
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.
+1 on my side besides the following comments.
I think we need a changelog entry targeting the 0.7 version.
if state.get('override_existing_globals', True): | ||
func.__globals__.update(state['globals']) | ||
else: | ||
for k, v in state['globals'].items(): |
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.
I would re-add the original comment for this block of the condition:
# Only set global variables that do not exist.
06f38ba
to
f6d6337
Compare
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.
LGTM, please add an entry to the change log (for 0.7).
07f8a3e
to
3f32518
Compare
@suquark could you please provide more details? Do you have a standalone example of one such problematic recursive function? |
Closing in favor of #240. |
Following #214.
This PR implements a switch called
override_existing_globals
, available fromCloudPickler.__init__
,cloudpickle.dumps
andcloudpickle.dump
.True
, the globals from a function originally created in the__main__
module, dynamic modules or in a nested scope override the globals of the function's module at unpickling time.False
, the existing variables in the function's module overrides the globals of those functions at unpickling time.