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

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

                Author: ASF GitHub Bot
            Created on: 13/Nov/19 00:48
            Start Date: 13/Nov/19 00:48
    Worklog Time Spent: 10m 
      Work Description: liumomo315 commented on pull request #9957: [BEAM-8575] 
Test a customized window fn work as expected
URL: https://github.com/apache/beam/pull/9957#discussion_r345520928
 
 

 ##########
 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:
   With that change, I also need to separate the windows runner api tests to a 
separate file.
 
----------------------------------------------------------------
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: 342318)
    Time Spent: 4.5h  (was: 4h 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
>            Assignee: wendy liu
>            Priority: Major
>          Time Spent: 4.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