0
0
Apache Airflowdevops~10 mins

Creating custom operators in Apache Airflow - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the base class for creating a custom operator in Airflow.

Apache Airflow
from airflow.operators.[1] import BaseOperator
Drag options to blanks, or click blank then click option'
Abash
Bpython
Cbase
Dcustom
Attempts:
3 left
💡 Hint
Common Mistakes
Importing BaseOperator from the wrong module like 'python' or 'bash'.
Trying to import from a non-existing 'custom' module.
2fill in blank
medium

Complete the code to define the constructor method for a custom operator class.

Apache Airflow
def __init__(self, [1], **kwargs):
Drag options to blanks, or click blank then click option'
Atask_id
Bdag
Cparams
Dstart_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'dag' as the first parameter instead of 'task_id'.
Omitting the task_id parameter.
3fill in blank
hard

Fix the error in the execute method signature of the custom operator.

Apache Airflow
def execute(self, [1]):
Drag options to blanks, or click blank then click option'
Aself
Btask_instance
Cdag
Dcontext
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'self' as a parameter (already implicit).
Using 'dag' or 'task_instance' instead of 'context'.
4fill in blank
hard

Fill both blanks to call the parent constructor and pass parameters correctly.

Apache Airflow
super().[1](task_id=[2], **kwargs)
Drag options to blanks, or click blank then click option'
A__init__
Btask_id
Ctask
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Calling 'super().execute' instead of '__init__'.
Passing 'task' instead of 'task_id'.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters tasks with priority greater than 5.

Apache Airflow
high_priority_tasks = {task: [1] for task, [2] in tasks.items() if [3] > 5}
Drag options to blanks, or click blank then click option'
Apriority
Dtask
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'task' as the value instead of 'priority'.
Using wrong variable names in the condition.