Skip to content

Commit 7b48f8d

Browse files
committed
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 7b48f8d

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/gwf/backends/lsf.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131

3232
logger = logging.getLogger(__name__)
3333

34-
TARGET_DEFAULTS = {"queue": "normal", "memory": "4GB", "cores": 1}
34+
TARGET_DEFAULTS = {"queue": "normal", "memory": "4GB", "cores": 1, "resource": ""}
3535

3636
BJOB_HEADER = """#BSUB -M {memory}
3737
#BSUB -R "select[mem>{memory}] rusage[mem={memory}] span[hosts=1]"
38+
#BSUB -R {resource}
3839
#BSUB -n {cores}
3940
#BSUB -q {queue}
4041
#BSUB -oo {std_out}
@@ -80,14 +81,15 @@ def get_job_states(self, tracked_jobs):
8081
logger.debug("Getting job states from LSF")
8182
if not tracked_jobs:
8283
return {}
84+
# Default tracked job IDs to UNKNOWN
8385
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
86+
87+
# Get all current job statuses
88+
for line in call("bjobs", "-noheader", "-o" , "jobid stat delimiter=','").splitlines():
89+
job_id, state = line.strip().split(",")
90+
# Update job status if tracked
91+
if job_id in tracked_jobs:
92+
job_states[job_id] = BJOB_STATES[state]
9193
return job_states
9294

9395
def compile_script(self, target):

0 commit comments

Comments
 (0)