tothandor opened a new issue, #27853: URL: https://github.com/apache/airflow/issues/27853
### Apache Airflow version 2.4.3 ### What happened I have a DAG that should be executed on every Wednesday for the last whole week (from Monday to Sunday). Data becomes available for the period by then. AFAIK this scheduling could not be done with the readily available timetables. So, I have created a custom Timetable in a plugin, based on the [AfterWorkdayTimetable](https://airflow.apache.org/docs/apache-airflow/stable/_modules/airflow/example_dags/plugins/workday.html#AfterWorkdayTimetable), but out-of-the-box it could not work because [infer_automated_data_interval() in models/dag.py](https://github.com/apache/airflow/blob/main/airflow/models/dag.py#L848) allows only descendants of built-in timetable types (OnceTimetable, CronDataIntervalTimetable, DeltaDataIntervalTimetable, NullTimetable). Therefore I had to patch dag.py to make ordinary Timetables work as well (note: until 2.4.0 Timetables were not runtime_checkable Protocols, and that was an other obstacle). Am I doing something unintended and the AfterWorkdayTimetable example is outdated or simple Timetables are really missing from models/dag.py:infer_automated_data_interval()? ### What you think should happen instead Custom Timetables should be able to be used in infer_automated_data_interval(). I have used the following patch. ```patch --- dag.py.orig 2022-10-24 12:06:09.551012255 +0200 +++ dag.py 2022-11-23 10:07:07.406591024 +0100 def infer_automated_data_interval(self, logical_date: datetime) -> DataInterval: """Infer a data interval for a run against this DAG. This method is used to bridge runs created prior to AIP-39 implementation, which do not have an explicit data interval. Therefore, this method only considers ``schedule_interval`` values valid prior to Airflow 2.2. DO NOT use this method is there is a known data interval. """ timetable_type = type(self.timetable) if issubclass(timetable_type, (NullTimetable, OnceTimetable)): return DataInterval.exact(timezone.coerce_datetime(logical_date)) start = timezone.coerce_datetime(logical_date) if issubclass(timetable_type, CronDataIntervalTimetable): end = cast(CronDataIntervalTimetable, self.timetable)._get_next(start) elif issubclass(timetable_type, DeltaDataIntervalTimetable): end = cast(DeltaDataIntervalTimetable, self.timetable)._get_next(start) + elif issubclass(timetable_type, Timetable): + return self.timetable.infer_manual_data_interval(logical_date) else: raise ValueError(f"Not a valid timetable: {self.timetable!r}") return DataInterval(start, end) ``` ### How to reproduce Use the [AfterWorkdayTimetable example timetable](https://airflow.apache.org/docs/apache-airflow/stable/_modules/airflow/example_dags/plugins/workday.html#AfterWorkdayTimetable). ### Operating System CentOS Linux Stream 8 ### Versions of Apache Airflow Providers _No response_ ### Deployment Virtualenv installation ### Deployment details _No response_ ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md) -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
