0
0
Apache Airflowdevops~10 mins

PythonOperator for custom logic 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 PythonOperator from Airflow.

Apache Airflow
from airflow.operators.[1] import PythonOperator
Drag options to blanks, or click blank then click option'
Apython
Bdummy
Cemail
Dbash
Attempts:
3 left
💡 Hint
Common Mistakes
Importing from the wrong operator module like 'bash' or 'email'.
Misspelling 'python' in the import statement.
2fill in blank
medium

Complete the code to define a Python function named 'my_task' that prints 'Hello Airflow'.

Apache Airflow
def [1]():
    print('Hello Airflow')
Drag options to blanks, or click blank then click option'
Ahello
Brun_task
Ctask_func
Dmy_task
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different function name than 'my_task'.
Forgetting to define a function.
3fill in blank
hard

Fix the error in the PythonOperator task by completing the argument that specifies the Python callable.

Apache Airflow
task = PythonOperator(
    task_id='print_hello',
    python_callable=[1],
    dag=dag
)
Drag options to blanks, or click blank then click option'
Aprint('my_task')
Bmy_task()
Cmy_task
D'my_task'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the function call with parentheses.
Passing the function name as a string.
4fill in blank
hard

Fill both blanks to create a DAG with id 'my_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'my_dag'
B'@hourly'
C'@daily'
D'default_dag'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong schedule interval like '@hourly'.
Not using quotes around strings.
5fill in blank
hard

Fill all three blanks to create a PythonOperator named 'task' with task_id 'print_hello', using the function 'my_task' and the DAG 'dag'.

Apache Airflow
task = [1](
    task_id=[2],
    python_callable=[3],
    dag=dag
)
Drag options to blanks, or click blank then click option'
APythonOperator
B'print_hello'
Cmy_task
DBashOperator
Attempts:
3 left
💡 Hint
Common Mistakes
Using BashOperator instead of PythonOperator.
Passing task_id without quotes.
Passing python_callable as a string or with parentheses.