Compare commits

...

3 commits

Author SHA1 Message Date
f14904f8ca Report only energy if script name is get_energy.py 2024-02-23 16:53:11 +01:00
ba5b2d80f5 Add option to report only total consumed energy 2024-02-23 16:51:55 +01:00
dcf88a6da0 Report node power only if requested
This is a hack! Monkey patches class Power :(
2024-02-23 16:39:59 +01:00

View file

@ -15,6 +15,10 @@ def parse_arguments(args):
help="Interval between power values in seconds") help="Interval between power values in seconds")
parser.add_argument('--hawk-ai', action='store_true', parser.add_argument('--hawk-ai', action='store_true',
help="Job did run on Hawk-AI") help="Job did run on Hawk-AI")
parser.add_argument('--report-nodes', action='store_true',
help='Report power of all nodes, not just statisitcs across nodes.')
parser.add_argument('--energy-only', action='store_true',
help='Return only total consumed energy, not detailed power')
parser.add_argument('jobid', type=parse_jobid, parser.add_argument('jobid', type=parse_jobid,
nargs='+', nargs='+',
help='Job ID such as "2260215" or "2260215.hawk-pbs5"') help='Job ID such as "2260215" or "2260215.hawk-pbs5"')
@ -99,7 +103,6 @@ class Power:
hd = "# all timestamp have unit miliseconds since unix epoch\n" hd = "# all timestamp have unit miliseconds since unix epoch\n"
hd += "# all power values have unit Watt\n" hd += "# all power values have unit Watt\n"
hd += "timestamp,RESERVED,head_node_power,avg_node_power,median_node_power,min_node_power,max_node_power,std_dev_sample_node_power" hd += "timestamp,RESERVED,head_node_power,avg_node_power,median_node_power,min_node_power,max_node_power,std_dev_sample_node_power"
# add node names here instead
hd += "," + ",".join(self.nodes) hd += "," + ",".join(self.nodes)
hd += "\n" hd += "\n"
return hd return hd
@ -228,6 +231,9 @@ class App:
def __init__(self, config): def __init__(self, config):
self.config = config self.config = config
self.db = MonitoringDB(self.config.verbose) self.db = MonitoringDB(self.config.verbose)
if not self.config.report_nodes:
# Monkey patching class Power; what a hack!
Power._all_values = lambda s,x: ""
@staticmethod @staticmethod
def warnings(config): def warnings(config):
@ -255,6 +261,13 @@ class App:
print('No data found for job ID "{}"'.format(jobid)) print('No data found for job ID "{}"'.format(jobid))
continue continue
if self.config.energy_only:
if power.energy:
print(power.energy)
else:
print('No total energy for job ID "{}"'.format(jobid))
continue
fn = power.to_file(jobid, header) fn = power.to_file(jobid, header)
if fn: if fn:
print('Created file {fn}'.format(fn=fn)) print('Created file {fn}'.format(fn=fn))
@ -269,6 +282,8 @@ if __name__ == "__main__":
config = parse_arguments(sys.argv[1:]) config = parse_arguments(sys.argv[1:])
config.cmd = " ".join(sys.argv) config.cmd = " ".join(sys.argv)
config.datetime = f"{datetime.now()}" config.datetime = f"{datetime.now()}"
if os.path.basename(__file__) == 'get_energy.py':
config.energy_only = True
main = App(config) main = App(config)
main.run_all() main.run_all()