ramitkataria commented on code in PR #55241:
URL: https://github.com/apache/airflow/pull/55241#discussion_r2330897422


##########
airflow-core/src/airflow/triggers/deadline.py:
##########
@@ -49,26 +49,25 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
         from airflow.models.deadline import DeadlineCallbackState  # to avoid 
cyclic imports
 
         try:
-            callback = import_string(self.callback_path)
             yield TriggerEvent({PAYLOAD_STATUS_KEY: 
DeadlineCallbackState.RUNNING})
+            callback = import_string(self.callback_path)
 
-            # TODO: get airflow context
-            context: dict = {}
-
-            result = await callback(**self.callback_kwargs, context=context)
-            log.info("Deadline callback completed with return value: %s", 
result)
+            # TODO: get full context and run template rendering. Right now, a 
simple context in included in `callback_kwargs`
+            result = await callback(**self.callback_kwargs)
             yield TriggerEvent({PAYLOAD_STATUS_KEY: 
DeadlineCallbackState.SUCCESS, PAYLOAD_BODY_KEY: result})
+
         except Exception as e:
             if isinstance(e, ImportError):
                 message = "Failed to import this deadline callback on the 
triggerer"
             elif isinstance(e, TypeError) and "await" in str(e):
                 message = "Failed to run this deadline callback because it is 
not awaitable"
             else:
                 message = "An error occurred during execution of this deadline 
callback"
-            log.exception("%s: %s; kwargs: %s\n%s", message, 
self.callback_path, self.callback_kwargs, e)
+
             yield TriggerEvent(
                 {
                     PAYLOAD_STATUS_KEY: DeadlineCallbackState.FAILED,
                     PAYLOAD_BODY_KEY: f"{message}: 
{traceback.format_exception(e)}",
                 }
             )
+            log.exception("%s: %s; kwargs: %s\n%s", message, 
self.callback_path, self.callback_kwargs, e)

Review Comment:
   Good point - fixed!



-- 
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]

Reply via email to