dstandish commented on code in PR #69565:
URL: https://github.com/apache/airflow/pull/69565#discussion_r3539293712
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -203,6 +203,33 @@ def _stop_remaining_tasks(*, task_instance: TaskInstance,
task_teardown_map=None
log.info("Not skipping teardown task '%s'", ti.task_id)
+def _add_and_prime_mapped_ti(
+ ti: TaskInstance,
+ task: Operator,
+ dag_run: DagRun,
+ *,
+ session: Session,
+ context_carrier: dict | None = None,
+) -> None:
+ """
+ Attach a newly-created mapped TI to the session and prime its ``dag_run``
cache.
+
+ Used by mapped-task expansion (``TaskMap.expand_mapped_task``,
+ ``DagRun._revise_map_indexes_if_mapped``) to persist a brand-new mapped TI
without
+ the per-row SELECT that ``session.merge()`` would issue, and to prime
``dag_run`` so
+ a later ``ti.get_dagrun()`` during dependency evaluation is a cache hit
rather than
+ another per-TI SELECT.
+
+ :meta private:
+ """
+ task_instance_mutation_hook(ti, dag_run=dag_run)
+ session.add(ti)
+ if context_carrier is not None:
+ ti.context_carrier = context_carrier
+ ti.refresh_from_task(task, dag_run=dag_run)
+ set_committed_value(ti, "dag_run", dag_run)
Review Comment:
so what it is about is setting an attribute or relationship on an object
without notifying the ORM (Object-Relational Mapper) that the object has changed
i do not think it is the same but i will verify
--
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]