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")
parser.add_argument('--hawk-ai', action='store_true',
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,
nargs='+',
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 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"
# add node names here instead
hd += "," + ",".join(self.nodes)
hd += "\n"
return hd
@ -228,6 +231,9 @@ class App:
def __init__(self, config):
self.config = config
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
def warnings(config):
@ -255,6 +261,13 @@ class App:
print('No data found for job ID "{}"'.format(jobid))
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)
if fn:
print('Created file {fn}'.format(fn=fn))
@ -269,6 +282,8 @@ if __name__ == "__main__":
config = parse_arguments(sys.argv[1:])
config.cmd = " ".join(sys.argv)
config.datetime = f"{datetime.now()}"
if os.path.basename(__file__) == 'get_energy.py':
config.energy_only = True
main = App(config)
main.run_all()