Skip to content

Commit 98d710f

Browse files
committed
if --wait is passed into gufi_query_distributed, print output files
1 parent 8c3cd15 commit 98d710f

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

scripts/gufi_query_distributed

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161

6262

6363

64+
import sys
65+
6466
import gufi_common
6567
import gufi_distributed
6668

@@ -114,6 +116,8 @@ def schedule_top(args, jobids):
114116

115117
cmd = [args.sbatch, '--nodes=1']
116118
cmd += gufi_distributed.depend_on_slurm_jobids(jobids)
119+
if args.wait:
120+
cmd += ['--wait']
117121
cmd += [
118122
args.gufi_query,
119123
'-n', str(args.threads),
@@ -127,6 +131,10 @@ def parse_args():
127131
'Script for distributing gufi_query across nodes')
128132

129133
parser.add_argument('--dry-run', action='store_true')
134+
parser.add_argument('-W', '--wait',
135+
action='store_true',
136+
help='wait until all jobs complete and print results')
137+
130138
parser.add_argument('--gufi_query', metavar='path',
131139
type=str,
132140
default='gufi_query.sbatch')
@@ -155,9 +163,15 @@ def main():
155163
lambda idx, start, end: schedule_work(args, idx, start, end),
156164
lambda jobids: schedule_top(args, jobids))
157165

158-
print('cat the following slurm job output files to get complete results:')
159-
for jobid in jobids:
160-
print(' {0}'.format(jobid))
166+
if args.wait:
167+
for jobid in jobids:
168+
with open('slurm-{0}.out'.format(jobid), 'r') as f:
169+
for line in f:
170+
sys.stdout.write(line)
171+
else:
172+
print('cat the following slurm job output files to get complete results:')
173+
for jobid in jobids:
174+
print(' {0}'.format(jobid))
161175

162176
if __name__ == '__main__':
163177
main()

test/regression/sbatch.no-output.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ case $key in
7676
--nodes|--dependency)
7777
shift # past count
7878
;;
79-
--nodes=*)
79+
--nodes=*|--wait)
8080
;;
8181
*) # unknown option
8282
POSITIONAL+=("$1") # save it in an array for later

test/regression/sbatch.output.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ case $key in
7676
--nodes|--dependency)
7777
shift # past count
7878
;;
79-
--nodes=*)
79+
--nodes=*|--wait)
8080
;;
8181
*) # unknown option
8282
POSITIONAL+=("$1") # save it in an array for later

0 commit comments

Comments
 (0)