0
0
Apache Airflowdevops~10 mins

DAG parsing and import errors 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 DAG class from Airflow.

Apache Airflow
from airflow.[1] import DAG
Drag options to blanks, or click blank then click option'
Aoperators
Bhooks
Cmodels
Dutils
Attempts:
3 left
💡 Hint
Common Mistakes
Importing DAG from the wrong module causes import errors during DAG parsing.
2fill in blank
medium

Complete the code to define the DAG's start date using Airflow's datetime utility.

Apache Airflow
from airflow.utils.dates import [1]

start_date = [1](1)
Drag options to blanks, or click blank then click option'
Adays_ago
Bdatetime
Ctimedelta
Dtimezone
Attempts:
3 left
💡 Hint
Common Mistakes
Using Python's standard datetime instead of Airflow's utility can cause timezone problems.
3fill in blank
hard

Fix the error in the DAG import statement to avoid parsing errors.

Apache Airflow
from airflow.operators.bash import [1]Operator

bash_task = [1]Operator(task_id='print_date', bash_command='date')
Drag options to blanks, or click blank then click option'
Abash
BBash
CBashOperator
Dbashoperator
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or incorrect casing causes import or attribute errors.
4fill in blank
hard

Fill both blanks to correctly define a DAG with a daily schedule and a default argument for retries.

Apache Airflow
default_args = {'retries': [1]
dag = DAG('example_dag', default_args=default_args, schedule_interval=[2])
Drag options to blanks, or click blank then click option'
A1
B'@daily'
C'@hourly'
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 retries disables retries, which might not be desired.
Using wrong schedule strings causes DAG not to run as expected.
5fill in blank
hard

Fill all three blanks to create a task using PythonOperator with a callable function and assign it to the DAG.

Apache Airflow
def my_task():
    print('Hello Airflow')

from airflow.operators.python import [1]
task = [1](task_id=[2], python_callable=[3], dag=dag)
Drag options to blanks, or click blank then click option'
APythonOperator
B'my_task'
Cmy_task
D'print_hello'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the function name in quotes for python_callable causes errors.
Using incorrect task_id strings or missing dag parameter causes DAG parsing failures.