Skip to content

Commit

Permalink
first pass at autopsy
Browse files Browse the repository at this point in the history
  • Loading branch information
brevans committed Mar 14, 2017
1 parent 8381155 commit 813a3da
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions dSQAutopsy
56 changes: 56 additions & 0 deletions dSQAutopsy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python
from __future__ import print_function #to make printing stderr work cleanly
import sys
import argparse
#from dSQ import __version__
__version__ = 0.4
desc = """Dead Simple Queue Autopsy v{}
https://github.com/ycrc/dSQ
A helper script for analyzing the success state of your tasks after a dSQ
run has completed. Specify the taskfile and the status.tsv file generated
by the dSQ job and dSQAutopsy will print the tasks that didn't run or
completed with non-zero exit codes. It will also report count of each to
stderr.
""".format(__version__)

# argument parsing
parser = argparse.ArgumentParser(description=desc,
usage='%(prog)s taskfile status.tsv',
formatter_class=argparse.RawTextHelpFormatter,
prog='dSQAutopsy')
parser.add_argument('-v','--version',
action='version',
version='%(prog)s {}'.format(__version__))
parser.add_argument('taskfile',
nargs=1,
type=argparse.FileType('r'),
help='Task file, one task per line')
parser.add_argument('statusfile',
nargs=1,
type=argparse.FileType('r'),
help='The status.tsv file generated from your dSQ run')

args = parser.parse_args()

try:
succeeded = set()
failed = set()
norun = set()
for i,l in enumerate(args.statusfile[0]):
print(l)
exit_code = l.split('\t',2)[1]
if exit_code == "0":
succeeded.add(i)
else:
failed.add(i)

for i,l in enumerate(args.taskfile[0]):
if i not in succeeded:
if i not in failed:
norun.add(i)
print(l, end='')
print("Autopsy Task Report:\n{} succeeded\n{} failed\n{} didn't run.".format(len(succeeded), len(failed), len(norun)), file=sys.stderr)
except Exception as e:
print ("Something went wrong. Did you specify the right files?")
sys.exit(1)

0 comments on commit 813a3da

Please sign in to comment.