eladkal commented on code in PR #27286:
URL: https://github.com/apache/airflow/pull/27286#discussion_r1008401878


##########
airflow/providers/amazon/aws/operators/emr.py:
##########
@@ -113,11 +118,21 @@ def execute(self, context: Context) -> list[str]:
 
         response = emr.add_job_flow_steps(JobFlowId=job_flow_id, Steps=steps)
 
-        if not response["ResponseMetadata"]["HTTPStatusCode"] == 200:
+        if response["ResponseMetadata"]["HTTPStatusCode"] != 200:
             raise AirflowException(f"Adding steps failed: {response}")
-        else:
-            self.log.info("Steps %s added to JobFlow", response["StepIds"])
-            return response["StepIds"]
+
+        self.log.info("Steps %s added to JobFlow", response["StepIds"])
+        if self.wait_for_completion:
+            for step_id in response["StepIds"]:
+                boto3.client("emr").get_waiter("step_complete").wait(
+                    ClusterId=self.job_flow_id,
+                    StepId=step_id,
+                    WaiterConfig={
+                        "Delay": 5,
+                        "MaxAttempts": 100,
+                    },
+                )
+        return response["StepIds"]

Review Comment:
   I'm not sure if this should be in the operator. it feels more like it should 
be in the hook.
   For example in SageMakerHook we have:
   
   
https://github.com/apache/airflow/blob/9ab1a6a3e70b32a3cddddf0adede5d2f3f7e29ea/airflow/providers/amazon/aws/hooks/sagemaker.py#L647
   
   which is utalized by operators:
   
https://github.com/apache/airflow/blob/2a34dc9e8470285b0ed2db71109ef4265e29688b/airflow/providers/amazon/aws/operators/sagemaker.py#L709



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