-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbsub.py.old
executable file
·44 lines (34 loc) · 2.79 KB
/
bsub.py.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3.3
import argparse
import farm
parser = argparse.ArgumentParser(
description = 'Wrapper script for running jobs on the farm',
usage = '%(prog)s <memory in GB> <job_name> <command>',
epilog = 'Note: to run a job array, use --start and --end. Every appearance of INDEX in the command to be run will be replaced with \\$LSB_JOBINDEx. e.g. try bsub.py --norun --start 1 --end 10 name foo.sh INDEX')
parser.add_argument('memory', type=float, help='Memory in GB to reserve for the job')
parser.add_argument('name', help='Name of the job')
parser.add_argument('command', help='Command to be bsubbed', nargs=argparse.REMAINDER)
parser.add_argument('-e', '--err', help='Name fo file that stderr gets written to [job_name.e]', metavar='filename', default=None)
parser.add_argument('-o', '--out', help='Name fo file that stdout gets written to [job_name.o]', metavar='filename', default=None)
parser.add_argument('--start', type=int, help='Starting index of job array', metavar='int', default=0)
parser.add_argument('--end', type=int, help='Ending index of job array', metavar='int', default=0)
parser.add_argument('--done', action='append', help='Only start the job running when the given job finishes successfully. All digits is interpreted as a job ID, otherwise a job name. This can be used more than once to make the job depend on two or more other jobs', metavar='Job ID/job name')
parser.add_argument('--ended', action='append', help='As for --done, except the job must only finish, wether successful or not', metavar='job ID/job name')
parser.add_argument('--lsf_units', help='Set to MB or KB as appropriate (this is a hack to be used when it is not detected automatically)', metavar='MB or KB', default=None)
parser.add_argument('--tmp_space', type=float, help='Reserve this much /tmp space in GB [%(default)s]', default=0, metavar='float')
parser.add_argument('--threads', type=int, help='Number of threads to request [%(default)s]', metavar='int', default=1)
parser.add_argument('-q', '--queue', help='Queue in which to run job [%(default)s]', default='normal', metavar='queue_name')
parser.add_argument('--norun', action='store_true', help='Don\'t run, just print the bsub command')
options = parser.parse_args()
command = ' '.join(options.command)
# if error and/or output file not give, make them name.{e,o}
if options.err is None:
options.err = options.name + '.e'
if options.out is None:
options.out = options.name + '.o'
# make bsub object and run or print it
b= farm.Bsub(options.out, options.err, options.name, options.queue, options.memory, command, start=options.start, end=options.end, depend=options.done, threads=options.threads, tmp_space=options.tmp_space, ended=options.ended, lsf_units=options.lsf_units)
print(b)
if not options.norun:
job_id = b.run()
print(job_id, 'submitted')