Esempio n. 1
0
    def infer_manual_data_interval(self, *, run_after: DateTime) -> DataInterval:
        # If Timetable not restricted to events, run for the time specified
        if not self.restrict_to_events:
            return DataInterval.exact(run_after)

        # If restricted to events, run for the most recent past event
        # or for the first event if all events are in the future
        if run_after < self.event_dates[0]:
            return DataInterval.exact(self.event_dates[0])
        else:
            past_events = itertools.dropwhile(lambda when: when > run_after, self.event_dates[::-1])
            most_recent_event = next(past_events)
            return DataInterval.exact(most_recent_event)
Esempio n. 2
0
 def infer_manual_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._get_prev(self._align(run_after))
     return DataInterval(start=self._get_prev(end), end=end)
Esempio n. 3
0
 def infer_data_interval(self, run_after: DateTime) -> DataInterval:
     weekday = run_after.weekday()
     if weekday in (0, 6):  # Monday and Sunday -- interval is last Friday.
         days_since_friday = (run_after.weekday() - 4) % 7
         delta = timedelta(days=days_since_friday)
     else:  # Otherwise the interval is yesterday.
         delta = timedelta(days=1)
     start = DateTime.combine((run_after - delta).date(), Time.min).replace(tzinfo=UTC)
     return DataInterval(start=start, end=(start + timedelta(days=1)))
Esempio n. 4
0
 def infer_manual_data_interval(self, run_after: DateTime) -> DataInterval:
     return DataInterval(start=self._get_prev(run_after), end=run_after)
Esempio n. 5
0
 def infer_manual_data_interval(self, *,
                                run_after: DateTime) -> DataInterval:
     return DataInterval(run_after - self._interval, run_after)
Esempio n. 6
0
 def infer_data_interval(self, *, run_after: DateTime) -> DataInterval:
     return DataInterval.exact(run_after)
Esempio n. 7
0
 def infer_data_interval(self, run_after: DateTime) -> DataInterval:
     return DataInterval(start=self._schedule.get_prev(run_after),
                         end=run_after)