airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] nuclearpinguin commented on a change in pull request #6898: [AIRFLOW-6432] fix EmrAddStepsOperator broken ref & faulty test & add test case for missing cluster
Date Sat, 28 Dec 2019 18:36:26 GMT
nuclearpinguin commented on a change in pull request #6898: [AIRFLOW-6432] fix EmrAddStepsOperator
broken ref & faulty test & add test case for missing cluster
URL: https://github.com/apache/airflow/pull/6898#discussion_r361807954
 
 

 ##########
 File path: airflow/contrib/operators/emr_add_steps_operator.py
 ##########
 @@ -68,12 +68,16 @@ def __init__(
         self.steps = steps
 
     def execute(self, context):
-        emr = EmrHook(aws_conn_id=self.aws_conn_id).get_conn()
+        emr_hook = EmrHook(aws_conn_id=self.aws_conn_id)
+
+        emr = emr_hook.get_conn()
 
         job_flow_id = self.job_flow_id
 
         if not job_flow_id:
-            job_flow_id = emr.get_cluster_id_by_name(self.job_flow_name, self.cluster_states)
+            job_flow_id = emr_hook.get_cluster_id_by_name(self.job_flow_name, self.cluster_states)
+            if not job_flow_id:
+                raise AirflowException('No cluster found for name = %s' % self.job_flow_name)
 
 Review comment:
   ```suggestion
                   raise AirflowException(f'No cluster found for name: {self.job_flow_name}')
   ```
   But here we can use f-strings ✅

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message