Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom timetable as a DAG argument #17414

Merged
merged 3 commits into from
Aug 31, 2021

Conversation

uranusjr
Copy link
Member

@uranusjr uranusjr commented Aug 4, 2021

To allow a custom timetable argument to work on a DAG, the existing schedule_interval attribute and the normalized_schedule_interval property are removed. All existing aceess to schedule_interval (the normalized
property is not used anywhere) are all changed to use the DAG's timetable member. A couple of timetable-describing flags, can_run and periodic, are added to replace some usages that need to know about what the timetable
is capable of doing.

Serialization methods are added to timetable classes so the timetable can be saved to the meta database during DAG serialization.

Since the schedule_interval attribute has been removed, the field on DagModel of the same name is also changed. Since we still need that information to display the timetable on the web UI, timetable.summary is used to “backfill” schedule_interval if a custom timetable is used. schedule_interval becomes purely cosmetic and only used to UI display.

@uranusjr uranusjr added the AIP-39 Timetables label Aug 4, 2021
@uranusjr uranusjr requested a review from ashb August 4, 2021 13:01
@uranusjr uranusjr requested review from kaxil and mik-laj as code owners August 4, 2021 13:02
@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:providers area:Scheduler including HA (high availability) scheduler area:serialization area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues kind:documentation provider:amazon-aws AWS/Amazon - related issues provider:google Google (including GCP) related issues labels Aug 4, 2021
@uranusjr uranusjr force-pushed the aip-39-dag-accepts-timetable branch from c6b7684 to c5b4e99 Compare August 4, 2021 13:03
@uranusjr uranusjr changed the title @uranusjr Allow custom timetable as a DAG argument Allow custom timetable as a DAG argument Aug 4, 2021
@uranusjr uranusjr force-pushed the aip-39-dag-accepts-timetable branch 2 times, most recently from f693525 to 791ddec Compare August 5, 2021 08:00
@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Aug 5, 2021
@github-actions
Copy link

github-actions bot commented Aug 5, 2021

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@uranusjr uranusjr force-pushed the aip-39-dag-accepts-timetable branch 4 times, most recently from fd59fa0 to f4129d9 Compare August 6, 2021 14:02
@uranusjr uranusjr closed this Aug 6, 2021
@uranusjr uranusjr force-pushed the aip-39-dag-accepts-timetable branch 3 times, most recently from 54d5877 to c1f6815 Compare August 16, 2021 16:29
@uranusjr uranusjr mentioned this pull request Aug 17, 2021
@uranusjr uranusjr force-pushed the aip-39-dag-accepts-timetable branch from c1f6815 to e1c553c Compare August 17, 2021 12:01
airflow/models/dag.py Show resolved Hide resolved
airflow/models/dag.py Show resolved Hide resolved
Copy link
Member

@ashb ashb left a comment

Choose a reason for hiding this comment

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

A few minor non-blocking changes.

Since I'm out I'm approving this now, but please either make the changes suggested or leave comments saying why they aren't needed (then merge without needing further approval from me)

airflow/models/dag.py Show resolved Hide resolved
airflow/models/dag.py Show resolved Hide resolved
tests/serialization/test_dag_serialization.py Outdated Show resolved Hide resolved
@uranusjr uranusjr requested a review from bbovenzi as a code owner August 30, 2021 11:19
@uranusjr uranusjr force-pushed the aip-39-dag-accepts-timetable branch 3 times, most recently from c754edc to 74739cd Compare August 30, 2021 13:25
@uranusjr
Copy link
Member Author

Static check failing due to unrelated issue.

@uranusjr uranusjr force-pushed the aip-39-dag-accepts-timetable branch 2 times, most recently from bc7ea67 to d3b56fe Compare August 30, 2021 16:00
This delegates most of the serialization work to the type, so the behavior
can be completely controlled by a custom subclass.
"""
return {"type": as_importable_string(type(var)), "value": var.serialize()}
Copy link
Member

Choose a reason for hiding this comment

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

Possibly __type to match with other "special" keys? Not sure

Copy link
Member Author

Choose a reason for hiding this comment

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

I’m assuming we’re not yet set on the serialisation method because of the class registration stuff (and I’m not sure the current method will always work if the timetable class is declared in a DAG file), so let’s not think too hard on this for now?

Copy link
Member

Choose a reason for hiding this comment

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

👍🏻 We can tackle that next then.

All existing aceess to schedule_interval (the normalized property is
not used anywhere) are all changed to use the DAG's timetable member.
A couple of timetable-describing flags, can_run and periodic, are added
to replace some usages that need to know about what the timetable is
capable of doing.

Serialization methods are added to timetable classes so the timetable
can be saved to the meta database during DAG serialization.
@uranusjr
Copy link
Member Author

uranusjr commented Aug 31, 2021

Registration issue opened as #17931.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AIP-39 Timetables area:API Airflow's REST/HTTP API area:providers area:Scheduler including HA (high availability) scheduler area:serialization area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues full tests needed We need to run full set of tests for this PR to merge kind:documentation provider:amazon-aws AWS/Amazon - related issues provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants