From c594006d4c362d15879417231f5a4c0a6ad8e2ee Mon Sep 17 00:00:00 2001 From: bwibking Date: Wed, 8 May 2024 14:13:35 -0500 Subject: [PATCH] add workaround for sbatch custom output --- maestrowf/interfaces/script/slurmscriptadapter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/maestrowf/interfaces/script/slurmscriptadapter.py b/maestrowf/interfaces/script/slurmscriptadapter.py index 36992dd7..34681eda 100644 --- a/maestrowf/interfaces/script/slurmscriptadapter.py +++ b/maestrowf/interfaces/script/slurmscriptadapter.py @@ -217,6 +217,8 @@ def submit(self, step, path, cwd, job_map=None, env=None): """ # Leading command is 'sbatch' cmd = ["sbatch"] + # add "--parsable": https://slurm.schedmd.com/sbatch.html#OPT_parsable + cmd += ["--parsable"] # Check and see if we should be submitting into a reservation. if "reservation" in self._batch: if self._batch["reservation"]: @@ -238,7 +240,9 @@ def submit(self, step, path, cwd, job_map=None, env=None): if retcode == 0: LOGGER.info("Submission returned status OK.") - jid = re.search('[0-9]+', output).group(0) + # parse only last line of sbatch output (see: https://github.com/LLNL/maestrowf/issues/441) + output_lastline = output.splitlines()[-1] + jid = re.search('[0-9]+', output_lastline).group(0) return SubmissionRecord(SubmissionCode.OK, retcode, jid) else: LOGGER.warning(