Skills2026年4月13日·1 分钟阅读

Apache Airflow — Programmatic Workflow Orchestration Platform

Apache Airflow is the industry-standard platform for authoring, scheduling, and monitoring data workflows. Define DAGs in Python to orchestrate ETL pipelines, ML training, data processing, and any complex workflow with dependencies.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Community
入口
step-1.md
先审查命令
npx -y tokrepo@latest install 00a6152f-371c-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

TL;DR
Apache Airflow lets you define, schedule, and monitor data workflows as Python DAGs with a rich web UI.
§01

What it is

Apache Airflow is the industry-standard platform for authoring, scheduling, and monitoring data workflows. You define Directed Acyclic Graphs (DAGs) in Python to orchestrate ETL pipelines, ML training jobs, data processing, and any complex multi-step automation.

Airflow targets data engineers, ML engineers, and DevOps teams who need reliable, observable, and repeatable workflow execution. It provides a web UI for monitoring, alerting, and manual intervention.

The project is actively maintained and suitable for both individual developers and teams looking to integrate it into their existing toolchain. Documentation and community support are available for onboarding.

§02

How it saves time or tokens

Airflow replaces cron jobs, custom schedulers, and ad-hoc scripts with a single orchestration layer. Dependencies between tasks are explicit in the DAG definition. Retries, SLA monitoring, and failure callbacks are built in. The web UI shows exactly which task failed, when, and why, eliminating hours of log digging.

For teams evaluating multiple tools in the same category, the clear documentation and active community reduce the time spent on research and troubleshooting. Getting started takes minutes rather than hours of configuration.

§03

How to use

  1. Install Airflow via pip or use a managed service (Astronomer, MWAA, Cloud Composer).
  2. Write a DAG file in Python defining tasks and their dependencies.
  3. Place the DAG file in the dags/ directory. Airflow auto-detects and schedules it.
  4. Monitor execution in the web UI at localhost:8080. Trigger manual runs or retry failed tasks from the interface.
§04

Example

from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime

def extract():
    print('Extracting data from source')

def transform():
    print('Transforming data')

def load():
    print('Loading data to warehouse')

with DAG('etl_pipeline', start_date=datetime(2026, 1, 1),
         schedule='@daily', catchup=False) as dag:
    t1 = PythonOperator(task_id='extract', python_callable=extract)
    t2 = PythonOperator(task_id='transform', python_callable=transform)
    t3 = PythonOperator(task_id='load', python_callable=load)
    t1 >> t2 >> t3
§05

Related on TokRepo

§06

Common pitfalls

  • Writing heavy processing inside Airflow tasks. Airflow is an orchestrator, not a compute engine. Use it to trigger Spark, dbt, or Kubernetes jobs instead.
  • Setting catchup=True on a new DAG with a historical start_date. This creates hundreds of backfill runs that overwhelm your scheduler.
  • Not setting task-level retries and timeouts. Without them, a single stuck task blocks the entire DAG indefinitely.
  • Not reading the changelog before upgrading. Breaking changes between versions can cause unexpected failures in production. Pin your version and review release notes.

常见问题

What is a DAG in Airflow?+

A DAG (Directed Acyclic Graph) defines the order and dependencies of tasks in a workflow. Each node is a task, and edges define execution order. Airflow ensures tasks run in the correct sequence and handles retries on failure.

Can Airflow run on Kubernetes?+

Yes. The KubernetesExecutor spins up a new pod for each task, providing isolation and dynamic resource allocation. This is the recommended executor for production deployments with variable workloads.

How does Airflow compare to Prefect or Dagster?+

Airflow is the most mature and widely adopted. Prefect offers a more Pythonic API with dynamic task generation. Dagster focuses on data assets and type checking. All three handle workflow orchestration; Airflow has the largest community and integration library.

Is Airflow suitable for real-time streaming?+

No. Airflow is designed for batch workflows with scheduled or triggered execution. For real-time streaming, use Kafka, Flink, or Spark Streaming. Airflow can orchestrate the setup and monitoring of streaming pipelines.

What are the main Airflow executors?+

The three main executors are LocalExecutor (single machine, multiple processes), CeleryExecutor (distributed across workers via message queue), and KubernetesExecutor (one pod per task). Choose based on your scale and isolation requirements.

引用来源 (3)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产