xBis7 commented on code in PR #71737: URL: https://github.com/apache/airflow/pull/71737#discussion_r3864032954
########## airflow-core/src/airflow/models/dagrun.py: ########## @@ -140,14 +141,41 @@ tracer = trace.get_tracer(__name__) +@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``). + """ + + task_id: str + map_index: int + state: str | None + start_date: datetime | None + end_date: datetime | None + task: Operator | None = None + + +# Get the necessary columns from the FinishedTI fields so that the class stays +# the single source of truth. For any needed change, add or remove a field there. +FINISHED_TI_COLUMNS = tuple(getattr(TI, f.name) for f in fields(FinishedTI) if f.name != "task") Review Comment: `getattr` without a default param doesn't fail silently. Instead it throws an `AttributeError` exception. https://docs.python.org/3/library/functions.html#getattr -- 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]
