kacpermuda commented on code in PR #75132:
URL: https://github.com/apache/airflow/pull/75132#discussion_r4323853109


##########
task-sdk/src/airflow/sdk/execution_time/task_runner.py:
##########
@@ -267,6 +268,27 @@ def model_post_init(self, context: Any) -> None:
         if self.region_index is None:
             self.region_index = self.map_index
 
+    @property
+    def loop(self) -> LoopContextAccessor | None:
+        """The iteration of the innermost loop this task instance runs in, 
``None`` outside a loop."""
+        if self._ti_context_from_server is None or 
self._ti_context_from_server.loop is None:
+            return None
+        return LoopContextAccessor(self._ti_context_from_server.loop, self)
+
+    @property
+    def loop_decision(self) -> LoopDecision | None:
+        """A loop gate's decision, set once the gate has evaluated whether the 
loop stops."""
+        if self._loop_decision is None:
+            return None
+        return LoopDecision(stop=self._loop_decision.stop, 
reason=self._loop_decision.reason)
+
+    @property
+    def expanded_ti_count(self) -> int | None:

Review Comment:
   Context already declares an expanded_ti_count key, but the Task SDK never 
fills it. I exposed the count on the task instance instead of filling that key, 
because xcom_arg.py passes the context value to 
get_relevant_upstream_map_indexes, so filling it would change how mapped task 
groups resolve upstream XComs. Inside a loop it would arguably be more correct, 
since GetTICount counts the latest pass rather than the caller’s iteration, but 
that’s a behavior change I’d rather do separately. Is keeping it on the TI the 
right call, or should this PR fill the context key too?



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