rohdesamuel commented on a change in pull request #11503:
URL: https://github.com/apache/beam/pull/11503#discussion_r424735647
##########
File path: sdks/python/apache_beam/runners/direct/direct_runner.py
##########
@@ -234,7 +234,89 @@ def get_replacement_transform(self, transform):
from apache_beam.runners.direct.test_stream_impl import
_ExpandableTestStream
return _ExpandableTestStream(transform)
+ class GroupByKeyPTransformOverride(PTransformOverride):
+ """A ``PTransformOverride`` for ``GroupByKey``.
+
+ This replaces the Beam implementation as a primitive.
+ """
+ def matches(self, applied_ptransform):
+ # Imported here to avoid circular dependencies.
+ # pylint: disable=wrong-import-order, wrong-import-position
+ from apache_beam.transforms.core import GroupByKey
+ if (isinstance(applied_ptransform.transform, GroupByKey) and
+ not getattr(applied_ptransform.transform, 'override', False)):
+ self.input_type = applied_ptransform.inputs[0].element_type
+ return True
+ return False
+
+ def get_replacement_transform(self, ptransform):
+ # Imported here to avoid circular dependencies.
+ # pylint: disable=wrong-import-order, wrong-import-position
+ from apache_beam.transforms.core import GroupByKey
+
+ # Subclass from GroupByKey to inherit all the proper methods.
Review comment:
Yep, I took out the subclass dependency and simplified the override
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]