-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Closed
Closed
Copy link
Labels
area:corekind:bugThis is a clearly a bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yetlabel for new issues that we didn't triage yetpending-response
Description
Apache Airflow version
Other Airflow 2 version (please specify below)
If "Other Airflow 2 version" selected, which one?
2.7.2
What happened?
Dynamic DAG Params behaves differently in manually triggered run vs scheduled run.
- For manually triggered run, the UI calculates the
DAG conf Parametersand populate the values in theTrigger DAGpage. The values are then fixed in the DAG run. - For scheduled run, Airflow re-evaluates Params for each task run. This is unexpected and different from manually triggered run behavior
What you think should happen instead?
Scheduled run should behave the same as manually triggered run. i.e. the value of DAG level Params should only be evaluated once.
How to reproduce
- Create a simple DAG that contains a DAG-level Param using `pendulum.now("America/Los_Angeles")
import pendulum
from airflow.models.dag import DAG
from airflow.models.param import Param
from airflow.operators.python import PythonOperator
def print_param(date, **context):
print(date)
with DAG(
dag_id="test_param_behavior",
start_date=pendulum.datetime(2024, 4, 16, tz="America/Los_Angeles"),
schedule='0 * * * *',
catchup=False,
params={
"date": Param(
default=pendulum.now("America/Los_Angeles").strftime("%Y-%m-%d, %H:%M:%S")
)
},
) as dag:
PythonOperator(
task_id="print_date",
python_callable=print_param,
op_kwargs={"date": "{{params.date}}"},
)
- Scheduled run behavior - The above DAG runs every hour. Once a schedule run is completed, examine the log in
print_date. Clear the task and examine the log in attempt Bring in more resolution to hivestats #2, the timestamp is now a different value - Manually triggered behavior - Manually trigger the DAG. Once the run is completed, clear
print_datetask and examine the log in attempt Bring in more resolution to hivestats #2, the timestamp should be identical to the timestamp in attempt Improving the search functionality in the graph view #1
Operating System
Amazon Linux 2
Versions of Apache Airflow Providers
No response
Deployment
Amazon (AWS) MWAA
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
area:corekind:bugThis is a clearly a bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yetlabel for new issues that we didn't triage yetpending-response