Introduction à Apache Airflow en Python
Mike Metzger
Data Engineer
@dag(
dag_id="Example_Dag"
)
def example_dag():
@task
def task1():
return "The result from task1"
task1()
example_dag()
from airflow.sdk import task@task def printme(): print("This goes in the logs!")printme()
@task def printme(name: str): print(f"Hi {name} - This goes in the logs!")printme(name='DataCamp')# Ajoute : # Hi DataCamp - This goes in the logs! # aux logs Airflow
@task.bash
def bash_example():
return "echo 'Example!'"
bash_example()
@task.bash
def run_cleanup():
return "runcleanup.sh"
run_cleanup()

>> et <<
task1() >> task2()# task1 se termine avant le démarrage de task2task1() >> task2() >> task3()# task1 se termine avant task2 et task2 avant task3task1() >> task3() task2() >> task3()# task1 et task2 peuvent s’exécuter ensemble mais doivent toutes deux finir avant task3
# Télécharger les ventes avant le rapprochement
download_sales_data() >> reconcile()
# Télécharger les stocks avant le rapprochement
download_inventory_data() >> reconcile()
Introduction à Apache Airflow en Python