amoghrajesh commented on code in PR #77158:
URL: https://github.com/apache/airflow/pull/77158#discussion_r4612197641
##########
providers/amazon/src/airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -363,6 +368,40 @@ def submit_job(self, context: Context):
aws_partition=self.hook.conn_partition,
job_id=self.job_id,
)
+ 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:
+ self._attach_to_job(external_id, context)
+ return self.job_id
Review Comment:
`get_job_result` now persists the definition, queue and CloudWatch links on
the already succeeded path. Note: this also stops the job from being attached
twice on the fresh path. And this prevents a surprise to users used to seeing
more links.
##########
providers/amazon/src/airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -363,6 +368,40 @@ def submit_job(self, context: Context):
aws_partition=self.hook.conn_partition,
job_id=self.job_id,
)
+ 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:
+ self._attach_to_job(external_id, 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 or self.job_id == external_id:
+ return
+ self.job_id = cast("str", external_id)
+ BatchJobDetailsLink.persist(
Review Comment:
Done
--
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]