ktalluri456 commented on code in PR #36737:
URL: https://github.com/apache/beam/pull/36737#discussion_r2504453443
##########
sdks/python/apache_beam/runners/worker/operations.py:
##########
@@ -444,12 +445,19 @@ def __init__(
self.metrics_container = MetricsContainer(self.name_context.metrics_name())
self.state_sampler = state_sampler
- self.scoped_start_state = self.state_sampler.scoped_state(
- self.name_context, 'start', metrics_container=self.metrics_container)
- self.scoped_process_state = self.state_sampler.scoped_state(
- self.name_context, 'process', metrics_container=self.metrics_container)
- self.scoped_finish_state = self.state_sampler.scoped_state(
- self.name_context, 'finish', metrics_container=self.metrics_container)
+ if self.state_sampler:
Review Comment:
I believe my change exposed a bug in the Operation class where it would
crash during initialization if the state_sampler was None. This happens in
batch pipelines I believe, which is why tests like the autocomplete_test.py
were failing in presubmit checks.
Adding the if self.state_sampler: check and using a NoOpScopedState in the
else block makes the code more robust and ensures it works correctly in both
streaming and batch contexts.
--
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]