Airflow-taken

Introductie tot Apache Airflow in Python

Mike Metzger

Data Engineer

Taken

Taken zijn:

  • Instanties van operators
  • Meestal toegewezen aan een variabele in Python
    example_task = BashOperator(task_id='bash_example',
                              bash_command='echo "Example!"')
    
  • Binnen Airflow-tools aangeduid via task_id
Introductie tot Apache Airflow in Python

Taakafhankelijkheden

$$

  • Bepalen de volgorde van taakafronding
  • Niet verplicht voor een workflow, maar meestal wel aanwezig
  • Heet upstream of downstream taken
  • In Airflow 1.8 en later gedefinieerd met bitshift-operators
    • >>, de upstream-operator
    • <<, de downstream-operator
Introductie tot Apache Airflow in Python

Upstream vs. downstream

Upstream betekent ervoor

Downstream betekent erna

Introductie tot Apache Airflow in Python

Eenvoudige taakafhankelijkheid

# Define the tasks
task1 = BashOperator(task_id='first_task',
                     bash_command='echo 1'
                    )

task2 = BashOperator(task_id='second_task', bash_command='echo 2' )
# Set first_task to run before second_task task1 >> task2 # or task2 << task1
Introductie tot Apache Airflow in Python

Taakafhankelijkheden in de Airflow-UI

eenvoudige afhankelijkheid DAG-weergave

Introductie tot Apache Airflow in Python

Taakafhankelijkheden in de Airflow-UI

eenvoudige afhankelijkheid DAG-weergave, taakmarkering

Introductie tot Apache Airflow in Python

Taakafhankelijkheden in de Airflow-UI

eenvoudige afhankelijkheid DAG met bitshift

Introductie tot Apache Airflow in Python

Meerdere afhankelijkheden

Geketen afhankelijkheden:

task1 >> task2 >> task3 >> task4

Gemengde afhankelijkheden:

task1 >> task2 << task3

of:

task1 >> task2
task3 >> task2

gekete afhankelijkheden

gemengde afhankelijkheden

Introductie tot Apache Airflow in Python

Laten we oefenen!

Introductie tot Apache Airflow in Python

Preparing Video For Download...