0
0
Apache Airflowdevops~10 mins

DAG versioning strategies 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 DAG version using a variable.

Apache Airflow
dag_version = '[1]'
Drag options to blanks, or click blank then click option'
Av1
B1.0
Cversion1
Dlatest
Attempts:
3 left
💡 Hint
Common Mistakes
Using numeric values without quotes causes errors.
Using 'latest' does not specify a fixed version.
2fill in blank
medium

Complete the code to import the DAG version from a configuration file.

Apache Airflow
from config import [1]
Drag options to blanks, or click blank then click option'
Aversion_number
Bversion
Cdag_ver
Ddag_version
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect variable names causes import errors.
Using generic names like 'version' may conflict with other modules.
3fill in blank
hard

Fix the error in the DAG version check condition.

Apache Airflow
if dag_version [1] 'v2':
    print('Using version 2 DAG')
Drag options to blanks, or click blank then click option'
A==
B!=
C=
D=>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '==' causes syntax errors.
Using '=>' is invalid syntax in Python.
4fill in blank
hard

Fill both blanks to create a dictionary mapping DAG versions to file paths.

Apache Airflow
dag_files = {'v1': '[1]', 'v2': '[2]'}
Drag options to blanks, or click blank then click option'
A/dags/dag_v1.py
B/dags/dag_latest.py
C/dags/dag_v2.py
D/dags/dag_old.py
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing file paths causes confusion in version management.
Using generic file names like 'dag_latest.py' loses version specificity.
5fill in blank
hard

Fill all three blanks to filter DAG versions and print active ones.

Apache Airflow
active_dags = {k: v for k, v in dag_files.items() if k [1] 'v1' and v [2] '.py' and 'latest' not in v[3]
Drag options to blanks, or click blank then click option'
A!=
Bendswith
C()
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '!=' includes 'v1' which is not desired.
Forgetting parentheses after 'endswith' causes errors.