-
Notifications
You must be signed in to change notification settings - Fork 3
/
utilization.py
executable file
·44 lines (34 loc) · 1.76 KB
/
utilization.py
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 python
import argparse,logging
from balsam.core.models import utilization_report, BalsamJob, process_job_times
import matplotlib.pyplot as plt
logger = logging.getLogger(__name__)
def main():
''' simple starter program that can be copied for use when starting a new script. '''
logging_format = '%(asctime)s %(levelname)s:%(name)s:%(message)s'
logging_datefmt = '%Y-%m-%d %H:%M:%S'
logging_level = logging.INFO
parser = argparse.ArgumentParser(description='')
parser.add_argument('-w','--workflow',help='workflow name to analyze',required=True)
parser.add_argument('--debug', dest='debug', default=False, action='store_true', help="Set Logger to DEBUG")
parser.add_argument('--error', dest='error', default=False, action='store_true', help="Set Logger to ERROR")
parser.add_argument('--warning', dest='warning', default=False, action='store_true', help="Set Logger to ERROR")
parser.add_argument('--logfilename',dest='logfilename',default=None,help='if set, logging information will go to file')
args = parser.parse_args()
if args.debug and not args.error and not args.warning:
logging_level = logging.DEBUG
elif not args.debug and args.error and not args.warning:
logging_level = logging.ERROR
elif not args.debug and not args.error and args.warning:
logging_level = logging.WARNING
logging.basicConfig(level=logging_level,
format=logging_format,
datefmt=logging_datefmt,
filename=args.logfilename)
qs = BalsamJob.objects.filter(workflow=args.workflow)
dat = process_job_times(qs)
times, utils = utilization_report(dat)
plt.step(times, utils, where="post")
plt.waitforbuttonpress()
if __name__ == "__main__":
main()