본문으로 건너뛰기
cccskills
무료GitHub에 공개

airflow-best-practices

Apache Airflow best practices for DAG authoring, testing, and production deployment

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md3.3 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Apache Airflow Best Practices (3.2.0)

DAG Authoring

Imports (Airflow 3.x)

  • Use from airflow.sdk import DAG, task, Asset — the stable public API
  • Legacy from airflow.models import DAG and from airflow.decorators import task are deprecated

Top-Level Code (CRITICAL)

  • Avoid heavy computation at module level (executed on every DAG parse)
  • Minimize imports at module level — lazy-load inside @task functions
  • Never call APIs, query databases, or access Variables at top level
  • If Variables needed at top level, enable experimental cache with TTL

TaskFlow API (Default Pattern)

  • Use @task decorator for all Python tasks (preferred over classic operators)
  • XCom serialization is automatic — return values become XCom
  • Use @task.branch for branching logic
  • Use @task.sensor for sensor tasks

Dynamic Task Mapping

  • Use task.expand() for runtime-determined task instances
  • Combine with .partial() for fixed kwargs
  • Map over lists, dicts, or XCom outputs from upstream tasks

Scheduling

  • Use cron expressions or timetables for schedule parameter
  • Set catchup=False for most DAGs
  • Use data-aware scheduling with Asset (replaces Dataset) for dependencies
  • Configure SLA monitoring

Task Dependencies

  • Use >> / << operators for clarity
  • Group related tasks with TaskGroup
  • Avoid deep nesting (max 3 levels)

Testing

Local Testing

  • Use dag.test() in if __name__ == "__main__": block for IDE debugging
  • Runs all tasks in single serialized process without executor

Unit Tests

  • Test DAG import without errors
  • Detect cycles in dependencies
  • Mock external connections
  • Test task logic independently

Integration Tests

  • Use Airflow test mode
  • Validate end-to-end workflows
  • Test with sample data

Production Deployment

Performance

  • Lazy-load heavy libraries inside @task functions
  • Use connection pooling
  • Minimize DAG parse time (target < 30s for all DAGs)
  • Enable parallelism appropriately

Reliability

  • Set appropriate retries and retry_delay
  • Use SLA callbacks for monitoring
  • Implement proper error handling with on_failure_callback
  • Log important events

Migration: 2.x → 3.x

Deprecated (Remove or Replace)

DeprecatedReplacement
from airflow.models import DAGfrom airflow.sdk import DAG
from airflow.decorators import taskfrom airflow.sdk import task
DatasetAsset
execution_date in contextdag_run.logical_date
conf in task contextRemoved — use Variables or params

Architecture Changes

  • AIP-72: Task Execution Interface — tasks run in isolated subprocesses via Execution API Server
  • AIP-44: Internal API — components communicate via API, not direct DB access
  • New UI: React-based web interface (replaces Flask-based UI)

References

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Pre-action boundary checking — validates agent tool calls against declared capabilities and task contracts

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

baekenough/second-brain152026년 10월 8일 업데이트

Auto-detect project context and optimize harness — deactivate unused agents/skills, suggest missing experts, generate project profile

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

baekenough/second-brain152026년 10월 8일 업데이트

Adversarial code review using attacker mindset — trust boundary, attack surface, business logic, and defense evaluation

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

baekenough/second-brain152026년 10월 8일 업데이트

Alembic migration patterns for naming conventions, safety checks, expand-contract, env.py configuration, and CI integration

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

baekenough/second-brain152026년 10월 8일 업데이트

Pre-routing ambiguity analysis — scores request clarity and asks clarifying questions when needed (inspired by ouroboros)

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

baekenough/second-brain152026년 10월 8일 업데이트

AWS patterns from Well-Architected Framework

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

baekenough/second-brain152026년 10월 8일 업데이트

baekenough의 스킬 모두 보기

이 스킬의 문제 신고