aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lava_scheduler_tool/commands.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/lava_scheduler_tool/commands.py b/lava_scheduler_tool/commands.py
index 915021e..1a927cb 100644
--- a/lava_scheduler_tool/commands.py
+++ b/lava_scheduler_tool/commands.py
@@ -163,7 +163,7 @@ class submit_job(Command): # pylint: disable=invalid-name
if self.args.block:
print('')
- print('This kind of polling is deprecated and will be removed in the next release. Please use "wait-for-job" command.')
+ print('This kind of polling is deprecated and will be removed in the next release. Please use "wait-job-events" command.')
print('')
print('Waiting for the job to run ')
print('. = job waiting in the queue')
@@ -696,8 +696,10 @@ class wait_job_events(Command): # pylint: disable=invalid-name
Wait for job to finish and return job details.
"""
- FINISHED_JOB_STATE = "Finished"
+ FINISHED_JOB_STATE = ["Finished"]
+ FINISHED_JOB_STATUS = ["Complete", "Incomplete", "Canceled"]
EVENT_SOCKET_PATTERN_SYMBOL = "*"
+ API_UPDATE_VERSION = "2018.1"
def reparse_arguments(self, parser, raw_args):
pass
@@ -742,12 +744,20 @@ class wait_job_events(Command): # pylint: disable=invalid-name
host = get_server_url(auth_backend, self.args.SERVER)
hostname = urlparse.urlparse(host).hostname
+ # Support both old and new API versions.
+ if server.system.version().split("+")[0] >= self.API_UPDATE_VERSION:
+ state_key = "state"
+ relevant_finished_states = self.FINISHED_JOB_STATE
+ else:
+ state_key = "status"
+ relevant_finished_states = self.FINISHED_JOB_STATUS
+
if self.args.job_id:
job_ids = [self.args.job_id]
try:
job = server.scheduler.job_details(self.args.job_id)
- if job["state"] == self.FINISHED_JOB_STATE:
+ if job[state_key] in relevant_finished_states:
print("Job %s already finished with state %s." % (
self.args.job_id, job["health"]))
return
@@ -817,7 +827,7 @@ class wait_job_events(Command): # pylint: disable=invalid-name
if data["job"] in job_ids:
data["job"] = urlparse.urljoin(
job_url_template, str(data["job"]))
- if data["state"] == self.FINISHED_JOB_STATE:
+ if data[state_key] in relevant_finished_states:
print(data)
break
elif not self.args.quiet: