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


##########
airflow-core/src/airflow/models/task_coordinates.py:
##########
@@ -69,6 +71,40 @@ class _ProducerRequest:
     loop_node_id: str | None = None
 
 
[email protected](kw_only=True)
+class LoopPosition:
+    """
+    The pass of the innermost loop a task instance runs in.
+
+    ``region_id`` is the loop region that holds the pass, also for a mapped 
task, whose own ``region_id`` is
+    its expansion's. A clear that reruns later passes forks the loop region: 
``trajectory`` is 1 for the
+    original region and grows by one with each fork, ``forked_from_region_id`` 
is the region the fork
+    replaced and ``resumes_from_index`` the first pass the fork owns (0 for an 
original region).
+    """
+
+    group: SerializedLoopTaskGroup
+    index: int
+    region_id: UUID
+    trajectory: int
+    forked_from_region_id: UUID | None
+    resumes_from_index: int
+
+
[email protected](kw_only=True)
+class TaskInstanceExecutionPosition:

Review Comment:
   No, removed it. ti_run now calls get_loop_position and get_expanded_ti_count 
directly.



##########
airflow-core/src/airflow/models/task_coordinates.py:
##########
@@ -839,3 +926,18 @@ def select_producer_ids(
             region_index=request.region_index,
             session=self.session,
         )
+
+
+def get_task_instance_execution_position(
+    task_instance: TaskInstance, *, session: Session
+) -> TaskInstanceExecutionPosition:
+    """
+    Place a stored task instance in its mapped expansion and loop pass.
+
+    This is what the Execution API sends a worker when the task starts 
(``TIRunContext.loop`` and
+    ``TIRunContext.expanded_ti_count``), so server-side consumers such as 
listeners reporting a manual state
+    change describe the task instance as the worker would, without reading 
region rows themselves.
+    """
+    return TaskCoordinateResolver(DBDagBag(load_op_links=False), 
session).get_execution_position(

Review Comment:
   Removed the helper. Server-side callers build a resolver with 
TaskCoordinateResolver.for_dag(dag, session), which reuses the Dag they already 
hold, and call the same two methods.



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