ब्रांचिंग

Python में Apache Airflow परिचय

Mike Metzger

Data Engineer

ब्रांचिंग

  • कंडीशनल लॉजिक देता है (जैसे, if -> then वाले टास्क)
  • @task.branch का उपयोग करें

DNT_CURLY_TAG_2

  • अगला टास्क id (या ids की सूची) लौटाने के लिए एक Python फंक्शन चलाता है
Python में Apache Airflow परिचय

ब्रांचिंग उदाहरण

@task.branch
def branch_task(logical_date):
  if int(logical_date.month) % 3 == 0:
    # महीने 3 - March, 6 - June, 9 - September, 12 - December
    return 'end_of_quarter_task'
  else:
    # बाकी सभी महीने
    return 'regular_monthly_task'
Python में Apache Airflow परिचय

ब्रांचिंग उदाहरण

@task.branch
def branch_task(logical_date):
  if int(logical_date.month) % 3 == 0:
    # महीने 3 - March, 6 - June, 9 - September, 12 - December
    return 'end_of_quarter_task'
  else:
    # बाकी सभी महीने
    return 'regular_monthly_task'

start_task >> branch_task >> end_of_quarter_task >> end_of_quarter_task2
branch_task >> regular_monthly_task >> regular_monthly_task2
Python में Apache Airflow परिचय

ब्रांचिंग ग्राफ व्यू

दो डाउनस्ट्रीम टास्क पाथ वाले ब्रांचिंग Dag का Airflow ग्राफ व्यू

Python में Apache Airflow परिचय

ब्रांचिंग: क्वार्टर-अंत महीने

एंड-ऑफ-क्वार्टर टास्क चले और मंथली टास्क स्किप हुए ऐसा Airflow ग्राफ व्यू

Python में Apache Airflow परिचय

ब्रांचिंग: रेगुलर महीने

रेगुलर मंथली टास्क चले और क्वार्टर-अंत टास्क स्किप हुए ऐसा Airflow ग्राफ व्यू

Python में Apache Airflow परिचय

डेट वैरिएबल्स

  • ds - डैश सहित लॉजिकल डेट YYYY-MM-DD
  • ds_nodash - डैश बिना लॉजिकल डेट YYYYMMDD
  • prev_data_interval_start_success - पिछली सफल Dag रन की तारीख
  • और भी कई - Airflow variables डॉक्युमेंटेशन देखें
1 https://airflow.apache.org/docs/apache-airflow/stable/templates-ref.html#templates-variables
Python में Apache Airflow परिचय

अभ्यास करते हैं!

Python में Apache Airflow परिचय

Preparing Video For Download...