uranusjr commented on code in PR #58025:
URL: https://github.com/apache/airflow/pull/58025#discussion_r2512870869
##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -516,22 +517,22 @@ def set_state(self, state: DagRunState) -> None:
raise ValueError(f"invalid DagRun state: {state}")
if self._state != state:
if state == DagRunState.QUEUED:
- self.queued_at = timezone.utcnow()
+ self.queued_at = pendulum.now(tz="UTC")
self.start_date = None
self.end_date = None
if state == DagRunState.RUNNING:
if self._state in State.finished_dr_states:
- self.start_date = timezone.utcnow()
+ self.start_date = pendulum.now(tz="UTC")
else:
- self.start_date = self.start_date or timezone.utcnow()
+ self.start_date = self.start_date or pendulum.now(tz="UTC")
self.end_date = None
if self._state in State.unfinished_dr_states or self._state is
None:
if state in State.finished_dr_states:
- self.end_date = timezone.utcnow()
+ self.end_date = pendulum.now(tz="UTC")
self._state = state
else:
if state == DagRunState.QUEUED:
- self.queued_at = timezone.utcnow()
Review Comment:
How about we just make utcnow() return a Pendulum DateTime?
pendulum.DateTime is a datetime.datetime subclass anyway so it shouldn’t (?)
break anything. Things like `convert_to_utc` already return pendulum.DateTime
anyway.
--
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]