ephraimbuddy commented on code in PR #52177:
URL: https://github.com/apache/airflow/pull/52177#discussion_r2220158961


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -131,15 +131,16 @@ def _get_dag(self, version_id: str, session: Session) -> 
DAG | None:
         return dag
 
     @staticmethod
-    def _version_from_dag_run(dag_run, session):
-        if dag_run.bundle_version:
-            dag_version = dag_run.created_dag_version
-        else:
+    def _version_from_dag_run(dag_run, latest, session):
+        if latest or not dag_run.bundle_version:
             dag_version = DagVersion.get_latest_version(dag_id=dag_run.dag_id, 
session=session)
-        return dag_version
+            if dag_version:
+                return dag_version
+
+        return dag_run.created_dag_version
 
-    def get_dag(self, dag_run: DagRun, session: Session) -> DAG | None:
-        version = self._version_from_dag_run(dag_run=dag_run, session=session)
+    def get_dag(self, dag_run: DagRun, session: Session, latest=False) -> DAG 
| None:

Review Comment:
   I'm refactoring it in https://github.com/apache/airflow/pull/53153 to have a 
better interface. Specifically, `get_dag_for_run` and 
`get_latest_version_of_dag`



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

Reply via email to