[ 
https://issues.apache.org/jira/browse/BEAM-8575?focusedWorklogId=339668&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-339668
 ]

ASF GitHub Bot logged work on BEAM-8575:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Nov/19 01:17
            Start Date: 07/Nov/19 01:17
    Worklog Time Spent: 10m 
      Work Description: liumomo315 commented on pull request #9957: [BEAM-8575] 
Add validates runner tests for 1. Custom window fn: Test a customized window fn 
work as expected; 2. Windows idempotency: Applying the same window fn (or 
window fn + GBK) to the input multiple times will have the same effect as 
applying it once.
URL: https://github.com/apache/beam/pull/9957#discussion_r343409486
 
 

 ##########
 File path: sdks/python/apache_beam/transforms/window_test.py
 ##########
 @@ -65,6 +76,44 @@ def process(self, element, window=core.DoFn.WindowParam):
 
 reify_windows = core.ParDo(ReifyWindowsFn())
 
+class TestCustomWindows(NonMergingWindowFn):
+  """A custom non merging window fn which assigns elements into interval 
windows
+  based on the element timestamps.
+  """
+
+  def __init__(self, first_window_end, second_window_end):
+    self.first_window_end = Timestamp.of(first_window_end)
+    self.second_window_end = Timestamp.of(second_window_end)
+
+  def assign(self, context):
+    timestamp = context.timestamp
+    if timestamp < self.first_window_end:
+      return [IntervalWindow(0, self.first_window_end)]
+    elif timestamp < self.second_window_end:
+      return [IntervalWindow(self.first_window_end, self.second_window_end)]
+    else:
+      return [IntervalWindow(self.second_window_end, timestamp)]
+
+  def get_window_coder(self):
+    return IntervalWindowCoder()
+
+  def to_runner_api_parameter(self, context):
 
 Review comment:
   This custom window fn is added only for a test, to test a non-standard 
window fn. To fully implement it, I need to also implement 
to_runner_api_parameter and from_runner_api_parameter. Those require me to also 
change the standard_window_fns.proto and common_urns.py. Are these changes 
necessary? If not, is there a better way to do this? Thanks! @lukecwik 
@robertwb 
 
----------------------------------------------------------------
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: 339668)
    Time Spent: 0.5h  (was: 20m)

> 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
>            Priority: Major
>          Time Spent: 0.5h
>  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)

Reply via email to