Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the BashOperator from Airflow.
Apache Airflow
from airflow.operators.[1] import BashOperator
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'python' instead of 'bash_operator' as the module name.
Confusing BashOperator with other operators like EmailOperator.
✗ Incorrect
The BashOperator is imported from airflow.operators.bash_operator.
2fill in blank
mediumComplete the code to create a BashOperator task that runs 'echo Hello World'.
Apache Airflow
task = BashOperator(task_id='print_hello', bash_command='[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using commands that do not print 'Hello World'.
Forgetting to put the command inside quotes.
✗ Incorrect
The bash_command should be the shell command to run. Here, echo Hello World prints the message.
3fill in blank
hardFix the error in the BashOperator task by completing the missing argument.
Apache Airflow
task = BashOperator([1]='print_date', bash_command='date')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
bash_command instead of task_id as the first argument.Omitting the
task_id argument.✗ Incorrect
The task_id argument is required to name the task uniquely.
4fill in blank
hardFill both blanks to create a BashOperator that runs a command and assign it to a DAG.
Apache Airflow
task = BashOperator(task_id='list_files', bash_command='ls -l', [1]=[2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
default_args instead of dag.Passing the wrong variable name for the DAG.
✗ Incorrect
The dag argument assigns the task to the DAG object named my_dag.
5fill in blank
hardFill all three blanks to create a BashOperator with task_id, bash_command, and dag assigned.
Apache Airflow
task = BashOperator([1]='run_script', [2]='sh script.sh', [3]=my_dag)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up argument names.
Forgetting to assign the task to the DAG.
✗ Incorrect
The three main arguments are task_id, bash_command, and dag.