Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)22k · #10342

managed-airflow-dag-authoring

Skill này làm gì

Skill này giúp viết và kiểm thử các quy trình Airflow chạy trên Managed Service for Apache Airflow, trước đây gọi là Cloud Composer. Skill dành cho các nhóm dữ liệu và kỹ thuật lên lịch công việc bằng Airflow.

Khi nào nên dùng

  • ✓Khi bạn muốn tạo hoặc mở rộng một DAG Airflow cho Managed Airflow trên Google Cloud.
  • ✓Khi bạn cần kiểm tra mã DAG hoạt động với Airflow 2 hay Airflow 3.
  • ✓Khi bạn muốn kiểm tra mã DAG trên máy hoặc trên môi trường thật trước khi triển khai.

Liên kết skill

https://github.com/google/skills/blob/main/skills/cloud/managed-airflow-dag-authoring/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/google/skills/blob/main/skills/cloud/managed-airflow-dag-authoring/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Viết một DAG Airflow nạp file CSV từ Cloud Storage vào BigQuery mỗi đêm, rồi kiểm tra trước khi tôi triển khai.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Trước tiên skill kiểm tra môi trường và phiên bản Airflow, sau đó viết DAG theo các thực hành tốt nhất. Khi có quyền truy cập, skill kiểm tra mã trên máy hoặc trong môi trường đích.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

GCP Managed Airflow DAG Authoring Guide

This skill guides you through authoring and validating Apache Airflow DAGs for Managed Service for Apache Airflow (MSAA; formerly Cloud Composer) environments.


Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read Usage Attribution. For commands executed directly in the terminal (never in generated scripts, Terraform, or user code), prefix gcloud with CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:managed-airflow-dag-authoring)" and append agent-skills/1.0 (skill:managed-airflow-dag-authoring) to User-Agent headers.

Phase 1: Context Discovery

Before writing any DAG code, you MUST understand the constraints (e.g. version of Airflow) and capabilities of your target environment if user is willing to provide them.

1.1 Identify Target Environment & Access

Determine if you have direct access to the target Managed Airflow environment, local development environment or if you are working offline (only changing local files without validation).

  • If environment access is available: Use gcloud to inspect the environment (see Section 1.3).
  • If offline: Rely on user provided details.

1.2 Identify Development Environment

Determine if a local development environment is available.

  • Check if composer-dev CLI is installed.
  • Check if a local Python environment with airflow is available.

1.3 Inspect Target Environment (if available and requested)

Run the following commands to discover version constraints:

  1. Get Airflow/Image Version:

    gcloud composer environments describe {env_name} \
        --location {region} \
        --format="value(config.softwareConfig.imageVersion)"
    
  2. Get Installed Packages (Versions):

    gcloud composer environments describe {env_name} \
        --location {region} \
        --format="value(config.softwareConfig.pypiPackages)"
    
  3. Get DAGs GCS Bucket:

    gcloud composer environments describe {env_name} \
        --location {region} \
        --format="value(config.dagGcsPrefix)"
    

Phase 2: DAG Authoring Best Practices

2.1 General Airflow Best Practices

  • Idempotency: Every task SHOULD be idempotent. Running it multiple times with the same inputs (e.g., execution date) SHOULD produce the same result and not duplicate data.
  • No Top-Level Code Execution: Do NOT execute database queries, external API calls, or heavy computations at the top level of the DAG file (outside of tasks/operators). This code runs every few seconds during DAG parsing and will degrade performance.
  • Explicit Catchup: Always set catchup=False in the DAG definition unless historical backfilling is explicitly required.
  • Use Airflow Variables/Connections: Never hardcode credentials or environment-specific configs. Use Variable.get() (with deserialize_json=True if applicable) and BaseHook.get_connection(). Access variables via Jinja templates (e.g., {{ var.value.my_var }}) to avoid database calls during DAG parsing.

2.2 Airflow 2 vs Airflow 3 Compatibility

Use managed-airflow-migrations skill to navigate adjusting the code to specific target Airflow version.


Phase 3: Validation Process

You MUST validate DAGs before concluding your task.

3.1 Local Validation (Offline/Pre-deployment)

3.1.1 Static Analysis & Linting

Use ruff or pylint if available.

ruff check path/to/dag.py
  • If targeting Airflow 3, check with Airflow 3 rules if rulesets are available.

3.1.2 Local Dev Environment (composer-dev)

If the user has composer-dev configured:

  1. Copy the DAG to the local directory with DAGs:

    cp path/to/dag.py $(composer-dev describe {local_env} --format="value(dags_directory)")
    
  2. Verify parsing:

    composer-dev run-airflow-cmd {local_env} dags list-import-errors
    

3.2: Target Environment Validation

Only perform these steps if you have GCP access and are authorized to deploy to a target environment.

3.2.1 Deploy to GCS

Upload the DAG to t

Câu hỏi thường gặp

Skill có dùng được cho mã Python không liên quan đến Airflow không?

Không. Skill chỉ dành cho việc viết DAG Airflow.

Skill hỗ trợ những phiên bản Airflow nào?

Cả Airflow 2 và Airflow 3, kèm kiểm tra tương thích cho từng bản.

Nếu tôi làm việc ngoại tuyến thì sao?

Skill dựa vào thông tin bạn cung cấp và bỏ qua bước kiểm tra trực tiếp.

Chi tiết

Mô tả gốc của tác giả

Provides guidance for authoring Apache Airflow DAGs in Managed Service for Apache Airflow (MSAA; formerly Cloud Composer). Covers environment context discovery, Airflow 2 vs 3 compatibility, authoring best practices, and local/remote validation processes. Use when creating or extending an Airflow DAG. Don't use when authoring Python code unrelated to Airflow DAGs.

repo: google/skills

Độ phổ biến

Sao GitHub
22k
Vị trí xếp hạng
#10342
Giấy phép
Apache-2.0
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự