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

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

                Author: ASF GitHub Bot
            Created on: 13/Jan/20 23:59
            Start Date: 13/Jan/20 23:59
    Worklog Time Spent: 10m 
      Work Description: lukecwik commented on pull request #10375: [BEAM-8537] 
Provide WatermarkEstimator to track watermark
URL: https://github.com/apache/beam/pull/10375#discussion_r366088770
 
 

 ##########
 File path: sdks/python/apache_beam/io/watermark_estimators_test.py
 ##########
 @@ -0,0 +1,105 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""Unit tests for built-in WatermarkEstiamtors"""
+
+from __future__ import absolute_import
+
+import unittest
+
+from apache_beam.io.iobase import WatermarkEstimator
+from apache_beam.io.watermark_estimators import ManualWatermarkEstimator
+from apache_beam.io.watermark_estimators import MonotonicWatermarkEstimator
+from apache_beam.io.watermark_estimators import WalltimeWatermarkEstimator
+from apache_beam.utils.timestamp import Duration
+from apache_beam.utils.timestamp import Timestamp
+
+
+class MonotonicWatermarkEstimatorTest(unittest.TestCase):
+
+  def test_initialize_from_state(self):
+    timestamp = Timestamp(10)
+    watermark_estimator = MonotonicWatermarkEstimator(timestamp)
+    self.assertIsInstance(watermark_estimator, WatermarkEstimator)
+    self.assertEqual(watermark_estimator.get_estimator_state(), timestamp)
+
+  def test_observe_timestamp(self):
+    watermark_estimator = MonotonicWatermarkEstimator(Timestamp(10))
+    watermark_estimator.observe_timestamp(Timestamp(15))
+    self.assertEqual(watermark_estimator.current_watermark(), Timestamp(15))
+    watermark_estimator.observe_timestamp(Timestamp(20))
+    self.assertEqual(watermark_estimator.current_watermark(), Timestamp(20))
+    watermark_estimator.observe_timestamp(Timestamp(20))
+    self.assertEqual(watermark_estimator.current_watermark(), Timestamp(20))
+    with self.assertRaises(ValueError):
+      watermark_estimator.observe_timestamp(Timestamp(10))
+
+  def test_get_estimator_state(self):
+    watermark_estimator = MonotonicWatermarkEstimator(Timestamp(10))
+    watermark_estimator.observe_timestamp(Timestamp(15))
+    self.assertEqual(watermark_estimator.get_estimator_state(), Timestamp(15))
+
+
+class WalltimeWatermarkEstimatorTest(unittest.TestCase):
+
+  def test_initialization(self):
+    watermark_estiamtor = WalltimeWatermarkEstimator()
 
 Review comment:
   nit: watermark_estiamtor -> watermark_estimator
 
----------------------------------------------------------------
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: 371230)
    Time Spent: 4h 50m  (was: 4h 40m)

> Provide WatermarkEstimatorProvider for different types of WatermarkEstimator
> ----------------------------------------------------------------------------
>
>                 Key: BEAM-8537
>                 URL: https://issues.apache.org/jira/browse/BEAM-8537
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-py-core, sdk-py-harness
>            Reporter: Boyuan Zhang
>            Assignee: Boyuan Zhang
>            Priority: Major
>          Time Spent: 4h 50m
>  Remaining Estimate: 0h
>
> This is a follow up for in-progress PR:  
> https://github.com/apache/beam/pull/9794.
> Current implementation in PR9794 provides a default implementation of 
> WatermarkEstimator. For further work, we want to let WatermarkEstimator to be 
> a pure Interface. We'll provide a WatermarkEstimatorProvider to be able to 
> create a custom WatermarkEstimator per windowed value. It should be similar 
> to how we track restriction for SDF: 
> WatermarkEstimator <---> RestrictionTracker 
> WatermarkEstimatorProvider <---> RestrictionTrackerProvider
> WatermarkEstimatorParam <---> RestrictionDoFnParam



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to