Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Apache Airflow Execute Workload

From Leeroopedia


Knowledge Sources
Domains Execution, Task_SDK
Last Updated 2026-02-08 00:00 GMT

Overview

Concrete tool for executing task workloads in isolated environments provided by the Task SDK.

Description

The execute_workload function is the entry point for task execution in isolated environments. It receives an ExecuteTask workload containing the task identity, DAG file path, bundle information, JWT token, and log path. The supervise function in the Task SDK manages the actual execution lifecycle including signal handling, heartbeats, and result reporting via the Execution API.

Usage

This is called internally by executors when dispatching tasks. Not typically invoked directly by users.

Code Reference

Source Location

  • Repository: Apache Airflow
  • File: task-sdk/src/airflow/sdk/execution_time/execute_workload.py
  • File: task-sdk/src/airflow/sdk/execution_time/supervisor.py

Signature

def execute_workload(workload: ExecuteTask) -> None:
    """Execute a task workload in the current process."""
    # workload.ti: TaskInstance — task to execute
    # workload.dag_rel_path: str — DAG file path
    # workload.bundle_info — bundle metadata
    # workload.token: str — JWT auth token
    # workload.log_path: str — log output path
    ...

Import

from airflow.sdk.execution_time.execute_workload import execute_workload

I/O Contract

Inputs

Name Type Required Description
workload ExecuteTask Yes Contains task identity, DAG path, JWT token
DAG file Python file Yes DAG source file accessible at dag_rel_path

Outputs

Name Type Description
Task result State Success or failure state via Execution API
XCom values JSON Task return values pushed to API
Logs Text Task execution logs written to log_path

Usage Examples

Internal Executor Dispatch

# Internal to executor — not called directly by users
from airflow.sdk.execution_time.execute_workload import execute_workload

workload = ExecuteTask(
    ti=task_instance,
    dag_rel_path="dags/my_dag.py",
    token="jwt-token-here",
    log_path="/logs/my_task.log",
)
execute_workload(workload)

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment