Skip to content

Fix misleading timetable Variable example in best practices - #73945

Merged
ashb merged 2 commits into
apache:mainfrom
Pebble32:fix-timetable-variable-best-practice
Oct 9, 2026
Merged

ashb merged 2 commits into
apache:mainfrom
Pebble32:fix-timetable-variable-best-practice

Conversation

@Pebble32

@Pebble32 Pebble32 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

The best-practices "good" timetable example calls Variable.get in __init__, which reruns every time the Dag processor or scheduler deserializes the timetable and fails to load it if the Variable is missing. Rewrite the guidance to pass plain arguments through serialize/deserialize, reading any Variable in the Dag file instead.

closes: #61497

Comment thread airflow-core/docs/best-practices.rst Resolved

@ashb ashb left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure showing using variables like that was used for a reason. I wonder how people are "meant" to use Variables in a timetable "well"? Or do we say "nope, you can't"?

@Pebble32
Pebble32 requested a review from ashb October 9, 2026 10:28
@Pebble32

Pebble32 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Good question I double checked this. Since 3.2 the lookup does work in the scheduler and Dag processor, it just runs on every deserialize and breaks loading if the Variable is missing. The "well" way is to read the Variable in the Dag file and pass the value in as a plain argument, so it is serialized with the timetable and refreshed on each parse. Updated the docs to say that and show it.

@ashb ashb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Though I really why we are calling __init__() when deserialzing. That feels like a mistake, and is why pickle etc don't do this, but call __setstate__ or similar.)

@ashb
ashb merged commit b8ef78f into apache:main Oct 9, 2026
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Best Practice for using variable in timetable seems obsolete

2 participants