Skip to content

Commit

Permalink
fixed Rob's mistake, added some documentation
Browse files Browse the repository at this point in the history
brevans committed Dec 20, 2016
1 parent 5037251 commit 578af0e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions dSQ.py
Original file line number Diff line number Diff line change
@@ -4,21 +4,28 @@
import argparse
import sys

desc = """Dead Simple Queue
A simple utility for submitting a list of tasks as a job array, using sbatch. Tasks that return non-zero exit codes will be output to the job_<slurm job id>.REMAINING file. The job_<slurm job id>.STATUS file will contain info about the tasks run and contains the following tab-separated columns:
Task_ID, Exit_Code, Time_Started, Time_Ended, Time_Elapsed, Task
run sbatch --help for more info on sbatch options."""

#use fancy argument parsing
parser = argparse.ArgumentParser()
parser.add_argument('taskfile', type=argparse.FileType('r'))
parser = argparse.ArgumentParser(description=desc, usage='%(prog)s taskfile [slurm args] ...',
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('taskfile', type=argparse.FileType('r'), help="Task file, one task per line")
#capture the rest of the arguments
parser.add_argument('rest', nargs=argparse.REMAINDER)
parser.add_argument('slurm_args', nargs=argparse.REMAINDER, help="flags and arguments to sbatch")
args = parser.parse_args()

num_tasks = sum(1 for line in args.taskfile)

script = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), 'dSQbatch.py')

cmd="sbatch --array=0-{} {} {} {}".format(num_tasks-1,
" ".join(args.rest),
" ".join(args.slurm_args),
script,
args.taskfile.name)

ret=subprocess.call("foobar", shell=True)
ret=subprocess.call(cmd, shell=True)
sys.exit(ret)

0 comments on commit 578af0e

Please sign in to comment.