Add argument parser
This commit is contained in:
parent
b54e31f4fd
commit
294a4e1273
1 changed files with 23 additions and 1 deletions
|
@ -2,6 +2,26 @@ import numpy as np
|
|||
from collections import OrderedDict
|
||||
import os.path
|
||||
|
||||
|
||||
def parse_arguments():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Produce detailed power usage data for a list of jobids.')
|
||||
parser.add_argument('-v', '--verbose', action='store_true',
|
||||
help='Show database querries, etc.')
|
||||
parser.add_argument('jobid', type=parse_jobid,
|
||||
# nargs='+',
|
||||
help='Job ID such as "2260215" or "226015.hawk-pbs5"')
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
def parse_jobid(s):
|
||||
import re
|
||||
hawkpbs = r'.hawk-pbs5'
|
||||
jobid = re.sub(hawkpbs, '', s)
|
||||
if not jobid.isdigit():
|
||||
raise argparse.ArgumentTypeError(f'invalid job ID "{s}"')
|
||||
return jobid
|
||||
|
||||
def init_db():
|
||||
import sqlalchemy as db
|
||||
_verbose = False #True
|
||||
|
@ -149,8 +169,10 @@ class Power:
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_arguments()
|
||||
|
||||
conn = init_db()
|
||||
jobid = "2260215"
|
||||
jobid = args.jobid
|
||||
interval = 5
|
||||
query = init_query(jobid, interval)
|
||||
|
||||
|
|
Loading…
Reference in a new issue