Skip to content

Commit 6a7a4a3

Browse files
authored
LSF job state (#429)
Add initial support for generic resources (e.g. tokens) and alter get_job_states to only get current jobs, like SLURM
1 parent a96e2aa commit 6a7a4a3

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/gwf/backends/lsf.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ def get_job_states(self, tracked_jobs):
8080
logger.debug("Getting job states from LSF")
8181
if not tracked_jobs:
8282
return {}
83+
# Default tracked job IDs to UNKNOWN
8384
job_states = {job_id: BackendStatus.UNKNOWN for job_id in tracked_jobs}
84-
for job_id in tracked_jobs:
85-
cmd = ["bjobs", "-noheader", "-o", "stat", job_id]
86-
ret = call(*cmd).strip()
87-
if ret == "":
88-
continue
89-
state = BJOB_STATES[ret]
90-
job_states[job_id] = state
85+
86+
# Get all current job statuses
87+
for line in call("bjobs", "-noheader", "-o" , "jobid stat delimiter=','").splitlines():
88+
job_id, state = line.strip().split(",")
89+
# Update job status if tracked
90+
if job_id in tracked_jobs:
91+
job_states[job_id] = BJOB_STATES[state]
9192
return job_states
9293

9394
def compile_script(self, target):

0 commit comments

Comments
 (0)