0
0
Apache Airflowdevops~10 mins

BashOperator for shell commands 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 BashOperator from Airflow.

Apache Airflow
from airflow.operators.[1] import BashOperator
Drag options to blanks, or click blank then click option'
Apython
Bbash_operator
Cemail
Ddummy
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'python' instead of 'bash_operator' as the module name.
Confusing BashOperator with other operators like EmailOperator.
2fill in blank
medium

Complete 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'
Als -l
Bpwd
Cdate
Decho Hello World
Attempts:
3 left
💡 Hint
Common Mistakes
Using commands that do not print 'Hello World'.
Forgetting to put the command inside quotes.
3fill in blank
hard

Fix 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'
Adag
Bbash_command
Ctask_id
Downer
Attempts:
3 left
💡 Hint
Common Mistakes
Using bash_command instead of task_id as the first argument.
Omitting the task_id argument.
4fill in blank
hard

Fill 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'
Adag
Bmy_dag
Cdefault_args
Dargs
Attempts:
3 left
💡 Hint
Common Mistakes
Using default_args instead of dag.
Passing the wrong variable name for the DAG.
5fill in blank
hard

Fill 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'
Atask_id
Bbash_command
Cdag
Downer
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up argument names.
Forgetting to assign the task to the DAG.