Challenge - 5 Problems
Default Args & DAG Parameters Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the start_date of the DAG?
Given this Airflow DAG snippet, what is the effective
start_date of the DAG tasks?default_args = {
'owner': 'airflow',
'start_date': datetime(2024, 1, 1)
}
dag = DAG(
'example_dag',
default_args=default_args,
start_date=datetime(2024, 2, 1),
schedule_interval='@daily'
)Apache Airflow
from datetime import datetime from airflow import DAG default_args = { 'owner': 'airflow', 'start_date': datetime(2024, 1, 1) } dag = DAG( 'example_dag', default_args=default_args, start_date=datetime(2024, 2, 1), schedule_interval='@daily' )
Attempts:
2 left
💡 Hint
The DAG parameter
start_date overrides the one in default_args.✗ Incorrect
When both DAG and default_args specify
start_date, the DAG's own start_date takes precedence for scheduling.🧠 Conceptual
intermediate2:00remaining
What happens if a task has no start_date but DAG has one?
In Airflow, if a DAG has a
Choose the correct behavior.
start_date defined but a task inside it does not specify any start_date, what will be the task's effective start_date?Choose the correct behavior.
Attempts:
2 left
💡 Hint
Tasks inherit missing parameters from DAG or default_args.
✗ Incorrect
If a task does not specify
start_date, it inherits the DAG's start_date or from default_args if provided.❓ Configuration
advanced2:00remaining
Identify the error in this DAG default_args usage
Examine the following DAG code snippet. What error will occur when Airflow tries to parse this DAG?
default_args = {
'owner': 'airflow',
'start_date': '2024-01-01'
}
dag = DAG(
'faulty_dag',
default_args=default_args,
schedule_interval='@daily'
)Apache Airflow
from datetime import datetime from airflow import DAG default_args = { 'owner': 'airflow', 'start_date': '2024-01-01' } dag = DAG( 'faulty_dag', default_args=default_args, schedule_interval='@daily' )
Attempts:
2 left
💡 Hint
Check the type of the start_date value.
✗ Incorrect
Airflow requires
start_date to be a datetime object, not a string. Using a string causes a TypeError.🔀 Workflow
advanced2:30remaining
Order the steps to override default_args in a DAG
Put these steps in the correct order to override a default argument in an Airflow DAG.
Steps:
1. Pass the new argument value directly in the DAG constructor
2. Define default_args dictionary with base parameters
3. Create the DAG object with default_args parameter
4. Import required modules and datetime
Steps:
1. Pass the new argument value directly in the DAG constructor
2. Define default_args dictionary with base parameters
3. Create the DAG object with default_args parameter
4. Import required modules and datetime
Attempts:
2 left
💡 Hint
Start with imports, then define defaults, create DAG, then override.
✗ Incorrect
First import modules, then define default_args, create DAG with default_args, finally override parameters in DAG constructor.
❓ Troubleshoot
expert3:00remaining
Why does this DAG fail to schedule despite correct start_date?
You have this DAG snippet:
The DAG never runs any tasks even after 2024-04-01. What is the most likely reason?
default_args = {
'owner': 'airflow',
'start_date': datetime(2024, 4, 1)
}
dag = DAG(
'test_dag',
default_args=default_args,
schedule_interval='@daily',
catchup=False
)
# Task definition omitted for brevity
The DAG never runs any tasks even after 2024-04-01. What is the most likely reason?
Apache Airflow
from datetime import datetime from airflow import DAG default_args = { 'owner': 'airflow', 'start_date': datetime(2024, 4, 1) } dag = DAG( 'test_dag', default_args=default_args, schedule_interval='@daily', catchup=False )
Attempts:
2 left
💡 Hint
Check the system date vs start_date.
✗ Incorrect
If the DAG's start_date is in the future relative to the scheduler's current date, no runs are triggered yet.