syedahsn commented on code in PR #32513:
URL: https://github.com/apache/airflow/pull/32513#discussion_r1265910807
##########
airflow/providers/amazon/aws/operators/emr.py:
##########
@@ -1355,6 +1438,24 @@ def execute(self, context: Context) -> None:
)
self.log.info("EMR serverless application %s stopped
successfully", self.application_id)
+ def stop_application(self, context, event=None) -> None:
+ if event["status"] == "success":
+ self.hook.conn.stop_application(applicationId=self.application_id)
+ self.defer(
+ trigger=EmrServerlessStopApplicationTrigger(
+ application_id=self.application_id,
+ aws_conn_id=self.aws_conn_id,
+ waiter_delay=self.waiter_delay,
+ waiter_max_attempts=self.waiter_max_attempts,
+ ),
+ timeout=timedelta(seconds=self.waiter_max_attempts *
self.waiter_delay),
+ method_name="execute_complete",
+ )
+
+ def execute_complete(self, context, event=None) -> None:
+ if event["status"] == "success":
+ self.log.info("EMR serverless application %s stopped
successfully", self.application_id)
Review Comment:
no we don't need to because the Trigger is the only place that generates the
`event` object, and in this case, the Trigger only sets the status to success
because if there was a failure, it would have raised an exception before
creating the event object, and this method would never have been executed.
Technically, we don't even need to check the status as it is because we know if
the execution gets this far, the operation was a success, but I think its good
practice to check anyways.
--
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]