From 813a3da745e4e51e74154ce7676d8a79a1426446 Mon Sep 17 00:00:00 2001 From: Ben Evans Date: Tue, 14 Mar 2017 15:09:50 -0400 Subject: [PATCH] first pass at autopsy --- dSQAutopsy | 1 + dSQAutopsy.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 120000 dSQAutopsy create mode 100755 dSQAutopsy.py diff --git a/dSQAutopsy b/dSQAutopsy new file mode 120000 index 0000000..756cd69 --- /dev/null +++ b/dSQAutopsy @@ -0,0 +1 @@ +dSQAutopsy.py \ No newline at end of file diff --git a/dSQAutopsy.py b/dSQAutopsy.py new file mode 100755 index 0000000..7673318 --- /dev/null +++ b/dSQAutopsy.py @@ -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)