0
0
Apache Airflowdevops~10 mins

Cost optimization for cloud resources 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 set the default retry delay to 5 minutes in an Airflow DAG.

Apache Airflow
default_args = {
    'retry_delay': timedelta(minutes=[1])
}
Drag options to blanks, or click blank then click option'
A10
B5
C15
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using too short retry delays causing frequent retries and higher costs.
Using too long retry delays delaying task recovery.
2fill in blank
medium

Complete the code to schedule the DAG to run once every day at midnight.

Apache Airflow
dag = DAG(
    'cost_optimization',
    schedule_interval='[1]',
    default_args=default_args
)
Drag options to blanks, or click blank then click option'
A'@hourly'
B'@daily'
C'@weekly'
D'0 0 * * *'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '@hourly' which runs every hour, increasing costs.
Using '@weekly' which runs once a week, missing daily checks.
3fill in blank
hard

Fix the error in the task definition by completing the operator name correctly.

Apache Airflow
task1 = [1](
    task_id='check_unused_resources',
    bash_command='echo Checking unused cloud resources',
    dag=dag
)
Drag options to blanks, or click blank then click option'
ADummyOperator
BPythonOperator
CBashOperator
DEmailOperator
Attempts:
3 left
💡 Hint
Common Mistakes
Using PythonOperator without a Python callable.
Using DummyOperator which does nothing.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps resource names to their cost if the cost is greater than 0.

Apache Airflow
costs = {resource: [1] for resource, cost in resource_costs.items() if cost [2] 0}
Drag options to blanks, or click blank then click option'
Acost
B<
C>
Dresource
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' causing incorrect filtering.
Mapping resource to resource name instead of cost.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary of resources with cost above 100, using uppercase resource names as keys.

Apache Airflow
filtered_costs = { [1]: [2] for [3], cost in resource_costs.items() if cost > 100}
Drag options to blanks, or click blank then click option'
Aresource.upper()
Bcost
Cresource
Dcosts
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'costs' as a variable instead of 'cost'.
Not converting resource names to uppercase.