AIP-115 Add on-demand task sections using skipped tasks - #71050
Draft
dheerajturaga wants to merge 6 commits into
Draft
AIP-115 Add on-demand task sections using skipped tasks#71050dheerajturaga wants to merge 6 commits into
dheerajturaga wants to merge 6 commits into
Conversation
The alternate design reuses existing skip semantics, so its user-facing guidance needs to distinguish it from the bypassed-state proposal.
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.
Summary
This draft implements the skipped-task alternative for AIP-115: On-Demand Task Sections.
It is intentionally opened alongside #71038 so the PMC can compare two lifecycle models for the same user-facing feature:
bypassedstate.skippedstate.Both proposals let Dag authors keep expensive, risky, slow, or rarely needed work visible in a Dag without running it automatically. A normal Dag run can finish without waiting for that optional work, while an authorized user can later run the section for the exact Dag run that needs it.
Motivation
Airflow supports related workflows today, but none directly express non-blocking work that remains available on demand:
On-demand sections make this intent explicit in the Dag definition and provide a discoverable, scoped action in the UI and API.
Authoring experience
Dag authors place an
OnDemandSectionOperatorat the start of an optional path and may give the section a user-facing label:The label identifies the action to users. When omitted, the task display name or
task_idis used.By default, the section controls all downstream descendants. Authors may instead limit it to direct downstream tasks, allowing later descendants to follow their existing trigger rules. Teardown tasks remain outside the optional section so cleanup behavior is preserved.
Dag run behavior
For scheduled, manually triggered, and backfill Dag runs:
This means backfills and manual runs do not unexpectedly execute expensive or high-impact optional sections. The section remains visible in the graph and retains a clear action for the specific Dag run.
Running a section
After the section marker succeeds, users can run its section from Graph view or the task instance details for that selected Dag run. The action never implicitly targets the latest run.
Before confirmation, Airflow previews the affected task instances. The confirmation flow supports an action note and protects already-running task instances by default. After confirmation:
A dedicated public task-instance action provides both preview and execution modes and returns the affected task instances. Invalid targets and unsafe transitions produce explicit client errors rather than silently acting on unrelated work.
The action is available for successful, non-mapped on-demand section task instances. A section can be run again when needed, subject to the default protection against disrupting active tasks.
Permissions and auditability
Running an on-demand section is a mutating task-instance action. It requires the existing Dag task-instance mutation permission and participates in normal API action logging.
This feature does not add named approvers, assignees, or task-level authorization. Deployments that need a person or group to approve execution should continue to use Human-in-the-loop operators.
CI/CD example
The included example models a release pipeline that builds and tests an artifact, publishes it, deploys it to staging, and verifies staging during the normal Dag run. Production deployment and production smoke tests remain visible but skipped.
After reviewing staging, an authorized operator can run the production section for that exact release's Dag run. This avoids rebuilding the artifact, keeps the production path attached to its originating release, and prevents backfills from deploying historical releases automatically.
Other suitable workflows include optional enrichment, report generation, historical reconciliation, deep validation, one-off exports, and high-impact follow-up work that should require an explicit operational action.
Design tradeoff for PMC review
Using
skippedkeeps the task-state model smaller and reuses behavior already understood by the scheduler, UI, APIs, executors, and users. It also avoids adding a state that every task-state consumer must recognize.The tradeoff is that a generic task-state view cannot distinguish an on-demand omission from other skipped work using state alone. The Dag definition, operator identity, section label, and dedicated action provide that context, but analytics based only on task state will see
skipped.The central decision between this draft and #71038 is therefore whether first-class state-level distinction is valuable enough to justify expanding the task-state model. The authoring and operational experience can otherwise remain substantially the same.
Compatibility and scope
This proposal is additive. Existing Dags, skipped-task behavior, branching, Human-in-the-loop workflows, and executor contracts remain unchanged unless a Dag adopts
OnDemandSectionOperator.It intentionally does not:
Validation
related: #71038
Was generative AI tooling used to co-author this PR?
Generated-by: Codex (GPT-5) following the guidelines
Drafted-by: Codex (GPT-5) (no human review before posting)