[ https://issues.apache.org/jira/browse/BEAM-8575?focusedWorklogId=369592&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-369592 ]
ASF GitHub Bot logged work on BEAM-8575: ---------------------------------------- Author: ASF GitHub Bot Created on: 10/Jan/20 03:20 Start Date: 10/Jan/20 03:20 Worklog Time Spent: 10m Work Description: bumblebee-coming commented on pull request #10190: [BEAM-8575] Added two unit tests to CombineTest class to test that Co… URL: https://github.com/apache/beam/pull/10190#discussion_r365055230 ########## File path: sdks/python/apache_beam/transforms/combiners_test.py ########## @@ -50,6 +52,39 @@ from apache_beam.utils.timestamp import Timestamp +class CounterIncrememtingCombineFn(beam.CombineFn): + """CombineFn for incrementing three different counters: + counter, distribution, gauge, + at the same time concatenating words.""" + + def __init__(self): + beam.CombineFn.__init__(self) + self.word_counter = Metrics.counter(self.__class__, 'word_counter') + self.word_lengths_counter = Metrics.counter( + self.__class__, 'word_lengths') + self.word_lengths_dist = Metrics.distribution( + self.__class__, 'word_len_dist') + self.last_word_len = Metrics.gauge(self.__class__, 'last_word_len') + + def create_accumulator(self): + return '' + + def add_input(self, acc, element): + self.word_counter.inc(1) + self.word_lengths_counter.inc(len(element)) + self.word_lengths_dist.update(len(element)) + self.last_word_len.set(len(element)) + + # ''.join() converts the list to a string. + return ''.join(sorted(acc + element)) + + def merge_accumulators(self, accs): + return ''.join(sorted(''.join(accs))) + + def extract_output(self, acc): + return acc Review comment: Once sorted, acc became a list again. So I use ''.join() to convert it back to a string. ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 369592) Time Spent: 47h (was: 46h 50m) > Add more Python validates runner tests > -------------------------------------- > > Key: BEAM-8575 > URL: https://issues.apache.org/jira/browse/BEAM-8575 > Project: Beam > Issue Type: Test > Components: sdk-py-core, testing > Reporter: wendy liu > Assignee: wendy liu > Priority: Major > Time Spent: 47h > Remaining Estimate: 0h > > This is the umbrella issue to track the work of adding more Python tests to > improve test coverage. -- This message was sent by Atlassian Jira (v8.3.4#803005)