Aller au contenu

Concepts clés : DAG, Task, Operator

·1 min·
Airflow Data Engineering Industrialisation
Sommaire
Airflow - Cet article fait partie d'une série.
Partie 1: Cet article

Airflow orchestre des workflows sous forme de DAG.


DAG (Directed Acyclic Graph)
#

Un DAG définit :

  • un ensemble de tâches
  • leurs dépendances
  • leur planification

Caractéristiques :

  • orienté (ordre d’exécution défini)
  • acyclique (pas de boucle)
  • versionné en Python

Un DAG décrit la structure du pipeline, pas son exécution.


Task
#

Une Task est une unité de travail dans un DAG.

Elle représente :

  • une requête SQL
  • un script Python
  • un appel API
  • un job Docker
  • etc.

Chaque Task :

  • a un task_id
  • dépend éventuellement d’autres tâches
  • peut réussir ou échouer

Operator
#

Un Operator définit le type de travail effectué par une Task.

Exemples :

  • PythonOperator
  • BashOperator
  • DockerOperator
  • PostgresOperator
  • EmailOperator

Une Task = une instance d’un Operator.


Exemple minimal
#

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

def hello():
    print("Hello Airflow")

with DAG(
    dag_id="example_dag",
    start_date=datetime(2024, 1, 1),
    schedule="@daily",
    catchup=False
) as dag:

    task_hello = PythonOperator(
        task_id="hello_task",
        python_callable=hello
    )

Résumé
#

  • DAG → structure du pipeline
  • Task → unité de travail
  • Operator → type d’exécution
  • Un DAG est défini en Python
  • Airflow orchestre, il ne transforme pas les données lui-même
Thibault CLEMENT - Intechnia
Auteur
Thibault CLEMENT - Intechnia
Data scientist
Airflow - Cet article fait partie d'une série.
Partie 1: Cet article