ferruzzi commented on code in PR #58248:
URL: https://github.com/apache/airflow/pull/58248#discussion_r2563927598
##########
airflow-core/src/airflow/serialization/serialized_objects.py:
##########
@@ -3361,27 +3356,77 @@ def create_dagrun(
)
if self.deadline:
- for deadline in cast("list", self.deadline):
- if isinstance(deadline.reference,
DeadlineReference.TYPES.DAGRUN):
- deadline_time = deadline.reference.evaluate_with(
- session=session,
- interval=deadline.interval,
- dag_id=self.dag_id,
- run_id=run_id,
- )
- if deadline_time is not None:
- session.add(
- Deadline(
- deadline_time=deadline_time,
- callback=deadline.callback,
- dagrun_id=orm_dagrun.id,
- dag_id=orm_dagrun.dag_id,
- )
- )
- Stats.incr("deadline_alerts.deadline_created",
tags={"dag_id": self.dag_id})
+ self._process_dagrun_deadline_alerts(orm_dagrun, session)
return orm_dagrun
+ def _process_dagrun_deadline_alerts(
+ self,
+ orm_dagrun: DagRun,
+ session: Session,
+ ) -> None:
+ """
+ Process deadline alerts for a newly created DagRun.
+
+ Creates Deadline records for any DeadlineAlerts that reference DAGRUN.
+
+ :param orm_dagrun: The newly created DagRun
+ :param session: Database session
+ """
+ # Import here to avoid circular dependency
+ from airflow.models.serialized_dag import SerializedDagModel
+
+ # Get the serialized_dag ID for this DAG
+ serialized_dag_id = session.scalar(
+ select(SerializedDagModel.id).where(SerializedDagModel.dag_id ==
self.dag_id).limit(1)
+ )
Review Comment:
Do you have a suggestion? I thought the serdag was versioned, one serdag
is one specific version of a given dag?
--
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]