[
https://issues.apache.org/jira/browse/BEAM-7961?focusedWorklogId=377892&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-377892
]
ASF GitHub Bot logged work on BEAM-7961:
----------------------------------------
Author: ASF GitHub Bot
Created on: 27/Jan/20 22:54
Start Date: 27/Jan/20 22:54
Worklog Time Spent: 10m
Work Description: chamikaramj commented on pull request #10051:
[BEAM-7961] Add tests for all runner native transforms for XLang
URL: https://github.com/apache/beam/pull/10051#discussion_r371527681
##########
File path:
sdks/python/apache_beam/runners/portability/expansion_service_test.py
##########
@@ -75,39 +88,139 @@ def from_runner_api_parameter(payload, unused_context):
return FilterLessThanTransform(payload.decode('utf8'))
[email protected]_urn('simple', None)
-class SimpleTransform(ptransform.PTransform):
[email protected]_urn(TEST_PREFIX_URN, None)
[email protected]_output_types(unicode)
+class PrefixTransform(ptransform.PTransform):
+ def __init__(self, payload):
+ self._payload = payload
+
def expand(self, pcoll):
- return pcoll | 'TestLabel' >> beam.Map(lambda x: 'Simple(%s)' % x)
+ return pcoll | 'TestLabel' >> beam.Map(
+ lambda x: '{}{}'.format(self._payload, x))
def to_runner_api_parameter(self, unused_context):
- return 'simple', None
+ return TEST_PREFIX_URN, None
@staticmethod
- def from_runner_api_parameter(unused_parameter, unused_context):
- return SimpleTransform()
+ def from_runner_api_parameter(payload, unused_context):
+ return PrefixTransform(parse_string_payload(payload)['data'])
[email protected]_urn('multi', None)
[email protected]_urn(TEST_MULTI_URN, None)
class MutltiTransform(ptransform.PTransform):
def expand(self, pcolls):
return {
'main':
(pcolls['main1'], pcolls['main2'])
| beam.Flatten()
| beam.Map(lambda x, s: x + s,
- beam.pvalue.AsSingleton(pcolls['side'])),
- 'side': pcolls['side'] | beam.Map(lambda x: x + x),
+ beam.pvalue.AsSingleton(pcolls['side'])
+ ).with_output_types(unicode),
+ 'side': pcolls['side'] | beam.Map(
+ lambda x: x + x).with_output_types(unicode),
}
def to_runner_api_parameter(self, unused_context):
- return 'multi', None
+ return TEST_MULTI_URN, None
@staticmethod
def from_runner_api_parameter(unused_parameter, unused_context):
return MutltiTransform()
[email protected]_urn(TEST_GBK_URN, None)
+class GBKTransform(ptransform.PTransform):
+ def expand(self, pcoll):
+ return pcoll | 'TestLabel' >> beam.GroupByKey()
+
+ def to_runner_api_parameter(self, unused_context):
+ return TEST_GBK_URN, None
+
+ @staticmethod
+ def from_runner_api_parameter(unused_parameter, unused_context):
+ return GBKTransform()
+
+
[email protected]_urn(TEST_CGBK_URN, None)
+class CoGBKTransform(ptransform.PTransform):
+ class ConcatFn(beam.DoFn):
+ def process(self, element):
+ (k, v) = element
+ return [(k, v['col1'] + v['col2'])]
+
+ def expand(self, pcoll):
+ return pcoll \
+ | beam.CoGroupByKey() \
+ | beam.ParDo(self.ConcatFn()).with_output_types(
+ typing.Tuple[int, typing.Iterable[unicode]])
+
+ def to_runner_api_parameter(self, unused_context):
+ return TEST_CGBK_URN, None
+
+ @staticmethod
+ def from_runner_api_parameter(unused_parameter, unused_context):
+ return CoGBKTransform()
+
+
[email protected]_urn(TEST_COMGL_URN, None)
+class CombineGloballyTransform(ptransform.PTransform):
+ def expand(self, pcoll):
+ return pcoll \
Review comment:
Nit: use parenthesis instead of \ for line wrap.
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 377892)
Time Spent: 18h (was: 17h 50m)
> Add tests for all runner native transforms and some widely used composite
> transforms to cross-language validates runner test suite
> ----------------------------------------------------------------------------------------------------------------------------------
>
> Key: BEAM-7961
> URL: https://issues.apache.org/jira/browse/BEAM-7961
> Project: Beam
> Issue Type: Improvement
> Components: testing
> Reporter: Heejong Lee
> Assignee: Heejong Lee
> Priority: Major
> Time Spent: 18h
> Remaining Estimate: 0h
>
> Add tests for all runner native transforms and some widely used composite
> transforms to cross-language validates runner test suite
--
This message was sent by Atlassian Jira
(v8.3.4#803005)