BaşlayınÜcretsiz Başlayın

Triggering a child Dag

You notice that some of your workflows are using similar components and realize you could separate out common tasks into their own Dag. This should allow you to run those components as necessary without maintaining multiple copies. You decide to execute a child Dag via a task within your current workflow.

The components dag, task, and datetime have been imported for you.

Bu egzersiz

Python ile Apache Airflow'a Giriş

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Import the operator needed to start a Dag from within your workflow.
  • Set the operator to trigger the Dag named child_pipeline.
  • Make sure the parent Dag waits for the triggered Dag to complete before continuing.
  • Set how frequently the operator checks whether the child Dag has finished.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import TriggerDagRunOperator
from airflow.providers.standard.operators.trigger_dagrun import ____

@dag(start_date=datetime(2026, 1, 1))
def parent_orchestrator_dag():
    
    # Trigger child_pipeline and wait for it to complete
    trigger_child = TriggerDagRunOperator(
        task_id="trigger_child_pipeline",
        trigger_dag_id="____",   
        ____=True,          
        ____=30,                  
        conf={"source": "s3://my-bucket/raw/"})

    validate() >> trigger_child >> post_trigger_summary()

parent_orchestrator_dag()
Kodu Düzenle ve Çalıştır