Skip to content

Commit ad2e859

Browse files
committed
ENH: Improve the SGE job names
When submitting jobs to the SGE cluster, it is useful for the jobs to use their nodes names in the reporting from qstat. This makes it easier to debug or identify potential problems with the cluster job submissions.
1 parent 5215480 commit ad2e859

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

nipype/pipeline/plugins/sgegraph.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ def __init__(self, **kwargs):
3939
super(SGEGraphPlugin, self).__init__(**kwargs)
4040

4141
def _submit_graph(self, pyfiles, dependencies, nodes):
42+
def make_job_name(jobnumber, nodeslist):
43+
"""
44+
- jobnumber: The index number of the job to create
45+
- nodeslist: The name of the node being processed
46+
- return: A string representing this job to be displayed by SGE
47+
"""
48+
return 'j{0}_{1}'.format(jobnumber, nodeslist[jobnumber]._id)
4249
batch_dir, _ = os.path.split(pyfiles[0])
4350
submitjobsfile = os.path.join(batch_dir, 'submit_jobs.sh')
4451
with open(submitjobsfile, 'wt') as fp:
@@ -65,20 +72,20 @@ def _submit_graph(self, pyfiles, dependencies, nodes):
6572
if idx in dependencies:
6673
values = ' '
6774
for jobid in dependencies[idx]:
68-
values += '${job%05d},' % jobid
75+
values += make_job_name(jobid, nodes)
6976
if values != ' ': # i.e. if some jobs were added to dependency list
7077
values = values.rstrip(',')
7178
deps = '-hold_jid%s' % values
72-
jobname = 'job%05d' % (idx)
73-
## Do not use default output locations if they are set in self._qsub_args
79+
jobname = make_job_name(idx, nodes)
80+
# Do not use default output locations if they are set in self._qsub_args
7481
stderrFile = ''
7582
if self._qsub_args.count('-e ') == 0:
76-
stderrFile = '-e {errFile}'.format(
77-
errFile=batchscripterrfile)
83+
stderrFile = '-e {errFile}'.format(
84+
errFile=batchscripterrfile)
7885
stdoutFile = ''
7986
if self._qsub_args.count('-o ') == 0:
80-
stdoutFile = '-o {outFile}'.format(
81-
outFile=batchscriptoutfile)
87+
stdoutFile = '-o {outFile}'.format(
88+
outFile=batchscriptoutfile)
8289
full_line = '{jobNm}=$(qsub {outFileOption} {errFileOption} {extraQSubArgs} {dependantIndex} -N {jobNm} {batchscript} | awk \'{{print $3}}\')\n'.format(
8390
jobNm=jobname,
8491
outFileOption=stdoutFile,

0 commit comments

Comments
 (0)