vincbeck commented on code in PR #77158:
URL: https://github.com/apache/airflow/pull/77158#discussion_r4615724174


##########
providers/amazon/src/airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -356,6 +361,44 @@ def submit_job(self, context: Context):
 
         self.job_id = response["jobId"]
         self.log.info("AWS Batch job (%s) started: %s", self.job_id, response)
+        self._persist_job_details_link(context)
+        return self.job_id
+
+    def get_job_status(self, external_id: JsonValue, context: Context) -> str:
+        jobs = self.hook.client.describe_jobs(jobs=[cast("str", 
external_id)])["jobs"]
+        return jobs[0]["status"] if jobs else "NOT_FOUND"
+
+    def is_job_active(self, status: str) -> bool:
+        return status in self.hook.INTERMEDIATE_STATES
+
+    def is_job_succeeded(self, status: str) -> bool:
+        return status == self.hook.SUCCESS_STATE
+
+    def poll_until_complete(self, external_id: JsonValue, context: Context) -> 
None:
+        self._attach_to_job(external_id, context)
+        if self.wait_for_completion:
+            self.monitor_job(context)
+
+    def get_job_result(self, external_id: JsonValue, context: Context) -> str 
| None:
+        # Not attached yet only when the stored job already succeeded, so 
monitor_job never ran.
+        if external_id is not None and self.job_id != external_id:
+            self._attach_to_job(external_id, context)
+            self._persist_links(context)
+            self._persist_cloudwatch_link(context)
+        return self.job_id
+
+    def _attach_to_job(self, external_id: JsonValue, context: Context) -> None:
+        # None comes from subclasses whose submit_job override predates it 
returning the job id;
+        # they still set self.job_id, so keep it.
+        if external_id is None:
+            self.log.warning("submit_job returned no job id, so a retry will 
submit a new job")

Review Comment:
   nit: this also logs with `durable=False` and on Airflow < 3.3, where a retry 
submits a new job anyway. Maybe only log it when `self.durable` is True?



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