You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "AutomationDev85 (via GitHub)" <gi...@apache.org> on 2023/04/25 09:40:48 UTC

[GitHub] [airflow] AutomationDev85 commented on a diff in pull request #30706: Save scheduler execution time by checking if DAG has interval or timetable

AutomationDev85 commented on code in PR #30706:
URL: https://github.com/apache/airflow/pull/30706#discussion_r1176269054


##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1308,8 +1308,18 @@ def _create_dag_runs_dataset_triggered(
                     DatasetDagRunQueue.target_dag_id == dag_run.dag_id
                 ).delete()
 
-    def _should_update_dag_next_dagruns(self, dag, dag_model: DagModel, total_active_runs: int) -> bool:
+    def _should_update_dag_next_dagruns(
+        self, dag: DAG, dag_model: DagModel, session: Session, total_active_runs: int = -1
+    ) -> bool:
         """Check if the dag's next_dagruns_create_after should be updated."""
+        # If dag has no interval or timetable then skip save runtime
+        if not dag.schedule_interval and isinstance(dag.timetable, NullTimetable):
+            return False

Review Comment:
   Thanks for your input!
   1. Any idea what is the best case to check if a dag is only triggered and not scheduled? I was not finding a nicer way to check for this.
   2. I wanted to catch the use case of the function _create_dag_runs were the number of active dags is increase outside of the function.
   3. Why should a user subclass NullTimetable. I did not get why NullTimetable exists and not setting this to None. Can you help me to understand this? i though NullTimeTable is used if no timetable exists.
   4. Will check this out.



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