Skip to content

Commit 60f7a98

Browse files
committed
fix: differentiation between stdout and stderr upon job submission, might fix #157
1 parent d98e4ac commit 60f7a98

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

snakemake_executor_plugin_slurm/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,27 @@ def run_job(self, job: JobExecutorInterface):
217217

218218
self.logger.debug(f"sbatch call: {call}")
219219
try:
220-
out = subprocess.check_output(
221-
call, shell=True, text=True, stderr=subprocess.STDOUT
222-
).strip()
220+
process = subprocess.Popen(call, hell=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
221+
out, err = process.communicate()
222+
if process.returncode != 0:
223+
raise subprocess.CalledProcessError(
224+
process.returncode, call, output=err
225+
)
223226
except subprocess.CalledProcessError as e:
224227
raise WorkflowError(
225228
f"SLURM job submission failed. The error message was {e.output}"
226229
)
230+
if err: # any other error message?
231+
raise WorkflowError(
232+
f"SLURM job submission failed. The error message was {err}"
233+
)
227234

228235
# multicluster submissions yield submission infos like
229236
# "Submitted batch job <id> on cluster <name>" by default, but with the
230237
# --parsable option it simply yields "<id>;<name>".
231238
# To extract the job id we split by semicolon and take the first element
232239
# (this also works if no cluster name was provided)
233-
slurm_jobid = out.split(";")[0]
240+
slurm_jobid = out.strip().split(";")[0]
234241
slurm_logfile = slurm_logfile.replace("%j", slurm_jobid)
235242
self.logger.info(
236243
f"Job {job.jobid} has been submitted with SLURM jobid {slurm_jobid} "

0 commit comments

Comments
 (0)