|
31 | 31 |
|
32 | 32 | logger = logging.getLogger(__name__) |
33 | 33 |
|
34 | | -TARGET_DEFAULTS = {"queue": "normal", "memory": "4GB", "cores": 1} |
| 34 | +TARGET_DEFAULTS = {"queue": "normal", "memory": "4GB", "cores": 1, "resource": ""} |
35 | 35 |
|
36 | 36 | BJOB_HEADER = """#BSUB -M {memory} |
37 | 37 | #BSUB -R "select[mem>{memory}] rusage[mem={memory}] span[hosts=1]" |
| 38 | +#BSUB -R {resource} |
38 | 39 | #BSUB -n {cores} |
39 | 40 | #BSUB -q {queue} |
40 | 41 | #BSUB -oo {std_out} |
@@ -80,14 +81,15 @@ def get_job_states(self, tracked_jobs): |
80 | 81 | logger.debug("Getting job states from LSF") |
81 | 82 | if not tracked_jobs: |
82 | 83 | return {} |
| 84 | + # Default tracked job IDs to UNKNOWN |
83 | 85 | 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] |
91 | 93 | return job_states |
92 | 94 |
|
93 | 95 | def compile_script(self, target): |
|
0 commit comments