Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new query api methods #4056

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions client/python/armada_client/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,39 @@ async def get_job_status(self, job_ids: List[str]) -> job_pb2.JobStatusResponse:
resp = await self.job_stub.GetJobStatus(req)
return resp

async def get_job_status_by_external_job_uri(
self, queue: str, job_set_id: str, external_job_uri: str
) -> job_pb2.JobDetailsResponse:
"""
Retrieves the status of a job based on externalJobUri annotation.

:param queue: The name of the queue
:param job_set_id: The name of the job set (a grouping of jobs)
:param external_job_uri: externalJobUri annotation value

:returns: The response from the server containing the job status.
:rtype: JobStatusResponse
"""
req = job_pb2.JobStatusUsingExternalJobUriRequest(
queue, job_set_id, external_job_uri
)
resp = await self.job_stub.GetJobStatusUsingExternalJobUri(req)
return resp

async def get_job_errors(self, job_ids: List[str]) -> job_pb2.JobErrorsResponse:
"""
Retrieves termination reason from query api.

:param job_ids: A list of unique job identifiers.
:type job_ids: List[str]

:returns: The response from the server containing the job errors.
:rtype: JobErrorsResponse
"""
req = job_pb2.JobErrorsRequest(job_ids=job_ids)
resp = await self.job_stub.GetJobErrors(req)
return resp

async def get_job_details(self, job_ids: List[str]) -> job_pb2.JobDetailsResponse:
"""
Asynchronously retrieves the details of a job from Armada.
Expand Down
32 changes: 32 additions & 0 deletions client/python/armada_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,38 @@ def get_job_status(self, job_ids: List[str]) -> job_pb2.JobStatusResponse:
req = job_pb2.JobStatusRequest(job_ids=job_ids)
return self.job_stub.GetJobStatus(req)

def get_job_status_by_external_job_uri(
self, queue: str, job_set_id: str, external_job_uri: str
) -> job_pb2.JobDetailsResponse:
"""
Retrieves the status of a job based on externalJobUri annotation.

:param queue: The name of the queue
:param job_set_id: The name of the job set (a grouping of jobs)
:param external_job_uri: externalJobUri annotation value

:returns: The response from the server containing the job status.
:rtype: JobStatusResponse
"""
req = job_pb2.JobStatusUsingExternalJobUriRequest(
queue, job_set_id, external_job_uri
)
return self.job_stub.GetJobStatusUsingExternalJobUri(req)

def get_job_errors(self, job_ids: List[str]) -> job_pb2.JobErrorsResponse:
"""
Retrieves termination reason from query api.

:param queue: The name of the queue
:param job_set_id: The name of the job set (a grouping of jobs)
:param external_job_uri: externalJobUri annotation value

:returns: The response from the server containing the job errors.
:rtype: JobErrorsResponse
"""
req = job_pb2.JobErrorsRequest(job_ids=job_ids)
return self.job_stub.GetJobErrors(req)

def get_job_details(self, job_ids: List[str]) -> job_pb2.JobDetailsResponse:
"""
Retrieves the details of a job from Armada.
Expand Down
2 changes: 1 addition & 1 deletion client/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "armada_client"
version = "0.4.6"
version = "0.4.7"
description = "Armada gRPC API python client"
readme = "README.md"
requires-python = ">=3.7"
Expand Down
61 changes: 61 additions & 0 deletions docs/python_armada_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,38 @@ Retrieves the details of a job from Armada.



#### get_job_errors(job_ids)
Retrieves termination reason from query api.


* **Parameters**


* **queue** – The name of the queue


* **job_set_id** – The name of the job set (a grouping of jobs)


* **external_job_uri** – externalJobUri annotation value


* **job_ids** (*List**[**str**]*) –



* **Returns**

The response from the server containing the job errors.



* **Return type**

JobErrorsResponse



#### get_job_events_stream(queue, job_set_id, from_message_id=None)
Get event stream for a job set.

Expand Down Expand Up @@ -362,6 +394,35 @@ Retrieves the status of a list of jobs from Armada.



#### get_job_status_by_external_job_uri(queue, job_set_id, external_job_uri)
Retrieves the status of a job based on externalJobUri annotation.


* **Parameters**


* **queue** (*str*) – The name of the queue


* **job_set_id** (*str*) – The name of the job set (a grouping of jobs)


* **external_job_uri** (*str*) – externalJobUri annotation value



* **Returns**

The response from the server containing the job status.



* **Return type**

JobStatusResponse



#### get_queue(name)
Get the queue by name.

Expand Down