ramitkataria commented on code in PR #53951:
URL: https://github.com/apache/airflow/pull/53951#discussion_r2255526254
##########
airflow-core/src/airflow/models/deadline.py:
##########
@@ -193,18 +195,30 @@ def prune_deadlines(cls, *, session: Session, conditions:
dict[Column, Any]) ->
return deleted_count
+ @cached_property
+ def callback(self) -> Callback:
+ return cast("Callback", deserialize(self._callback))
+
def handle_miss(self, session: Session):
- """Handle a missed deadline by creating a trigger to run the
callback."""
- # TODO: check to see if the callback is meant to run in triggerer or
executor. For now, the code below assumes it's for the triggerer
- callback_trigger = DeadlineCallbackTrigger(
- callback_path=self.callback,
- callback_kwargs=self.callback_kwargs,
- )
+ """Handle a missed deadline by running the callback in the appropriate
host and updating the `callback_state`."""
+ from airflow.sdk.definitions.deadline import AsyncCallback,
SyncCallback
+
+ if isinstance(self.callback, AsyncCallback):
+ callback_trigger = DeadlineCallbackTrigger(
+ callback_path=self.callback.path,
+ callback_kwargs=self.callback.kwargs,
+ )
+ trigger_orm = Trigger.from_object(callback_trigger)
+ session.add(trigger_orm)
+ session.flush()
+ self.trigger = trigger_orm
Review Comment:
Yes, this was intentional - I realized that this is probably the way
SQLAlchemy wants us to use `relationship`
--
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]