Skip to content

Add run_on_latest_version support for backfill and clear operations #52177

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ephraimbuddy
Copy link
Contributor

@ephraimbuddy ephraimbuddy commented Jun 24, 2025

With this option, users are able to choose the dag version they want
to run their dag/task after clearing or when running backfill. This
only applies to versioned bundles as non-versioned bundles run with
the latest dag version.

When the user choose the run with latest version, the bundle_version
associated with the dagrun is updated to the latest and the associated
serialized dag version updated to the latest. Choosing not to run
with latest version which is the default means that the bundle version
and serialized dag version that the dag ran with initially would be used
in running it again.

For backfill, there's now --run-on-latest-version flag that makes it run
with the latest version, otherwise it will run with the original bundle
the dagrun was created with. Note that it's only useful when rerunning
a dagrun using backfill. The default behaviour is using the initial bundle/version
and this is intentional otherwise running backfill will fail if there was
task rename in the latest version.

Summary of changes:

  • Use SchedulerDagBag instead of DagBag for execution API
  • Add run_on_latest_version field to DAGRunClearBody and ClearTaskInstancesBody models
  • Add --run-on-latest-version CLI flag for backfill command
  • Update backfill.py to support running tasks with latest DAG version
  • Add UI checkbox for "Run with latest version" in clear dialogs
  • Update SchedulerDagBag to handle latest version parameter
  • Update API endpoints to support run_on_latest_version parameter

closes: #49007, closes: #49047

@boring-cyborg boring-cyborg bot added area:airflow-ctl area:API Airflow's REST/HTTP API area:Scheduler including HA (high availability) scheduler area:translations area:UI Related to UI/UX. For Frontend Developers. translation:default labels Jun 24, 2025
@ephraimbuddy ephraimbuddy force-pushed the properly-clear-ti-specific-version branch 5 times, most recently from 1f4b2e3 to bfc2a49 Compare June 27, 2025 15:04
@ephraimbuddy ephraimbuddy changed the title Fix clearing dags of versioned bundles and allow running on previous version Add run_on_latest_version support for backfill and clear operations Jun 27, 2025
@ephraimbuddy
Copy link
Contributor Author

Screenshot 2025-06-27 at 16 28 35

With this option, users are able to choose the dag version they want
to run their dag/task after clearing or when running backfill. This
only applies to versioned bundles as non-versioned bundles run with
the latest dag version.

When the user choose the run with latest version, the bundle_version
associated with the dagrun is updated to the latest and the associated
serialized dag version updated to the latest. Choosing not to run
with latest version which is the default means that the bundle version
and serialized dag version that the dag ran with initially would be used
in running it again.

For backfill, there's now --run-on-latest-version flag that makes it run
with the latest version, otherwise it will run with the original bundle
the dagrun was created with. Note that it's only useful when rerunning
a dagrun using backfill. The default behaviour is using the initial bundle/version
and this is intentional otherwise running backfill will fail if there was
task rename in the latest version.

Summary of changes:

- Use SchedulerDagBag instead of DagBag for execution API
- Add run_on_latest_version field to DAGRunClearBody and ClearTaskInstancesBody models
- Add --run-on-latest-version CLI flag for backfill command
- Update backfill.py to support running tasks with latest DAG version
- Add UI checkbox for "Run with latest version" in clear dialogs
- Update SchedulerDagBag to handle latest version parameter
- Update API endpoints to support run_on_latest_version parameter
Copy link
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. There are some questions about the usage of SchedulerDagBag in core-api.

@@ -83,8 +83,10 @@ def create_app(apps: str = "all") -> FastAPI:
dag_bag = create_dag_bag()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dag_bag = create_dag_bag()

@bbovenzi
Copy link
Contributor

UI for dagrun clear and task instance clear look good. We'll add this to backfills next?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:airflow-ctl area:API Airflow's REST/HTTP API area:Scheduler including HA (high availability) scheduler area:translations area:UI Related to UI/UX. For Frontend Developers. translation:default
Projects
None yet
3 participants