You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/09/26 12:01:42 UTC

[GitHub] [airflow] ashb commented on a change in pull request #18503: When calling `dr.get_task_instance` automatically set `dag_run` relationship

ashb commented on a change in pull request #18503:
URL: https://github.com/apache/airflow/pull/18503#discussion_r716193475



##########
File path: airflow/models/dagrun.py
##########
@@ -381,11 +382,14 @@ def get_task_instance(self, task_id: str, session: Session = None) -> Optional[T
         :param session: Sqlalchemy ORM Session
         :type session: Session
         """
-        return (
+        ti = (
             session.query(TI)
             .filter(TI.dag_id == self.dag_id, TI.run_id == self.run_id, TI.task_id == task_id)
             .one_or_none()
         )
+        if ti:
+            set_committed_value(ti, 'dag_run', self)
+        return ti

Review comment:
       It can - the difference here is the extra join - that would result in a more complex query, and _we know_ that the ti belongs to those dag run.




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org