From 7b48f8d8d4523f5b2daedde69b061b986c1ae0b2 Mon Sep 17 00:00:00 2001 From: Tom Drever Date: Mon, 1 Jun 2026 14:16:00 +0100 Subject: [PATCH 1/2] Add initial support for generic resources (e.g. tokens) and alter get_job_states to only get current jobs, like SLURM --- src/gwf/backends/lsf.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gwf/backends/lsf.py b/src/gwf/backends/lsf.py index 853aa961..ccad0228 100644 --- a/src/gwf/backends/lsf.py +++ b/src/gwf/backends/lsf.py @@ -31,10 +31,11 @@ logger = logging.getLogger(__name__) -TARGET_DEFAULTS = {"queue": "normal", "memory": "4GB", "cores": 1} +TARGET_DEFAULTS = {"queue": "normal", "memory": "4GB", "cores": 1, "resource": ""} BJOB_HEADER = """#BSUB -M {memory} #BSUB -R "select[mem>{memory}] rusage[mem={memory}] span[hosts=1]" +#BSUB -R {resource} #BSUB -n {cores} #BSUB -q {queue} #BSUB -oo {std_out} @@ -80,14 +81,15 @@ def get_job_states(self, tracked_jobs): logger.debug("Getting job states from LSF") if not tracked_jobs: return {} + # Default tracked job IDs to UNKNOWN job_states = {job_id: BackendStatus.UNKNOWN for job_id in tracked_jobs} - for job_id in tracked_jobs: - cmd = ["bjobs", "-noheader", "-o", "stat", job_id] - ret = call(*cmd).strip() - if ret == "": - continue - state = BJOB_STATES[ret] - job_states[job_id] = state + + # Get all current job statuses + for line in call("bjobs", "-noheader", "-o" , "jobid stat delimiter=','").splitlines(): + job_id, state = line.strip().split(",") + # Update job status if tracked + if job_id in tracked_jobs: + job_states[job_id] = BJOB_STATES[state] return job_states def compile_script(self, target): From 167e6f2427ca71e99d8f04ffcfbc207e3603b69d Mon Sep 17 00:00:00 2001 From: Tom Drever Date: Mon, 1 Jun 2026 15:56:05 +0100 Subject: [PATCH 2/2] Remove resources changes --- src/gwf/backends/lsf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gwf/backends/lsf.py b/src/gwf/backends/lsf.py index ccad0228..6fb39455 100644 --- a/src/gwf/backends/lsf.py +++ b/src/gwf/backends/lsf.py @@ -31,11 +31,10 @@ logger = logging.getLogger(__name__) -TARGET_DEFAULTS = {"queue": "normal", "memory": "4GB", "cores": 1, "resource": ""} +TARGET_DEFAULTS = {"queue": "normal", "memory": "4GB", "cores": 1} BJOB_HEADER = """#BSUB -M {memory} #BSUB -R "select[mem>{memory}] rusage[mem={memory}] span[hosts=1]" -#BSUB -R {resource} #BSUB -n {cores} #BSUB -q {queue} #BSUB -oo {std_out}