udim commented on code in PR #28273:
URL: https://github.com/apache/beam/pull/28273#discussion_r1316282728


##########
sdks/python/apache_beam/runners/worker/data_sampler.py:
##########
@@ -49,11 +49,19 @@
 class SampleTimer:
   """Periodic timer for sampling elements."""
   def __init__(self, timeout_secs: float, sampler: OutputSampler) -> None:
-    self._timeout_secs = timeout_secs
+    self._target_timeout_secs = timeout_secs
+    self._timeout_secs = min(timeout_secs, 0.5) if timeout_secs > 0 else 0
     self._timer = Timer(self._timeout_secs, self.sample)
     self._sampler = sampler
+    self._sample_duration_secs = 0
 
   def reset(self) -> None:
+    # For the first 30 seconds, sample every 0.5 seconds. After that, sample at
+    # the normal rate.
+    if self._sample_duration_secs >= 30:
+      self._timeout_secs = self._target_timeout_secs
+    self._sample_duration_secs += self._timeout_secs

Review Comment:
   From mypy:
   `apache_beam/runners/worker/data_sampler.py:63: error: Incompatible types in 
assignment (expression has type "float", variable has type "int")  [assignment]`



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to