XCom के साथ डेटा पास करना
आप एक ETL workflow को अपडेट कर रहे हैं ताकि जानकारी को आसान तरीके से track रखने के लिए XCom का इस्तेमाल किया जा सके. इस कारण, आपको अपने Dag में tasks के बीच dependencies अपडेट करनी हैं.
आपके पास चार tasks पहले से defined हैं, जिन्हें इस प्रकार उपयोग किया जा सकता है:
extract()-order_dataरिटर्न करता हैtransform(order_data)- summarized data रिटर्न करता हैload(summary_data)- XCom जानकारी रिटर्न नहीं करताsend_report()- एक non-XCom task जो notifications संभालता है
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Apache Airflow परिचय
अभ्यास निर्देश
- चेन पूरी करने के लिए
extract()औरload()के बीचtransformटास्क insert करें. - परिणाम को
etl_resultनाम के वैरिएबल में असाइन करें. etl_resultवैरिएबल के बादsend_reportचलने के लिए सेट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
@dag(start_date=datetime(2026,4,1))
def etl_example():
# Chain extract, transform, and load, assigning the result
____ = load(____(extract()))
# Run send_report after the ETL tasks
etl_result ____ ____()
etl_example()