0
0
Apache Airflowdevops~10 mins

DAG concept (Directed Acyclic Graph) 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 import [1]
Drag options to blanks, or click blank then click option'
ADAG
BTask
COperator
DScheduler
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Task instead of DAG
Using Scheduler which is a different component
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'
A2023, 1, 1
B1, 1, 2023
C'2023-01-01'
Ddatetime.now()
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping month and year
Passing a string instead of integers
3fill in blank
hard

Fix the error in the DAG definition by completing the missing argument.

Apache Airflow
dag = DAG('example_dag', [1]=start_date)
Drag options to blanks, or click blank then click option'
Atasks
Bstart_date
Cdefault_args
Dschedule
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'schedule' instead of 'start_date'
Passing 'tasks' which is not a DAG argument
4fill in blank
hard

Fill both blanks to create a task using BashOperator with a command and assign it to the DAG.

Apache Airflow
from airflow.operators.bash import BashOperator

bash_task = BashOperator(task_id='print_date', bash_command=[1], dag=[2])
Drag options to blanks, or click blank then click option'
A'date'
Bdag
C'ls -l'
Dstart_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ls -l' instead of 'date' for this task
Passing start_date instead of dag object
5fill in blank
hard

Fill all three blanks to set task dependencies so task1 runs before task2 and task2 before task3.

Apache Airflow
task1 [1] task2
 task2 [2] task3

# Using Airflow's bitshift operators

[3]
Drag options to blanks, or click blank then click option'
A>>
B<<
Ctask1 >> task2 >> task3
Dtask3 >> task2 >> task1
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<<' which reverses the order
Writing the chain backwards