Move DAG._schedule_interval logic out of DAG.__init__#8225
Move DAG._schedule_interval logic out of DAG.__init__#8225kaxil merged 3 commits intoapache:masterfrom kaxil:schedule_interal_norm
Conversation
|
Please feel free to suggest a better name for the PR title/commit which looks good for the Changelog. |
| """ | ||
| return self._get_is_paused() | ||
|
|
||
| @property |
There was a problem hiding this comment.
Maybe @cached_property is better ?
There was a problem hiding this comment.
Maybe, the downside to cached_property would be if dag.schedule_interval is changed, this parameter would be out of sync.
We could do it as:
@property
def normalized_schedule_interval(self) -> Optional[ScheduleInterval]:
return self._normalized_schedule_interval(self.schedule_interval)
@functools.lru_cache(maxsize=1)
def _normalized_schedule_interval(self, schedule_interval) -> Optional[ScheduleInterval]:
...Might be overkill.
ashb
left a comment
There was a problem hiding this comment.
Change looks good. Up to you if you want to do the cached_property/lru_cache or not.
Codecov Report
@@ Coverage Diff @@
## master #8225 +/- ##
==========================================
- Coverage 88.31% 87.58% -0.73%
==========================================
Files 936 936
Lines 45272 45319 +47
==========================================
- Hits 39980 39694 -286
- Misses 5292 5625 +333
Continue to review full report at Codecov.
|
|
@kaxil thank you for this fix! I have backported it to 1.10 and applied on my installation (instead of a patch in #8166 (comment)) and can confirm that it indeed fixes the issue. Will this be backported to v1-10? |
|
Thanks for confirming @KostyaEsmukov Yes this will be backported to v1-10 and would |
|
Great, thank you! |
closes apache#8166 (cherry picked from commit 0ccd5b9)
closes #8166
DAG._schedule_intervalwithDAG.normalized_schedule_interval. This will even allow users to tests that they set correct Cron Preset in unit tests (instead of using an internal property before)schedule_intervaland_schedule_intervalMake sure to mark the boxes below before creating PR: [x]
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.