Skip to content

Commit 9d5da49

Browse files
authored
Merge pull request #208 from galaxyproject/207-job-wait
Job wait
2 parents ae89944 + 1bc4435 commit 9d5da49

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

abm/lib/job.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ def show(context: Context, args: list):
4343
print(json.dumps(job, indent=4))
4444

4545

46+
def wait(context:Context, args: list):
47+
if len(args) != 1:
48+
print("ERROR: Invalid parameters. Job ID is required")
49+
return
50+
gi = connect(context)
51+
state = "Unknown"
52+
waiting = True
53+
while waiting:
54+
job = gi.jobs.show_job(args[0], full_details=False)
55+
state = job["state"]
56+
if state == "ok" or state == "error":
57+
waiting = False
58+
print(json.dumps(job, indent=4))
59+
60+
4661
def get_value(metric: dict):
4762
if metric['name'] == 'runtime_seconds':
4863
return metric['raw_value']

abm/lib/menu.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@
197197
help: kills a job
198198
handler: job.cancel
199199
params: ID
200+
- name: [wait]
201+
help: Wait for a job to finish running
202+
handler: job.wait
203+
params: ID
200204
- name: [ metrics, stats ]
201205
help: display runtime metrics for the job, or a list of jobs contained in a history
202206
handler: job.metrics

0 commit comments

Comments
 (0)