Python ile Apache Airflow’a Giriş
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')# Şunları ekler: # Hi DataCamp - This goes in the logs! # Airflow günlüklerine
@task.bash
def bash_example():
return "echo 'Example!'"
bash_example()
@task.bash
def run_cleanup():
return "runcleanup.sh"
run_cleanup()

>> ve <<
task1() >> task2()# task2 başlamadan önce task1 tamamlanırtask1() >> task2() >> task3()# task2 başlamadan önce task1, task3 başlamadan önce task2 tamamlanırtask1() >> task3() task2() >> task3()# task1 ve task2 birlikte çalışabilir ancak her ikisi de bitmeden task3 çalışmaz
# Mutabakat öncesi satış verilerini indir
download_sales_data() >> reconcile()
# Mutabakat öncesi envanter verilerini indir
download_inventory_data() >> reconcile()
Python ile Apache Airflow’a Giriş