You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/08/14 19:58:09 UTC

[GitHub] [airflow] feluelle commented on a change in pull request #9022: Fix AwsGlueJobSensor

feluelle commented on a change in pull request #9022:
URL: https://github.com/apache/airflow/pull/9022#discussion_r470836977



##########
File path: airflow/providers/amazon/aws/hooks/glue.py
##########
@@ -105,29 +105,46 @@ def initialize_job(self, script_arguments=None):
                 JobName=job_name,
                 Arguments=script_arguments
             )
-            return self.job_completion(job_name, job_run['JobRunId'])
+            return job_run
         except Exception as general_error:
             self.log.error("Failed to run aws glue job, error: %s", general_error)
             raise
 
+    def get_job_state(self, job_name=None, run_id=None):
+        """
+        Get state of the Glue job. The job state can be
+        running, finished, failed, stopped or timeout.
+        :param job_name: unique job name per AWS account
+        :type job_name: str
+        :param run_id: The job-run ID of the predecessor job run
+        :type run_id: str
+        :return: State of the Glue job
+        """
+        glue_client = self.get_conn()
+        job_status = glue_client.get_job_run(
+            JobName=job_name,
+            RunId=run_id,
+            PredecessorsIncluded=True
+        )
+        job_run_state = job_status['JobRun']['JobRunState']
+        return job_run_state

Review comment:
       ```suggestion
           job_run = glue_client.get_job_run(
               JobName=job_name,
               RunId=run_id,
               PredecessorsIncluded=True
           )
           return job_run['JobRunState']
   ```
   Shouldn't it be like this?




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