Introductie tot Apache Airflow in 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')# Voegt toe: # Hi DataCamp - This goes in the logs! # aan de Airflow-logs
@task.bash
def bash_example():
return "echo 'Example!'"
bash_example()
@task.bash
def run_cleanup():
return "runcleanup.sh"
run_cleanup()

>> en <<
task1() >> task2()# task1 is klaar voordat task2 starttask1() >> task2() >> task3()# task1 is klaar voor task2 en task2 is klaar voor task3task1() >> task3() task2() >> task3()# task1 en task2 kunnen tegelijk draaien, maar beide moeten klaar zijn voor task3 draait
# Verkoopdata downloaden voor reconciliatie
download_sales_data() >> reconcile()
# Voorraaddata downloaden voor reconciliatie
download_inventory_data() >> reconcile()
Introductie tot Apache Airflow in Python