LionelZhao28 commented on a change in pull request #17502:
URL: https://github.com/apache/airflow/pull/17502#discussion_r690458047
##########
File path: airflow/models/dagrun.py
##########
@@ -286,7 +287,17 @@ def find(
@staticmethod
def generate_run_id(run_type: DagRunType, execution_date: datetime) -> str:
"""Generate Run ID based on Run Type and Execution Date"""
- return f"{run_type}__{execution_date.isoformat()}"
+ from airflow.configuration import conf
+ local_run_id = conf.getboolean("core", "localize_dag_run_id",
fallback=False)
+ if local_run_id:
+ local_time =
pendulum.instance(execution_date).astimezone(tz=settings.TIMEZONE)
Review comment:
@ashb
Just confirm that the `dag timezone` is the value that is inited here?
https://github.com/apache/airflow/blob/e99624d2f17f0aadcb992827e9e721f5e6c978d8/airflow/models/dag.py#L326
Can we use the `tzinfo` in the `execution_date` directly?
Or we need to add a parameter `dag_timezone` in the method `generate_run_id`
and set the value when calling this method?
Or transform the date to dag timezone datetime outside?
##########
File path: airflow/models/dagrun.py
##########
@@ -286,7 +287,17 @@ def find(
@staticmethod
def generate_run_id(run_type: DagRunType, execution_date: datetime) -> str:
"""Generate Run ID based on Run Type and Execution Date"""
- return f"{run_type}__{execution_date.isoformat()}"
+ from airflow.configuration import conf
+ local_run_id = conf.getboolean("core", "localize_dag_run_id",
fallback=False)
+ if local_run_id:
+ local_time =
pendulum.instance(execution_date).astimezone(tz=settings.TIMEZONE)
Review comment:
@ashb
I checked the codes, we can not use the `tzinfo` in the execution_date
directly, because it has been transformed into UTC already.

So we have two ways to implement:
1. change the method generate_run_id from static method to class method
2. add a parameter `timezone` in the method `generate_run_id` and the
default value is settings.TIMEZONE.
Which one do you prefer? Or there is something I miss that we can have a
better choice?
Let me know what do you think.
Thanks
--
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]