0
0
Apache Airflowdevops~10 mins

Managed Airflow (MWAA, Cloud Composer, Astronomer) - 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'
Amodels
Boperators
Chooks
Dsensors
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 schedule interval for a DAG to run daily.

Apache Airflow
dag = DAG('example_dag', schedule_interval=[1])
Drag options to blanks, or click blank then click option'
A'@once'
B'@daily'
C'@weekly'
D'@hourly'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '@hourly' or '@weekly' instead of '@daily'.
3fill in blank
hard

Fix the error in the task definition by completing the operator import.

Apache Airflow
from airflow.operators.[1] import BashOperator
Drag options to blanks, or click blank then click option'
Aemail
Bdummy
Cpython
Dbash
Attempts:
3 left
💡 Hint
Common Mistakes
Importing BashOperator from python or dummy modules.
4fill in blank
hard

Fill both blanks to create a task that runs a bash command in the DAG.

Apache Airflow
task1 = [1](task_id='print_date', bash_command=[2], dag=dag)
Drag options to blanks, or click blank then click option'
ABashOperator
B'date'
C'echo Hello World'
DPythonOperator
Attempts:
3 left
💡 Hint
Common Mistakes
Using PythonOperator instead of BashOperator.
Using wrong bash command string.
5fill in blank
hard

Fill all three blanks to define a DAG with default args and a Python task.

Apache Airflow
from datetime import datetime
default_args = {'owner': [1], 'start_date': [2]
dag = DAG('my_dag', default_args=default_args, schedule_interval='@daily')
def my_task():
    print('Hello Airflow')
task = [3](task_id='print_hello', python_callable=my_task, dag=dag)
Drag options to blanks, or click blank then click option'
A'airflow_user'
Bdatetime(2023, 1, 1)
CPythonOperator
DBashOperator
Attempts:
3 left
💡 Hint
Common Mistakes
Using BashOperator for a Python task.
Wrong format for start_date.
Owner not a string.