0
0
Apache Airflowdevops~10 mins

Creating a basic DAG file in Apache Airflow - Interactive 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'
Amodels
Bsensors
Chooks
Doperators
Attempts:
3 left
💡 Hint
Common Mistakes
Importing DAG from operators or hooks instead of models.
2fill in blank
medium

Complete the code to set the DAG's start date using datetime.

Apache Airflow
from datetime import datetime
start_date = datetime([1])
Drag options to blanks, or click blank then click option'
A'2023-01-01'
B1, 1, 2023
Cdatetime(2023, 1, 1)
D2023, 1, 1
Attempts:
3 left
💡 Hint
Common Mistakes
Passing arguments in wrong order or as strings.
3fill in blank
hard

Fix the error in the DAG definition by completing the default_args dictionary key for retries.

Apache Airflow
default_args = {
    'owner': 'airflow',
    'start_date': start_date,
    'retries': [1]
}
Drag options to blanks, or click blank then click option'
A3
B'3'
CTrue
D'True'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the number or using boolean values.
4fill in blank
hard

Fill both blanks to create a DAG object with id 'example_dag' and schedule interval '@daily'.

Apache Airflow
dag = DAG(
    dag_id=[1],
    schedule_interval=[2]
)
Drag options to blanks, or click blank then click option'
A'example_dag'
B'@hourly'
C'@daily'
D'example'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong strings for dag_id or schedule_interval.
5fill in blank
hard

Fill all three blanks to define a PythonOperator task named 'print_date' that calls the 'print_date' function and uses the DAG object.

Apache Airflow
from airflow.operators.python import PythonOperator

def print_date():
    print('Current date')

print_date_task = PythonOperator(
    task_id=[1],
    python_callable=[2],
    dag=[3]
)
Drag options to blanks, or click blank then click option'
A'print_date'
Bprint_date
Cdag
D'print_date_task'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around the function name or wrong task_id string.