Skip to content

Conversation

@kacpermuda
Copy link
Contributor

When using EventsTimetable, the schedule in Airflow UI is not shown correctly/. My guess is that the EventsTimetable description (and therefore summary) not being serialized is to blame.

In Airflow 3 we are relying on timetable.summary when displaying schedule in the UI. Currently, even if user provide a description Airflow UI will always display "X events" as timetable_summary, instead of description provided by the user.
image

In Airflow 2 we kept the timetable summary as DAG attribute and serialize it separately, so it always showed up in UI correctly.
image

This is also causing discrepancies in OpenLineage events, for DagRun events emitted from scheduler (for Airflow 2 and 3), we are receiving "X events", and for task events emitted from worker, the user description.

Example DAG to test it:

import pendulum
from datetime import datetime

from airflow import DAG
from airflow.timetables.events import EventsTimetable
from airflow.providers.standard.operators.bash import BashOperator


DAG_ID = "timetable_dag"

with DAG(
    dag_id=DAG_ID,
    start_date=datetime(2021, 1, 1),
    schedule=EventsTimetable(
        description="Example description",
        event_dates=[pendulum.datetime(2095, 3, 1, tz="America/Chicago")]
    ),
    catchup=False,
) as dag:
    nothing_task = BashOperator(task_id="do_nothing_task", bash_command="sleep 1;")

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an 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 a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@kacpermuda kacpermuda requested a review from uranusjr as a code owner May 29, 2025 14:42
@kacpermuda kacpermuda force-pushed the fix-events-timetable-summary branch from 32b6d88 to cc230fb Compare May 29, 2025 15:50
@kacpermuda
Copy link
Contributor Author

Can we also backport it to 2.X as well if merged?

@uranusjr
Copy link
Member

uranusjr commented Jun 6, 2025

This fix is awkward. I'd prefer the serialisation logic to just store the provided value, and supply it correctly on deserialisation. This shouldn't require an extra flag.

@kacpermuda
Copy link
Contributor Author

It's implemented this way because when providing description to the EventsTimetable, both _summary and description attributes are set to the provided description. When not provided, the _summary and description are generated, and different from each other. So if we serialize description regardless if it was provided or not, after deserializing the resulting summary will be different than before serialization if the description was not provided by the user. We would end up displaying the description (longer text) in the Airflow UI if we did that. We can also add the summary argument explicitly, but that was a bigger change imho.

@uranusjr
Copy link
Member

uranusjr commented Jun 6, 2025

Why not fix the value during deserialisation? Like

@classmethod
def deserialize(cls, data) -> Timetable:
    timetable = cls(...)
    timetable._summary = ...
    return timetable

@kacpermuda kacpermuda force-pushed the fix-events-timetable-summary branch from cc230fb to 40152b3 Compare June 6, 2025 12:58
@kacpermuda
Copy link
Contributor Author

Thanks for the advice, that make sense. Adjusted the code

@kacpermuda kacpermuda force-pushed the fix-events-timetable-summary branch 2 times, most recently from 34d6af7 to b0a8efe Compare June 6, 2025 14:05
@kacpermuda kacpermuda force-pushed the fix-events-timetable-summary branch from b0a8efe to 430060f Compare June 6, 2025 14:58
@kacpermuda
Copy link
Contributor Author

Anything else that needs to be adjusted?

@kacpermuda
Copy link
Contributor Author

Should we also backport it to 2.11 or fix it there? I think the difference is not visible on the UI but f.e. when listener is accessing dag timetable summary.

@uranusjr
Copy link
Member

I don’t have an opinion either way. This is not very meaningful from the user’s perspective, but also very easy to backport so why not.

@kacpermuda
Copy link
Contributor Author

Okay, I think it will be useful, so if it's not a big effort then let's do it. Does this PR need a specific label only or there is something else that needs to be done?

@uranusjr uranusjr added the backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch label Jun 12, 2025
@uranusjr
Copy link
Member

I think this should work, the rest will be automated after this is merged.

@kacpermuda
Copy link
Contributor Author

Should we merge it?

@uranusjr uranusjr merged commit a150e70 into apache:main Jun 19, 2025
53 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 19, 2025
#51203)

(cherry picked from commit a150e70)

Co-authored-by: Kacper Muda <mudakacper@gmail.com>
@github-actions
Copy link

Backport successfully created: v3-0-test

Status Branch Result
v3-0-test PR Link

@kacpermuda kacpermuda deleted the fix-events-timetable-summary branch June 19, 2025 08:51
github-actions bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Jun 19, 2025
apache#51203)

(cherry picked from commit a150e70)

Co-authored-by: Kacper Muda <mudakacper@gmail.com>
potiuk added a commit to potiuk/airflow that referenced this pull request Jun 19, 2025
The test misses timetable description after recent change in apache#51203
potiuk added a commit that referenced this pull request Jun 19, 2025
The test misses timetable description after recent change in #51203
shahar1 pushed a commit that referenced this pull request Jun 19, 2025
#51203) (#51926)

(cherry picked from commit a150e70)

Co-authored-by: Kacper Muda <mudakacper@gmail.com>
RoyLee1224 pushed a commit to RoyLee1224/airflow that referenced this pull request Jun 21, 2025
RoyLee1224 pushed a commit to RoyLee1224/airflow that referenced this pull request Jun 21, 2025
The test misses timetable description after recent change in apache#51203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants