Files
dag_airflow/hello_world.py
gitea_admin 48b9f96427 Ajouter hello_world.py
ajout example basique dag
2026-01-24 15:41:19 +00:00

30 lines
811 B
Python

from airflow.decorators import dag, task
from datetime import datetime
# 1. On définit le DAG avec le décorateur @dag
@dag(
dag_id="hello_world_taskflow",
start_date=datetime(2026, 1, 1),
schedule_interval="@daily", # Se lance tous les jours à minuit
catchup=False, # Ne rattrape pas les exécutions passées
tags=["exemple"],
)
def hello_world_dag():
# 2. On définit une première tâche
@task
def get_name():
return "Collaborateur"
# 3. On définit une deuxième tâche qui reçoit un paramètre
@task
def say_hello(name):
print(f"Hello {name} ! Bienvenue sur Airflow 2026.")
# 4. On définit l'ordre d'exécution (le workflow)
user_name = get_name()
say_hello(user_name)
# 5. On instancie le DAG
hello_world_dag()