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/08/20 16:32:22 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #17755: Separate infer_data_interval implementations for interval timetables

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



##########
File path: airflow/timetables/interval.py
##########
@@ -86,6 +79,13 @@ class CronDataIntervalTimetable(_DataIntervalTimetable):
     def __init__(self, cron: str, timezone: datetime.tzinfo) -> None:
         self._schedule = CronSchedule(cron, timezone)
 
+    def infer_data_interval(self, run_after: DateTime) -> DataInterval:
+        # Get the last complete period before run_after, e.g. if a DAG run is
+        # scheduled at each midnight, the data interval of a manually triggered
+        # run at 1am 25th is between 0am 24th and 0am 25th.
+        end = self._schedule.get_prev(self._schedule.align(run_after))
+        return DataInterval(start=self._schedule.get_prev(end), end=end)
+
 
 class DeltaDataIntervalTimetable(_DataIntervalTimetable):

Review comment:
       No strong opinion from me either, this name is not intended to be used directly by users anyway (they can just use `schedule_interval`). The only “complaint” (a weird term considering I named these classes) I have to this (and `CronDataIntervalTimetable`) is they are so terribly long.




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