ashb commented on a change in pull request #17719:
URL: https://github.com/apache/airflow/pull/17719#discussion_r692768322
##########
File path: airflow/models/taskinstance.py
##########
@@ -1092,13 +1102,16 @@ def get_dagrun(self, session: Session = None):
:param session: SQLAlchemy ORM Session
:return: DagRun
"""
+ info = inspect(self)
+ if info.attrs.dag_run.loaded_value is not NO_VALUE:
+ return self.dag_run
+
from airflow.models.dagrun import DagRun # Avoid circular import
- dr = (
- session.query(DagRun)
- .filter(DagRun.dag_id == self.dag_id, DagRun.execution_date ==
self.execution_date)
- .first()
- )
+ dr = session.query(DagRun).filter(DagRun.dag_id == self.dag_id,
DagRun.run_id == self.run_id).one()
+
+ # Record it in the instance for next timme. This means that
`self.execution_date` will work correctly
+ set_committed_value(self, 'dag_run', dr)
Review comment:
Yes.
--
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]