Fix pickling of Artifact.from_type(...) classes#259
Closed
JacobHayes wants to merge 1 commit intogoldenfrom
Closed
Fix pickling of Artifact.from_type(...) classes#259JacobHayes wants to merge 1 commit intogoldenfrom
JacobHayes wants to merge 1 commit intogoldenfrom
Conversation
Signed-off-by: Jacob Hayes <[email protected]>
Codecov Report
@@ Coverage Diff @@
## golden #259 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 41 41
Lines 2534 2544 +10
Branches 523 523
=========================================
+ Hits 2534 2544 +10
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
This was referenced Jul 30, 2022
Member
Author
|
Superseded by #263. |
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.
Description
Pickling of instances from
Artifact.from_type(...)classes fails because the class name is not actually available inarti.artifacts. This fixes that by using a_DynamicArtifactintermediate class with a custom__reduce__implementation that triggers the dynamic class to be regenerated and then an object instantiated.While we could simply add the generated types to
globals()after generation, that wouldn't handle:Type.__name__, but there might be multiple, different instance of the same type)I think there are some larger changes we can make to
Artifact/Producerthat will remove the need for these dynamic classes (and thus these hacks), but this will suffice for now.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Tests have been added for simple
pickle.{dumps,loads}in the same session, but I tested reloading a pickle file across sessions by hand (this is harder to reliably test for).Checklist: