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

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

                Author: ASF GitHub Bot
            Created on: 20/Nov/20 20:11
            Start Date: 20/Nov/20 20:11
    Worklog Time Spent: 10m 
      Work Description: ibzib commented on a change in pull request #13338:
URL: https://github.com/apache/beam/pull/13338#discussion_r527941960



##########
File path: 
sdks/python/apache_beam/runners/portability/fn_api_runner/fn_runner_test.py
##########
@@ -835,23 +834,37 @@ def process(
       assert_that(res, equal_to(['1', '2']))
 
   def test_register_finalizations(self):
-    event_recorder = EventRecorder(tempfile.gettempdir())
-    elements_list = ['2', '1']
+    class FinalizableSplittableDoFn(beam.DoFn):
+      was_finalized = False
+
+      def set_finalized(self):
+        self.was_finalized = True
 
-    class FinalizableDoFn(beam.DoFn):
       def process(
-          self, element, bundle_finalizer=beam.DoFn.BundleFinalizerParam):
-        bundle_finalizer.register(lambda: event_recorder.record(element))
-        yield element
+          self,
+          element,
+          bundle_finalizer=beam.DoFn.BundleFinalizerParam,
+          restriction_tracker=beam.DoFn.RestrictionParam(

Review comment:
       Can you add a comment explaining why we use a splittable DoFn?

##########
File path: 
sdks/python/apache_beam/runners/portability/fn_api_runner/fn_runner_test.py
##########
@@ -835,23 +834,37 @@ def process(
       assert_that(res, equal_to(['1', '2']))
 
   def test_register_finalizations(self):
-    event_recorder = EventRecorder(tempfile.gettempdir())
-    elements_list = ['2', '1']
+    class FinalizableSplittableDoFn(beam.DoFn):
+      was_finalized = False
+
+      def set_finalized(self):
+        self.was_finalized = True
 
-    class FinalizableDoFn(beam.DoFn):
       def process(
-          self, element, bundle_finalizer=beam.DoFn.BundleFinalizerParam):
-        bundle_finalizer.register(lambda: event_recorder.record(element))
-        yield element
+          self,
+          element,
+          bundle_finalizer=beam.DoFn.BundleFinalizerParam,
+          restriction_tracker=beam.DoFn.RestrictionParam(
+              OffsetRangeProvider(use_bounded_offset_range=True))):
+        if self.was_finalized:
+          restriction_tracker.try_claim(
+              restriction_tracker.current_restriction().start)
+          yield element
+          restriction_tracker.try_claim(element)
+          return
+        if restriction_tracker.try_claim(
+            restriction_tracker.current_restriction().start):
+          bundle_finalizer.register(lambda: self.set_finalized())
+          time.sleep(1)

Review comment:
       Why is the sleep necessary? Can you add a comment?




----------------------------------------------------------------
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: 514819)
    Time Spent: 1h 20m  (was: 1h 10m)

> Portable FlinkRunnerTestStreaming.test_register_finalizations is flkay
> ----------------------------------------------------------------------
>
>                 Key: BEAM-11070
>                 URL: https://issues.apache.org/jira/browse/BEAM-11070
>             Project: Beam
>          Issue Type: Bug
>          Components: test-failures
>            Reporter: Boyuan Zhang
>            Assignee: Boyuan Zhang
>            Priority: P2
>              Labels: flake
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> The test is flaky owing to flink checkpoint configuration. We should be able 
> to tune the configuration to make the test reliable.



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

Reply via email to