-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding query API endpoints to python client (#3650)
* Adding missing methods to python client (#154) * Adding proto methods * Adding tests and docs * Making tox formatting pass * Fixing docs * Bump version --------- Co-authored-by: Mustafa Ilyas <[email protected]>
- Loading branch information
1 parent
ee1ee05
commit 553da79
Showing
9 changed files
with
340 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
try: | ||
from .typings import JobState | ||
from ._proto_methods import is_active, is_terminal | ||
|
||
JobState.is_active = is_active | ||
JobState.is_terminal = is_terminal | ||
|
||
del is_active, is_terminal, JobState | ||
except ImportError: | ||
""" | ||
Import errors occur during proto generation, where certain | ||
modules import types that don't exist yet. We can safely ignore these failures | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from armada_client.typings import JobState | ||
|
||
|
||
def is_terminal(self) -> bool: | ||
""" | ||
Determines if a job state is terminal. | ||
Terminal states indicate that a job has completed its lifecycle, | ||
whether successfully or due to failure. | ||
:param state: The current state of the job. | ||
:type state: JobState | ||
:returns: True if the job state is terminal, False if it is active. | ||
:rtype: bool | ||
""" | ||
terminal_states = { | ||
JobState.SUCCEEDED, | ||
JobState.FAILED, | ||
JobState.CANCELLED, | ||
JobState.PREEMPTED, | ||
} | ||
return self.value in terminal_states | ||
|
||
|
||
def is_active(self) -> bool: | ||
""" | ||
Determines if a job state is active. | ||
Active states indicate that a job is still running or in a non-terminal state. | ||
:param state: The current state of the job. | ||
:type state: JobState | ||
:returns: True if the job state is active, False if it is terminal. | ||
:rtype: bool | ||
""" | ||
return not is_terminal(self.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.