xBis7 commented on code in PR #71737:
URL: https://github.com/apache/airflow/pull/71737#discussion_r4312945822
##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -163,14 +164,51 @@ def validate_loop_decision(decision: str | None,
region_index: int, group: Seria
raise InvalidLoopDecision("Fixed-count loop decision does not match
its iteration limit")
+@dataclass(frozen=True, slots=True, eq=False)
+class FinishedTI:
+ """
+ Immutable view of a task instance in a terminal state.
+
+ Keeps the dag_run rescan lightweight and fast: scheduling only reads these
columns
+ off finished task instances, so a fully instrumented TaskInstance per row
is
+ unnecessary. ``task`` is attached from the serialized dag rather than the
row.
+
+ ``eq=False`` keeps the same identity-based equality and hashing a
TaskInstance has.
+
+ Anything needing a full TaskInstance must re-fetch it (see
``_ensure_type_task_instance``).
+ """
+
+ id: UUID
+ dag_id: str
+ run_id: str
+ task_id: str
+ region_id: UUID
+ region_index: int
+ dag_version_id: UUID | None
+ state: str | None
Review Comment:
I actually got that from the `TaskInstance` model
https://github.com/xBis7/airflow/blob/fd7ebe8bf657366b759f4cd22e79a2d45d378f02/airflow-core/src/airflow/models/taskinstance.py#L1122
I'd rather keep that consistent because the values are populated based on
the `TaskInstance` and any change in the model might break this.
##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -163,14 +164,51 @@ def validate_loop_decision(decision: str | None,
region_index: int, group: Seria
raise InvalidLoopDecision("Fixed-count loop decision does not match
its iteration limit")
+@dataclass(frozen=True, slots=True, eq=False)
+class FinishedTI:
+ """
+ Immutable view of a task instance in a terminal state.
+
+ Keeps the dag_run rescan lightweight and fast: scheduling only reads these
columns
+ off finished task instances, so a fully instrumented TaskInstance per row
is
+ unnecessary. ``task`` is attached from the serialized dag rather than the
row.
+
+ ``eq=False`` keeps the same identity-based equality and hashing a
TaskInstance has.
+
+ Anything needing a full TaskInstance must re-fetch it (see
``_ensure_type_task_instance``).
+ """
+
+ id: UUID
+ dag_id: str
+ run_id: str
+ task_id: str
+ region_id: UUID
+ region_index: int
+ dag_version_id: UUID | None
+ state: str | None
Review Comment:
I actually got that from the `TaskInstance` model
https://github.com/xBis7/airflow/blob/fd7ebe8bf657366b759f4cd22e79a2d45d378f02/airflow-core/src/airflow/models/taskinstance.py#L1122
I'd rather keep it consistent because the values are populated based on the
`TaskInstance` and any change in the model might break this.
--
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]