@@ -217,20 +217,27 @@ def run_job(self, job: JobExecutorInterface):
217
217
218
218
self .logger .debug (f"sbatch call: { call } " )
219
219
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
+ )
223
226
except subprocess .CalledProcessError as e :
224
227
raise WorkflowError (
225
228
f"SLURM job submission failed. The error message was { e .output } "
226
229
)
230
+ if err : # any other error message?
231
+ raise WorkflowError (
232
+ f"SLURM job submission failed. The error message was { err } "
233
+ )
227
234
228
235
# multicluster submissions yield submission infos like
229
236
# "Submitted batch job <id> on cluster <name>" by default, but with the
230
237
# --parsable option it simply yields "<id>;<name>".
231
238
# To extract the job id we split by semicolon and take the first element
232
239
# (this also works if no cluster name was provided)
233
- slurm_jobid = out .split (";" )[0 ]
240
+ slurm_jobid = out .strip (). split (";" )[0 ]
234
241
slurm_logfile = slurm_logfile .replace ("%j" , slurm_jobid )
235
242
self .logger .info (
236
243
f"Job { job .jobid } has been submitted with SLURM jobid { slurm_jobid } "
0 commit comments