Complete the code to import the Airflow DAG class.
from airflow.[1] import DAG
The DAG class is imported from the airflow.models module.
Complete the code to set the start date for a DAG.
from datetime import datetime dag = DAG('example_dag', start_date=[1](2024, 1, 1))
date instead of datetime which lacks time info.timedelta which is for durations, not points in time.The start_date requires a datetime object to specify when the DAG should start running.
Fix the error in the code to correctly set the DAG schedule interval.
dag = DAG('example_dag', schedule_interval=[1])
The schedule_interval accepts cron presets as strings like '@daily'. The option daily without quotes is invalid.
Fill both blanks to create a task that tracks execution time using the PythonOperator.
from airflow.operators.python import PythonOperator def track_time(): print('Tracking execution time') task = PythonOperator(task_id=[1], python_callable=[2], dag=dag)
The task_id must be a string identifier, here 'track_time_task'. The python_callable is the function track_time that runs when the task executes.
Fill all three blanks to create a dictionary comprehension that tracks task durations longer than 5 minutes.
durations = {task_id: duration for task_id, duration in task_durations.items() if duration [1] [2] and task_id [3] 'task_1'}This comprehension filters tasks with duration greater than 300 seconds (5 minutes) and excludes the task with ID 'task_1'.