0
0
Apache Airflowdevops~10 mins

DAG performance tracking in Apache Airflow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Airflow DAG class.

Apache Airflow
from airflow.[1] import DAG
Drag options to blanks, or click blank then click option'
Ahooks
Boperators
Cmodels
Dutils
Attempts:
3 left
💡 Hint
Common Mistakes
Importing DAG from operators or hooks instead of models.
Using incorrect module names.
2fill in blank
medium

Complete the code to set the start date for a DAG.

Apache Airflow
from datetime import datetime

dag = DAG('example_dag', start_date=[1](2024, 1, 1))
Drag options to blanks, or click blank then click option'
Adate
Btime
Ctimedelta
Ddatetime
Attempts:
3 left
💡 Hint
Common Mistakes
Using date instead of datetime which lacks time info.
Using timedelta which is for durations, not points in time.
3fill in blank
hard

Fix the error in the code to correctly set the DAG schedule interval.

Apache Airflow
dag = DAG('example_dag', schedule_interval=[1])
Drag options to blanks, or click blank then click option'
A'@daily'
Bdaily
Ctimedelta(days=1)
D'daily'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted words like daily which cause syntax errors.
Using timedelta objects directly which is not accepted here.
4fill in blank
hard

Fill both blanks to create a task that tracks execution time using the PythonOperator.

Apache Airflow
from airflow.operators.python import PythonOperator

def track_time():
    print('Tracking execution time')

task = PythonOperator(task_id=[1], python_callable=[2], dag=dag)
Drag options to blanks, or click blank then click option'
A'track_time_task'
Btrack_time
C'execution_time'
Dprint_time
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name as task_id without quotes.
Passing a string as python_callable instead of a function reference.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that tracks task durations longer than 5 minutes.

Apache Airflow
durations = {task_id: duration for task_id, duration in task_durations.items() if duration [1] [2] and task_id [3] 'task_1'}
Drag options to blanks, or click blank then click option'
A>
B300
C!=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' causing wrong filtering.
Using '==' instead of '!=' to exclude the task.