-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BEAM-13052] Implement ProtoPlusCoder and add it to the default options #15817
Conversation
R: @chamikaramj |
cc: @robertwb |
Codecov Report
@@ Coverage Diff @@
## master #15817 +/- ##
==========================================
+ Coverage 83.53% 83.61% +0.07%
==========================================
Files 445 445
Lines 61385 61356 -29
==========================================
+ Hits 51279 51301 +22
+ Misses 10106 10055 -51
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.
Thanks!
return value._pb.SerializePartialToString(deterministic=True) | ||
|
||
def decode(self, value): | ||
return self.proto_plus_type.deserialize(value) |
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.
To confirm, the API to be used here is different from ProtoCoder above (which uses 'ParseFromString') ?
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.
This is the preferred way to deserialize proto plus types. I can't use the serialize method on line 321 because it is not deterministic, so must drop down to the protobuf interface to do so.
@@ -310,6 +311,19 @@ def encode(self, value): | |||
return value.SerializePartialToString(deterministic=True) | |||
|
|||
|
|||
class ProtoPlusCoderImpl(SimpleCoderImpl): |
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.
Do you think this could affect the performance characteristics of existing Python GCP connectors ?
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.
It shouldn't- either they're currently not resolving a coder (and broken) or theyre already registering a custom coder (and this is ignored) or they're not using proto-plus types in their interfaces.
|
||
@classmethod | ||
def from_type_hint(cls, typehint, unused_registry): | ||
if issubclass(typehint, proto.Message): |
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.
To clarify, currently such messages get encoded using the default coder ?
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.
Yes. Currently they fall back to picklecoder and fail to serialize the state.
|
||
|
||
class ProtoPlusCoderTest(unittest.TestCase): | ||
def test_proto_plus_coder(self): |
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.
Should we also add tests that include more complex field types (for example, maps) ?
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.
See line 140, this is tested.
Run PythonDocker PreCommit |
Run Portable_Python PreCommit |
1 similar comment
Run Portable_Python PreCommit |
Run PythonDocker PreCommit |
Run Portable_Python PreCommit |
Run PythonDocker PreCommit |
1 similar comment
Run PythonDocker PreCommit |
Seems like this is blocked by a dependency update ? 16:45:43 ERROR: Cannot install -r /tmp/base_image_requirements.txt (line 37) and protobuf==3.17.3 because these package versions have conflicting dependencies. |
Google cloud python client libraries use proto-plus for their protocol message wrappers, this coder enables them to be used in beam pipelines
Google cloud python client libraries use proto-plus for their protocol message wrappers, this coder enables them to be used in beam pipelines
Google cloud python client libraries use proto-plus for their protocol message wrappers, this coder enables them to be used in beam pipelines
Google cloud python client libraries use proto-plus for their protocol message wrappers, this coder enables them to be used in beam pipelines
Google cloud python client libraries use proto-plus for their protocol message wrappers, this coder enables them to be used in beam pipelines
f6670ad
to
b7bfcf3
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.
Thanks.
Thanks. LGTM. |
cc: @tvalentyn |
Run Python PostCommit 3.8 |
Run Python 3.8 PostCommit |
PostCommit failure is unrelated (https://issues.apache.org/jira/browse/BEAM-13218) |
…lt options (apache#15817)" on 2.35.0 branch. This reverts commit be22467.
Google cloud python client libraries use proto-plus for their protocol message wrappers, this coder enables them to be used in beam pipelines
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username
).[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
ValidatesRunner
compliance status (on master branch)Examples testing status on various runners
Post-Commit SDK/Transform Integration Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.