Add argument for interval and report in output
This commit is contained in:
parent
6ff52227ef
commit
4a2107d6df
1 changed files with 16 additions and 9 deletions
|
@ -9,6 +9,8 @@ def parse_arguments(args):
|
|||
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('-t', '--interval', action='store', type=float, default=5.0,
|
||||
help="Interval between power values in seconds")
|
||||
parser.add_argument('jobid', type=parse_jobid,
|
||||
nargs='+',
|
||||
help='Job ID such as "2260215" or "2260215.hawk-pbs5"')
|
||||
|
@ -25,11 +27,12 @@ def parse_jobid(s):
|
|||
|
||||
|
||||
class Power:
|
||||
def __init__(self, nodes):
|
||||
def __init__(self, nodes, interval=-1):
|
||||
self.nodes = nodes
|
||||
self.epochs = OrderedDict()
|
||||
self.first_ts = None
|
||||
self.last_ts = None
|
||||
self.interval = interval
|
||||
|
||||
@classmethod
|
||||
def from_list(cls, data):
|
||||
|
@ -59,7 +62,10 @@ class Power:
|
|||
if not all_list:
|
||||
raise RuntimeError
|
||||
|
||||
return Power.from_list(all_list)
|
||||
power = cls.from_list(all_list)
|
||||
power.set_interval(interval*1000) # milliseconds
|
||||
|
||||
return power
|
||||
|
||||
def to_file(self, jobid):
|
||||
"""Dumps power data to file. Returns filename is succesfull and None if unsucessfull."""
|
||||
|
@ -78,6 +84,9 @@ class Power:
|
|||
|
||||
return fname
|
||||
|
||||
def set_interval(self, interval):
|
||||
self.interval = interval
|
||||
|
||||
def insert_epoch(self, ts, values):
|
||||
self.epochs[ts] = values
|
||||
if not self.first_ts:
|
||||
|
@ -98,9 +107,8 @@ class Power:
|
|||
_body += Power.pretty_print(self.summarize_epoch(epoch))
|
||||
return _body
|
||||
|
||||
@staticmethod
|
||||
def summarize_time(ts):
|
||||
return ts, -1
|
||||
def summarize_time(self, ts):
|
||||
return ts, self.interval
|
||||
|
||||
@staticmethod
|
||||
def summarize_values(val):
|
||||
|
@ -111,11 +119,10 @@ class Power:
|
|||
median = np.median(values)
|
||||
return head, avg, median, min, max, stddev
|
||||
|
||||
@staticmethod
|
||||
def summarize_epoch(epoch):
|
||||
def summarize_epoch(self, epoch):
|
||||
ts, values = epoch
|
||||
return Power.summarize_time(ts) \
|
||||
+ Power.summarize_values(values)
|
||||
return self.summarize_time(ts) \
|
||||
+ self.summarize_values(values)
|
||||
# + values
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Reference in a new issue