-
Notifications
You must be signed in to change notification settings - Fork 16.4k
docs(task-sdk): reorganize landing page into six core sections #52196
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8a94383
Restructure task-sdk/docs/index.rst into six sections (Intro, Public …
sunank200 17390b0
Remove API server docs
sunank200 a5e479e
Move arch to upgrading to airflow 3
sunank200 f755c43
Update airflow-core/docs/installation/upgrading_to_airflow3.rst
sunank200 6ccd3b8
Fix PR comments
sunank200 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| .. Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| .. http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| .. Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
|
|
||
| Concepts | ||
| ======== | ||
|
|
||
| This section covers the fundamental concepts that DAG authors need to understand when working with the Task SDK. | ||
|
|
||
| .. note:: | ||
|
|
||
| For information about Airflow 3.x architectural changes and database access restrictions, see the "Upgrading to Airflow 3" guide in the main Airflow documentation. | ||
|
|
||
| Terminology | ||
| ----------- | ||
| - **Task**: a Python function (decorated with ``@task``) or Operator invocation representing a unit of work in a DAG. | ||
| - **Task Execution**: the runtime machinery that executes user tasks in isolated subprocesses, managed via the Supervisor and Execution API. | ||
|
|
||
| Task Lifecycle | ||
| -------------- | ||
|
|
||
| Understanding the task lifecycle helps DAG authors write more effective tasks and debug issues: | ||
|
|
||
| - **Scheduled**: The Airflow scheduler enqueues the task instance. The Executor assigns a workload token used for subsequent API authentication and validation with the Airflow API Server. | ||
| - **Queued**: Workers poll the queue to retrieve and reserve queued task instances. | ||
| - **Subprocess Launch**: The worker's Supervisor process spawns a dedicated subprocess (Task Runner) for the task instance, isolating its execution. | ||
| - **Run API Call**: The Supervisor sends a ``POST /run`` call to the Execution API to mark the task as running; the API server responds with a ``TIRunContext`` containing essential runtime information including: | ||
|
|
||
| - **``dag_run``**: Complete DAG run information (logical date, data intervals, configuration, etc.) | ||
| - **``max_tries``**: Maximum number of retry attempts allowed for this task instance | ||
| - **``should_retry``**: Boolean flag indicating whether the task should enter retry state or fail immediately on error | ||
| - **``task_reschedule_count``**: Number of times this task has been rescheduled | ||
| - **``variables``**: List of Airflow variables accessible to the task instance | ||
| - **``connections``**: List of Airflow connections accessible to the task instance | ||
| - **``upstream_map_indexes``**: Mapping of upstream task IDs to their map indexes for dynamic task mapping scenarios | ||
| - **``next_method``**: Method name to call when resuming from a deferred state (set when task resumes from a trigger) | ||
| - **``next_kwargs``**: Arguments to pass to the ``next_method`` (can be encrypted for sensitive data) | ||
| - **``xcom_keys_to_clear``**: List of XCom keys that need to be cleared and purged by the worker | ||
| - **Runtime Dependency Fetching**: During execution, if the task code requests Airflow resources (variables, connections, etc.), it writes a request to STDOUT. The Supervisor receives it and issues a corresponding API call, and writes the API response into the subprocess's STDIN. | ||
| - **Heartbeats & Token Renewal**: The Task Runner periodically emits ``POST /heartbeat`` calls through the Supervisor. Each call authenticates via JWT; if the token has expired, the API server returns a refreshed token in the ``Refreshed-API-Token`` header. | ||
| - **XCom Operations**: Upon successful task completion (or when explicitly invoked during execution), the Supervisor issues API calls to set or clear XCom entries for inter-task data passing. | ||
| - **State Patch**: When the task reaches a terminal (success/failed), deferred, or rescheduled state, the Supervisor invokes ``PATCH /state`` with the final task status and metadata. | ||
|
|
||
| Supervisor & Task Runner | ||
| ------------------------ | ||
|
|
||
| Within an Airflow worker, a Supervisor process manages the execution of task instances: | ||
|
|
||
| - Spawns isolated subprocesses (Task Runners) for each task, following a parent–child model. | ||
| - Establishes dedicated STDIN, STDOUT, and log pipes to communicate with each subprocess. | ||
| - Proxies Execution API calls: forwards subprocess requests (e.g., variables, connections, XCom operations, state transitions) to the API server and relays responses. | ||
| - Monitors subprocess liveness via heartbeats and marks tasks as failed if heartbeats are missed. | ||
| - Generates and refreshes JWT tokens on behalf of subprocesses through heartbeat responses to ensure authenticated API calls. | ||
|
|
||
| A Task Runner subprocess provides a sandboxed environment where user task code runs: | ||
|
|
||
| - Receives startup messages (run parameters) via STDIN from the Supervisor. | ||
| - Executes the Python function or operator code in isolation. | ||
| - Emits logs through STDOUT and communicates runtime events (heartbeats, XCom messages) via the Supervisor. | ||
| - Performs final state transitions by sending authenticated API calls through the Supervisor. | ||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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.
Uh oh!
There was an error while loading. Please reload this page.