Acehaidrey commented on a change in pull request #12835:
URL: https://github.com/apache/airflow/pull/12835#discussion_r537266508
##########
File path: airflow/models/dagrun.py
##########
@@ -573,23 +573,29 @@ def
_emit_true_scheduling_delay_stats_for_finished_state(self, finished_tis):
Note, the stat will only be emitted if the DagRun is a scheduler
triggered one
(i.e. external_trigger is False).
"""
+ if self.state == State.RUNNING:
+ return
+ if self.external_trigger:
+ return
+ if not finished_tis:
+ return
+
try:
- if self.state == State.RUNNING:
- return
- if self.external_trigger:
- return
- if not finished_tis:
- return
dag = self.get_dag()
+
+ if not self.dag.schedule_interval or self.dag.schedule_interval ==
"@once":
+ # We can't emit this metric if there is no following schedule
to cacluate from!
+ return
+
ordered_tis_by_start_date = [ti for ti in finished_tis if
ti.start_date]
ordered_tis_by_start_date.sort(key=lambda ti: ti.start_date,
reverse=False)
first_start_date = ordered_tis_by_start_date[0].start_date
Review comment:
hey @XD-DENG yes agree you can do that and simplify this :) Feel free to
add that refactor!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]