aglinxinyuan commented on code in PR #8642:
URL: https://github.com/apache/texera/pull/8642#discussion_r4501626336
##########
amber/src/main/python/core/runnables/data_processor.py:
##########
@@ -84,6 +84,9 @@ def process_state(self, state: State) -> None:
or tuple generation based on the marker type.
"""
with self._executor_session() as (executor, port_id):
+ # Register the state message before the callback runs, so
+ # process_state (and every call after it) can consult self.state.
+ executor.state = state
Review Comment:
Fixed in ad9b1e23df — `self.loop_variables` now merges every state the
operator receives, and a state replaces only the names it carries, so the
second UDF still reads `self.loop_variables["i"]` after the first one's
`produce_state_on_finish` state. Your two-UDF loop is now a
`LoopIntegrationSpec` case (cb773d81b5), which failed with `KeyError: 'i'`
before the fix.
##########
amber/src/main/python/core/models/operator.py:
##########
@@ -76,6 +76,15 @@ def decode_python_template(self, data: Union[str, bytes]) ->
str:
__internal_is_source: bool = False
+ # The state message most recently handed to this operator -- inside a
+ # control block, the iteration's loop variables. The runtime registers it
+ # right before ``process_state`` runs (see
``DataProcessor.process_state``),
+ # so the callback and every call after it can consult it. A class-level
+ # default rather than an ``__init__`` assignment: a subclass ``__init__``
+ # that skips ``super()`` still reads ``None`` until a state arrives. The
+ # loop operators keep their own loop variables apart, on ``variables``.
+ state: Optional[State] = None
Review Comment:
Renamed it to `self.loop_variables` (e7f9caf61f) — the loop variables
received from upstream — so Loop Start and Loop End keep their own `self.state`
and this PR no longer touches them.
--
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]