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 06:54:29 UTC

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

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



##########
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:
       I think the same can be achieved with `options(joinedload(TI.dag_run))`? (See `get_task_instances()` above)




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