Skip to content

Commit 10bc559

Browse files
committed
ENH: Respect user supplied -o -e flags in qsub_args
The qsub_args may have -o and -e flags pre-specified. If those are explicitly specified by the user, then do not use the default values. In addition, the line was broken apart into units that make it easier to debug. Initially there was an error stating that the argument to %d is required to be an integer. This failure was removed during the refactoring process.
1 parent 493e708 commit 10bc559

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

nipype/pipeline/plugins/sgegraph.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,22 @@ def _submit_graph(self, pyfiles, dependencies):
6565
if 'job' in values:
6666
values = values.rstrip(',')
6767
deps = '-hold_jid%s' % values
68-
fp.writelines('job%05d=`qsub -o %s -e %s' +
69-
' %s %s -N job%05d %s`\n' % (
70-
idx,
71-
batchscriptoutfile,
72-
batchscripterrfile,
73-
self._qsub_args, deps,
74-
idx,
75-
batchscriptfile))
68+
jobname = 'job%05d' % ( idx )
69+
## Do not use default output locations if they are set in self._qsub_args
70+
stderrFile = ''
71+
if self._qsub_args.count('-e ') == 0:
72+
stderrFile='-e {errFile}'.format(errFile=batchscripterrfile)
73+
stdoutFile = ''
74+
if self._qsub_args.count('-o ') == 0:
75+
stdoutFile='-o {outFile}'.format(outFile=batchscriptoutfile)
76+
full_line = '{jobNm}=$(qsub {outFileOption} {errFileOption} {extraQSubArgs} {dependantIndex} -N {jobNm} {batchscript})\n'.format(
77+
jobNm=jobname,
78+
outFileOption=stdoutFile,
79+
errFileOption=stderrFile,
80+
extraQSubArgs=self._qsub_args,
81+
dependantIndex=deps,
82+
batchscript=batchscriptfile)
83+
fp.writelines( full_line )
7684

7785
cmd = CommandLine('bash', environ=os.environ.data)
7886
cmd.inputs.args = '%s' % submitjobsfile

0 commit comments

Comments
 (0)