Skip to content

Commit

Permalink
fix: differentiation between stdout and stderr upon job submission, m…
Browse files Browse the repository at this point in the history
…ight fix #157
  • Loading branch information
cmeesters committed Oct 31, 2024
1 parent d98e4ac commit 60f7a98
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions snakemake_executor_plugin_slurm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,27 @@ def run_job(self, job: JobExecutorInterface):

self.logger.debug(f"sbatch call: {call}")
try:
out = subprocess.check_output(
call, shell=True, text=True, stderr=subprocess.STDOUT
).strip()
process = subprocess.Popen(call, hell=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
if process.returncode != 0:
raise subprocess.CalledProcessError(
process.returncode, call, output=err
)
except subprocess.CalledProcessError as e:
raise WorkflowError(
f"SLURM job submission failed. The error message was {e.output}"
)
if err: # any other error message?
raise WorkflowError(
f"SLURM job submission failed. The error message was {err}"
)

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

0 comments on commit 60f7a98

Please sign in to comment.