Пример #1
0
 def next_dagrun_info(
     self,
     last_automated_dagrun: Optional[DateTime],
     restriction: TimeRestriction,
 ) -> Optional[DagRunInfo]:
     if last_automated_dagrun is not None:
         return None  # Already run, no more scheduling.
     if restriction.earliest is None:  # No start date, won't run.
         return None
     # "@once" always schedule to the start_date determined by the DAG and
     # tasks, regardless of catchup or not. This has been the case since 1.10
     # and we're inheriting it. See AIRFLOW-1928.
     run_after = restriction.earliest
     if restriction.latest is not None and run_after > restriction.latest:
         return None
     return DagRunInfo.exact(run_after)
Пример #2
0
    def next_dagrun_info(
        self,
        *,
        last_automated_data_interval: Optional[DataInterval],
        restriction: TimeRestriction,
    ) -> Optional[DagRunInfo]:
        if last_automated_data_interval is None:
            next_event = self.event_dates[0]
        else:
            future_dates = itertools.dropwhile(
                lambda when: when <= last_automated_data_interval.end, self.event_dates  # type: ignore
            )
            next_event = next(future_dates, None)  # type: ignore
            if next_event is None:
                return None

        return DagRunInfo.exact(next_event)