Repository navigation
Conversation
The Task SDK EventsTimetable inverted the presorted flag: it sorted the event dates only when presorted=True and kept them in the given order by default. The core EventsTimetable it is deserialized into is built with presorted=True and walks event_dates in order, picking the first event after the last run. An unsorted list therefore scheduled the latest event first and silently dropped every earlier one. Signed-off-by: Udaya Tejas <udayatejas2004@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The Task SDK
EventsTimetable.__init__(task-sdk/src/airflow/sdk/definitions/timetables/events.py) has thepresortedflag inverted:So with the default
presorted=False, the dates are kept in the given order, contrary to the docstring ("if True, event_dates will be assumed to be in ascending order") and to the coreairflow.timetables.events.EventsTimetable, which sortsif not presorted, as Airflow 2 did.The order matters downstream: the encoder serializes
event_datesas-is, and the coreEventsTimetable.deserializerebuilds withpresorted=True.next_dagrun_infowalks the list and takes the first event after the last run, so withevent_dates=[Mar 1, Jan 1, Feb 1]it schedules Mar 1 first and the earlier events are silently skipped; the"N events between X and Y"summary is also wrong, since it reads the first and last items.(Today this path is masked by the serialization
KeyError: '_summary'that #69401 fixes; once that lands, unsorted event dates start dropping runs. In an end-to-end encode → core decode →next_dagrun_infoloop with that fix applied by hand,[Mar 1, Jan 1, Feb 1]schedules only2025-03-01before this change and all three, in order, after.)Fix
Swap the branches:
list(event_dates) if presorted else sorted(event_dates).Tests
New
task-sdk/tests/task_sdk/definitions/timetables/test_events.py: dates are sorted by default, and kept as given (list or iterator) withpresorted=True. All three fail onmainand pass with the fix;tests/task_sdk/definitions/timetables/passes.Was generative AI tooling used to co-author this PR?