Lee-W commented on code in PR #75847:
URL: https://github.com/apache/airflow/pull/75847#discussion_r4411165112
##########
airflow-core/src/airflow/timetables/_cron.py:
##########
@@ -153,6 +174,31 @@ def localize_partition_datetime(self, dt:
datetime.datetime) -> DateTime:
"""
return convert_to_utc(make_aware(dt.replace(tzinfo=None),
self._timezone))
+ def _localized_ticks_within_limit(self, naive: datetime.datetime, *,
before: bool) -> list[DateTime]:
+ """Localize every cron tick within ``_MAX_DST_SHIFT`` on one side of
``naive``, ``naive`` included."""
+ nudge = datetime.timedelta(microseconds=1)
+ cron = croniter(self._expression, start_time=naive + nudge if before
else naive - nudge)
+ step = cron.get_prev if before else cron.get_next
+ localized: list[DateTime] = []
+ tick = step(datetime.datetime)
+ while abs(tick - naive) <= _MAX_DST_SHIFT:
+ localized += _localize_all_folds(tick, self._timezone)
+ tick = step(datetime.datetime)
+ return localized
+
+ def _localize_if_unambiguous(
+ self, naive: datetime.datetime, scheduled: datetime.datetime
+ ) -> DateTime | None:
+ """
+ Localize ``scheduled`` when neither it nor ``naive`` is ambiguous,
else return ``None``.
+
+ Without a fold or gap at either end, localizing the wall-clock tick is
exact.
Review Comment:
Updated the docstring.
"croniter yields ticks in wall-clock order, so nothing lies between `naive`
and `scheduled`" — a fold or gap between them holds no tick, which is why the
49-hour weekend case is safe; an earlier tick can only cross `current` through
a fold at `naive` itself, and that case (plus a fold or gap at `scheduled`) is
what the fold search handles."
--
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]