Skip to content

Commit ebd491d

Browse files
committed
Retrieve exec_hosts from bjobs
1 parent 484381b commit ebd491d

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/ert/scheduler/lsf_driver.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,15 @@ class JobData:
108108
iens: int
109109
job_state: AnyJob
110110
submitted_timestamp: float
111+
exec_hosts: str
111112

112113

113114
def parse_bjobs(bjobs_output: str) -> Dict[str, JobState]:
114115
data: Dict[str, JobState] = {}
115116
for line in bjobs_output.splitlines():
116117
tokens = line.split(sep="^")
117-
if len(tokens) == 2:
118-
job_id, job_state = tokens
118+
if len(tokens) == 3:
119+
job_id, job_state, _ = tokens
119120
if job_state not in get_args(JobState):
120121
logger.error(
121122
f"Unknown state {job_state} obtained from "
@@ -126,6 +127,17 @@ def parse_bjobs(bjobs_output: str) -> Dict[str, JobState]:
126127
return data
127128

128129

130+
def parse_bjobs_exec_hosts(bjobs_output: str) -> Dict[str, str]:
131+
data: Dict[str, str] = {}
132+
for line in bjobs_output.splitlines():
133+
tokens = line.split(sep="^")
134+
if len(tokens) == 3:
135+
job_id, _, exec_hosts = tokens
136+
if exec_hosts != "-":
137+
data[job_id] = exec_hosts
138+
return data
139+
140+
129141
def build_resource_requirement_string(
130142
exclude_hosts: Sequence[str],
131143
realization_memory: int,
@@ -421,7 +433,7 @@ async def poll(self) -> None:
421433
str(self._bjobs_cmd),
422434
"-noheader",
423435
"-o",
424-
"jobid stat delimiter='^'",
436+
"jobid stat exec_host delimiter='^'",
425437
*current_jobids,
426438
stdout=asyncio.subprocess.PIPE,
427439
stderr=asyncio.subprocess.PIPE,
@@ -438,6 +450,12 @@ async def poll(self) -> None:
438450
f"bjobs gave returncode {process.returncode} and error {stderr.decode()}"
439451
)
440452
bjobs_states = _parse_jobs_dict(parse_bjobs(stdout.decode(errors="ignore")))
453+
bjobs_exec_hosts = parse_bjobs_exec_hosts(stdout.decode(errors="ignore"))
454+
455+
print("exec hosts", bjobs_exec_hosts)
456+
457+
for jobid, exec_hosts in bjobs_exec_hosts:
458+
self._jobs[jobid].exec_hosts = exec_hosts
441459

442460
job_ids_found_in_bjobs_output = set(bjobs_states.keys())
443461
if (

0 commit comments

Comments
 (0)