Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using numeric values without quotes causes errors.
Using 'latest' does not specify a fixed version.
✗ Incorrect
The DAG version is often set as a simple string like 'v1' to track versions clearly.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect variable names causes import errors.
Using generic names like 'version' may conflict with other modules.
✗ Incorrect
The variable 'dag_version' is commonly used to hold the DAG version in config files.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '==' causes syntax errors.
Using '=>' is invalid syntax in Python.
✗ Incorrect
Use '==' to compare values in Python, '=' is for assignment.
4fill in blank
hardFill 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'
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.
✗ Incorrect
Each DAG version should map to its specific file path for clarity and version control.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '!=' includes 'v1' which is not desired.
Forgetting parentheses after 'endswith' causes errors.
✗ Incorrect
The code filters out version 'v1', checks if file ends with '.py', and uses parentheses for method call.