Python में Apache Airflow परिचय
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')# Adds: # Hi DataCamp - This goes in the logs! # to the Airflow logs
@task.bash
def bash_example():
return "echo 'Example!'"
bash_example()
@task.bash
def run_cleanup():
return "runcleanup.sh"
run_cleanup()

>> और <<
task1() >> task2()# task2 शुरू होने से पहले task1 पूरा होता हैtask1() >> task2() >> task3()# task2 से पहले task1 और task3 से पहले task2 पूरा होता हैtask1() >> task3() task2() >> task3()# task1 और task2 साथ चल सकते हैं पर दोनों के पूरा होने के बाद ही task3 चलेगा
# मिलान करने से पहले सेल्स डेटा डाउनलोड करें
download_sales_data() >> reconcile()
# मिलान करने से पहले इन्वेंटरी डेटा डाउनलोड करें
download_inventory_data() >> reconcile()
Python में Apache Airflow परिचय