jianqiuhuang opened a new issue, #39904:
URL: https://github.com/apache/airflow/issues/39904

   ### 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 Parameters` 
and populate the values in the `Trigger DAG` page. 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
   
   1. 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}}"},
       )
   
   ```
   2. 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 #2, the timestamp is now a different value
   3. Manually triggered behavior - Manually trigger the DAG. Once the run is 
completed, clear `print_date` task and examine the log in attempt #2, the 
timestamp should be identical to the timestamp in attempt #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?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to