diff --git a/abm/lib/job.py b/abm/lib/job.py index f495788..8ac7505 100644 --- a/abm/lib/job.py +++ b/abm/lib/job.py @@ -43,6 +43,21 @@ def show(context: Context, args: list): print(json.dumps(job, indent=4)) +def wait(context:Context, args: list): + if len(args) != 1: + print("ERROR: Invalid parameters. Job ID is required") + return + gi = connect(context) + state = "Unknown" + waiting = True + while waiting: + job = gi.jobs.show_job(args[0], full_details=False) + state = job["state"] + if state == "ok" or state == "error": + waiting = False + print(json.dumps(job, indent=4)) + + def get_value(metric: dict): if metric['name'] == 'runtime_seconds': return metric['raw_value'] diff --git a/abm/lib/menu.yml b/abm/lib/menu.yml index ecbfc54..347595e 100644 --- a/abm/lib/menu.yml +++ b/abm/lib/menu.yml @@ -197,6 +197,10 @@ help: kills a job handler: job.cancel params: ID + - name: [wait] + help: Wait for a job to finish running + handler: job.wait + params: ID - name: [ metrics, stats ] help: display runtime metrics for the job, or a list of jobs contained in a history handler: job.metrics