ferruzzi commented on code in PR #58248:
URL: https://github.com/apache/airflow/pull/58248#discussion_r2563930843
##########
airflow-core/src/airflow/models/serialized_dag.py:
##########
@@ -563,6 +680,65 @@ def data(self) -> dict | None:
return self.__data_cache
+ @classmethod
+ def _reconstruct_deadline_alerts(
+ cls,
+ dag_data: dict[str, Any],
+ serialized_dag_id: str,
+ session: Session,
+ ) -> dict[str, Any]:
+ """
+ Reconstruct DeadlineAlert objects from UUID references during
deserialization.
+
+ Queries the deadline_alert table to fetch full DeadlineAlert
definitions
+ and reconstructs them in the serialized format expected by
SerializedDAG.
+
+ :param dag_data: The serialized Dag data dictionary
+ :param serialized_dag_id: The serialized_dag ID
+ """
+ dag_deadline_data = dag_data.get("dag", {}).get("deadline")
+ if not dag_deadline_data:
+ return dag_data
+
+ deadline_list = dag_deadline_data if isinstance(dag_deadline_data,
list) else [dag_deadline_data]
+ deadline_alerts_by_id = {
+ str(alert.id): alert
+ for alert in session.execute(
+ select(DeadlineAlertModel).filter(
+ DeadlineAlertModel.id.in_(deadline_list),
+ DeadlineAlertModel.serialized_dag_id == serialized_dag_id,
+ )
+ )
+ .scalars()
Review Comment:
Thanks! I was a bit confused on when to use one vs the other, I think that
makes sense now. I'll make the changes.
--
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]