From a5435e65dc0c14385762655f65f1736b16ea0fbc Mon Sep 17 00:00:00 2001 From: Jose Gracia Date: Thu, 15 Feb 2024 10:29:45 +0100 Subject: [PATCH] Save warnings in output --- monitoring/db/scripts/get_detailed_power.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/monitoring/db/scripts/get_detailed_power.py b/monitoring/db/scripts/get_detailed_power.py index 7f01db8..f60bdd0 100755 --- a/monitoring/db/scripts/get_detailed_power.py +++ b/monitoring/db/scripts/get_detailed_power.py @@ -36,6 +36,7 @@ class Power: self.epochs = OrderedDict() self.first_ts = None self.last_ts = None + self.warnings = "" @classmethod def from_list(cls, data): @@ -67,14 +68,14 @@ class Power: e = list(epochs) k = list(values.keys()) if not e == k: - print("Warning: Unexpected unsorted timestamps.") + power.warnings += "# Warning: Unexpected unsorted timestamps.\n" # check implicit assumptions: 2) each line has #nodes values nnodes = len(nodes) for epoch in epochs: actual = len(values[epoch]) if actual != nnodes: - print("Warning: Unexpected number of nodes ({actual}/{expected})".format(actual=actual, expected=nnodes)) + power.warnings += "# Warning: Unexpected number of nodes ({actual}/{expected})\n".format(actual=actual, expected=nnodes) break return power @@ -96,6 +97,7 @@ class Power: print("Error: cowardly refusing to overwrite file ", fname) return None + header += self.warnings try: with open(fname, "w+") as f: f.write(header + self.header()) @@ -247,6 +249,8 @@ class App: fn = power.to_file(jobid, header) if fn: print('Created file {fn}'.format(fn=fn)) + if power.warnings: + print(power.warnings) if __name__ == "__main__":