swapz-z commented on code in PR #28282:
URL: https://github.com/apache/airflow/pull/28282#discussion_r1050766440


##########
airflow/providers/amazon/aws/hooks/emr.py:
##########
@@ -202,6 +202,74 @@ def get_ui_field_behaviour() -> dict[str, Any]:
             },
         }
 
+    def is_cluster_available(self, emr_cluster_id, cluster_states):
+        response = self.get_conn().list_clusters(ClusterStates=cluster_states)
+        matching_clusters = list(
+            filter(lambda cluster: cluster["Id"] == emr_cluster_id, 
response["Clusters"])
+        )
+
+        if len(matching_clusters) == 1:
+            emr_cluster_name = matching_clusters[0]["Name"]
+            self.log.info("Found cluster name = %s id = %s", emr_cluster_name, 
emr_cluster_id)
+            return True
+        elif len(matching_clusters) > 1:
+            raise AirflowException(f"More than one cluster found for Id 
{emr_cluster_id}")
+        else:
+            self.log.info("No cluster found for Id %s", emr_cluster_id)
+            return False
+
+    def _get_list_of_steps_already_triggered(
+        self, cluster_id: str, step_states: list[str]
+    ) -> list[tuple[str, str]]:
+
+        response = self.get_conn().list_steps(
+            ClusterId=cluster_id,
+            StepStates=step_states,
+        )
+        steps_name_id = [(step["Name"], step["Id"]) for step in 
response["Steps"]]
+        print(steps_name_id)
+        return steps_name_id
+
+    def _cancel_list_of_steps_already_triggered(
+        self, steps: list[dict], cluster_id: str, step_states: list[str]
+    ):
+        names_list = self._get_list_of_steps_already_triggered(cluster_id, 
step_states)
+
+        self.log.info(steps)

Review Comment:
   Removed all the debug kind of log statements which were used during my 
testing.
   Added info logs wherever necessary to give better understanding about the 
flow of the operator to the user



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to