Перейти к содержанию
Skillpedia
API и серверы (бэкенд)22k · #10342

managed-airflow-dag-authoring

Что он делает

Этот скилл помогает писать и тестировать процессы Airflow, которые работают в Managed Service for Apache Airflow, бывшем Cloud Composer. Он нужен командам данных и разработки, которые запускают задачи по расписанию с помощью Airflow.

Когда использовать

  • ✓Когда вы хотите создать или дополнить DAG Airflow для Managed Airflow в Google Cloud.
  • ✓Когда нужно проверить, работает ли код DAG с Airflow 2 или Airflow 3.
  • ✓Когда вы хотите проверить код DAG локально или в работающем окружении перед развёртыванием.

Ссылка на скилл

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

Скопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.

Как использовать

Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.

Готовое сообщение для вставки

Используй этот скилл, чтобы помочь мне: https://github.com/google/skills/blob/main/skills/cloud/managed-airflow-dag-authoring/SKILL.md Прочитай файл SKILL.md по этой ссылке и следуй его инструкциям в моей задаче.
Хотите, чтобы ваш ИИ сам находил такие скиллы?Установите бесплатный MCP Skillpedia: одна строка, и перед каждой задачей он ищет среди 15 000+ скиллов.Установить за 1 минуту →

Пример запроса к вашему ИИ

“Напиши DAG Airflow, который каждую ночь загружает CSV из Cloud Storage в BigQuery, и проверь его перед развёртыванием.”

5 новых скиллов в неделю. 1 минута чтения.

Как это работает

Сначала скилл проверяет окружение и версию Airflow, затем пишет DAG по лучшим практикам. Когда есть доступ, он проверяет код локально или в целевом окружении.

Технический текст (оригинальный SKILL.md)

Оригинальный текст автора на английском, прямо с GitHub.

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

Частые вопросы

Работает ли он с Python-кодом, не относящимся к Airflow?

Нет. Он предназначен только для написания DAG Airflow.

Какие версии Airflow он поддерживает?

И Airflow 2, и Airflow 3, с проверками совместимости для каждой версии.

Что делать, если я работаю без интернета?

Он опирается на данные, которые вы передаёте, и пропускает проверку в реальном окружении.

Подробности

Оригинальное описание автора

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

Популярность

Звёзды на GitHub
22k
Место в рейтинге
#10342
Лицензия
Apache-2.0
Обновлён
02.11.2026

Полезен ли этот скилл?

0

Войдите , чтобы голосовать.

Комментарии

  • …

Другие скиллы из этого репозитория

Похожие скиллы