From d7168a95f04b5e6225aa2bd17cf02127e681e15d Mon Sep 17 00:00:00 2001 From: Haizi Zheng Date: Tue, 10 Nov 2020 19:09:39 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20bug=20for=20legacy=20LSF?= =?UTF-8?q?=20system=20(v8.3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In a legacy LSF system such as v8.3, bjobs does not support certain argument such as --noheader or -o. Therefore, we need an alternative way to monitor job status. --- {{cookiecutter.profile_name}}/lsf_status.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.profile_name}}/lsf_status.py b/{{cookiecutter.profile_name}}/lsf_status.py index 5589f44..6095c88 100755 --- a/{{cookiecutter.profile_name}}/lsf_status.py +++ b/{{cookiecutter.profile_name}}/lsf_status.py @@ -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" @@ -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: @@ -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()