jedcunningham commented on code in PR #31591:
URL: https://github.com/apache/airflow/pull/31591#discussion_r1223297142
##########
airflow/providers/google/cloud/hooks/bigquery.py:
##########
@@ -3086,30 +3086,19 @@ async def get_job_instance(
with await self.service_file_as_context() as f:
return Job(job_id=job_id, project=project_id, service_file=f,
session=cast(Session, session))
- async def get_job_status(
- self,
- job_id: str | None,
- project_id: str | None = None,
- ) -> str | None:
- """
- Polls for job status asynchronously using gcloud-aio.
-
- Note that an OSError is raised when Job results are still pending.
- Exception means that Job finished with errors
- """
+ async def get_job_status(self, job_id: str | None, project_id: str | None
= None):
Review Comment:
Why'd you get rid of the return type annotation?
##########
airflow/providers/google/cloud/hooks/bigquery.py:
##########
@@ -3086,30 +3086,19 @@ async def get_job_instance(
with await self.service_file_as_context() as f:
return Job(job_id=job_id, project=project_id, service_file=f,
session=cast(Session, session))
- async def get_job_status(
- self,
- job_id: str | None,
- project_id: str | None = None,
- ) -> str | None:
- """
- Polls for job status asynchronously using gcloud-aio.
-
- Note that an OSError is raised when Job results are still pending.
- Exception means that Job finished with errors
- """
+ async def get_job_status(self, job_id: str | None, project_id: str | None
= None):
async with ClientSession() as s:
- try:
- self.log.info("Executing get_job_status...")
- job_client = await self.get_job_instance(project_id, job_id, s)
- job_status_response = await job_client.result(cast(Session, s))
- if job_status_response:
+ job_client = await self.get_job_instance(project_id, job_id, s)
+ job = await job_client.get_job()
+ status = job.get("status", {})
+ if status["state"] == "DONE":
+ if "errorResult" in status:
+ job_status = "error"
Review Comment:
Can't we just return here instead of putting it in a variable?
--
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]