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
Support Unpickling CachedQueryResults Created By Py2 #3234
Merged
phil-lopreiato
merged 6 commits into
the-blue-alliance:py3
from
phil-lopreiato:py2-unpickle
Jan 1, 2021
Merged
Support Unpickling CachedQueryResults Created By Py2 #3234
phil-lopreiato
merged 6 commits into
the-blue-alliance:py3
from
phil-lopreiato:py2-unpickle
Jan 1, 2021
Conversation
This file contains 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
phil-lopreiato
changed the title
Support Unpickling CachedQueryResults Created By Py2
[wip] Support Unpickling CachedQueryResults Created By Py2
Dec 30, 2020
Codecov Report
@@ Coverage Diff @@
## py3 #3234 +/- ##
==========================================
+ Coverage 95.41% 95.48% +0.06%
==========================================
Files 361 367 +6
Lines 15865 16328 +463
==========================================
+ Hits 15137 15590 +453
- Misses 728 738 +10
Continue to review full report at Codecov.
|
phil-lopreiato
changed the title
[wip] Support Unpickling CachedQueryResults Created By Py2
Support Unpickling CachedQueryResults Created By Py2
Jan 1, 2021
phil-lopreiato
added a commit
that referenced
this pull request
Jan 9, 2021
This is the followup to #3234 It implements the write side, as well as some other bug fixes and cleanup. Also adds tests to assert that we can do a round trip serialize + deserialize and get the original value back. This includes some of the serialization code from the legacy runtime, which maintains its original license. I made the basic modifications to port it to py3, and left links to where to find the original to make future debugging easier. I also verified that I could take pickles generated by these unit tests and be able to deserialize them in the legacy app's console. After fixing imports, of course. Which we'll need to add to the py2 code anyway.
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.
This is a rabbit hole, as pickling across python versions is a terrible idea.
However, we can hack around a few of the major issues that come up. Start by adding a repro unit test that tries to load+depickle a value I got from the datastore admin tool for something written by the py2 app.
Next, we need to fix:
Unpickler
. See this answer.encoding="bytes"
. We can do this in our custom unpickler too. Plus there's this whole thing about unpicklingdatetimes
. See this answer.__getstate__
and__setstate
on the baseModel
class. Since the py3 compatible ndb library does not do this, unpickling them will fail. I filed Can't Unpickle Models Pickled by Legacy Library googleapis/python-ndb#587 in hope of working with upstream to fix this, but if not, we can potentially hack around it ourselves by manually deserializing the protobuf and setting the field ourselves.WARNING: After this, we should be able to read data written by the legacy app, but we can not yet write data that the legacy app can read. So after this, when we re-enable
CachedQueryResult
, we'll have to make sure that we don't write anything to the datastore.