🐛 FIX: Allow for dereferencing of saved instance state#191
🐛 FIX: Allow for dereferencing of saved instance state#191chrisjsewell merged 3 commits intodevelopfrom
Conversation
|
Good catch. Yes, this is a problem (for
Option 1. is almost certainly safer while option 2 is, in general, more performant (and potentially safer if we don't use a Do you have a preference? I'm fairly happy with either so long as there is just a sentence added to the |
|
Hmm, yeh I think (2) then, because I'm "scared" that deepcopy has the potential to introduce failures. |
Codecov Report
@@ Coverage Diff @@
## develop #191 +/- ##
===========================================
+ Coverage 90.94% 90.94% +0.01%
===========================================
Files 22 22
Lines 2922 2924 +2
===========================================
+ Hits 2657 2659 +2
Misses 265 265
Continue to review full report at Codecov.
|
When saving the context of the workchain, a reference to it is supplied which will change when the context is updated (see `ContextMixin.save_instance_state`). This is an issue for persisters that do not serialize the saved state, in particular the `InMemoryPersister`, since the context will not remain static. In this commit, we add a `dereference` option to the `Bundle.__init__`, which will deepcopy the returned save data, to remove pointers.
When saving the context of the workchain, a reference to it is supplied which will change when the context is updated (see `ContextMixin.save_instance_state`). This is an issue for persisters that do not serialize the saved state, in particular the `InMemoryPersister`, since the context will not remain static. In this commit, we add a `dereference` option to the `Bundle.__init__`, which will deepcopy the returned save data, to remove pointers.
When saving the context of the workchain, a reference to it is supplied which will change when the context is updated (see `ContextMixin.save_instance_state`). This is an issue for persisters that do not serialize the saved state, in particular the `InMemoryPersister`, since the context will not remain static. In this commit, we add a `dereference` option to the `Bundle.__init__`, which will deepcopy the returned save data, to remove pointers.
When saving the context of the workchain, a reference to it is supplied which will change when the context is updated (see `ContextMixin.save_instance_state`). This is an issue for persisters that do not serialize the saved state, in particular the `InMemoryPersister`, since the context will not remain static. In this commit, we add a `dereference` option to the `Bundle.__init__`, which will deepcopy the returned save data, to remove pointers.
As a toy example:
This obviously won't affect Persisters that serialize the data, but it is definitely a bug in this instance.
Strictly we should use
copy.deepcopy, but this could run into issues if a value was not pickleable, and then I'm not sure how exceptions should be handled