Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion {{cookiecutter.profile_name}}/lsf_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ class UnknownStatusLine(Exception):
ZOMBIE = "ZOMBI"


def extract_job_status(bjobs_output):
import re

response = bjobs_output.split('\n')
if len(response) != 2:
return "UNKNOWN"

response = response[1]
return re.split("[\\t\\r\\n ]+", response)[2]


class StatusChecker:
SUCCESS = "success"
RUNNING = "running"
Expand Down Expand Up @@ -70,7 +81,7 @@ def outlog(self) -> str:

@property
def bjobs_query_cmd(self) -> str:
return "bjobs -o 'stat' -noheader {jobid}".format(jobid=self.jobid)
return "bjobs {jobid}".format(jobid=self.jobid)

def _handle_unknown_job(self) -> str:
if self.kill_unknown:
Expand Down Expand Up @@ -105,6 +116,8 @@ def _query_status_using_bjobs(self) -> str:
)
)

output_stream = extract_job_status(output_stream)

if output_stream == UNKNOWN:
return self._handle_unknown_job()

Expand Down