Skip to content

Commit 1053031

Browse files
committed
Fix error for Regex test
1 parent 1ce3c64 commit 1053031

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

sdks/python/apache_beam/runners/worker/operations.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ cdef class Operation(object):
8383
cdef readonly object scoped_start_state
8484
cdef readonly object scoped_process_state
8585
cdef readonly object scoped_finish_state
86-
cdef readonly object scoped_timer_processing_state
8786

8887
cdef readonly object data_sampler
8988

@@ -118,6 +117,7 @@ cdef class DoOperation(Operation):
118117
cdef dict timer_specs
119118
cdef public object input_info
120119
cdef object fn
120+
cdef readonly object scoped_timer_processing_state
121121

122122

123123
cdef class SdfProcessSizedElements(DoOperation):

sdks/python/apache_beam/runners/worker/operations.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from apache_beam.runners.worker import opcounters
5050
from apache_beam.runners.worker import operation_specs
5151
from apache_beam.runners.worker import sideinputs
52+
from apache_beam.runners.worker import statesampler
5253
from apache_beam.runners.worker.data_sampler import DataSampler
5354
from apache_beam.transforms import sideinputs as apache_sideinputs
5455
from apache_beam.transforms import combiners
@@ -454,6 +455,10 @@ def __init__(
454455
self.name_context, 'process', metrics_container=self.metrics_container)
455456
self.scoped_finish_state = self.state_sampler.scoped_state(
456457
self.name_context, 'finish', metrics_container=self.metrics_container)
458+
else:
459+
self.scoped_start_state = statesampler.NOOP_SCOPED_STATE
460+
self.scoped_process_state = statesampler.NOOP_SCOPED_STATE
461+
self.scoped_finish_state = statesampler.NOOP_SCOPED_STATE
457462
# TODO(ccy): the '-abort' state can be added when the abort is supported in
458463
# Operations.
459464
self.receivers = [] # type: List[ConsumerSet]

sdks/python/apache_beam/runners/worker/statesampler.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,15 @@ def commit_counters(self) -> None:
171171
for state in self._states_by_name.values():
172172
state_msecs = int(1e-6 * state.nsecs)
173173
state.counter.update(state_msecs - state.counter.value())
174+
175+
class NoOpScopedState:
176+
def __enter__(self):
177+
pass
178+
179+
def __exit__(self, exc_type, exc_val, exc_tb):
180+
pass
181+
182+
def sampled_msecs_int(self):
183+
return 0
184+
185+
NOOP_SCOPED_STATE = NoOpScopedState()

0 commit comments

Comments
 (0)