From 36bfb06228cc913afd2d3e53c60c2efccf6892e8 Mon Sep 17 00:00:00 2001 From: Jose Gracia Date: Wed, 22 Nov 2023 09:01:05 +0100 Subject: [PATCH] Add factory function for power from data base --- monitoring/db/scripts/get_detailed_power.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/monitoring/db/scripts/get_detailed_power.py b/monitoring/db/scripts/get_detailed_power.py index 5128539..7e4c819 100644 --- a/monitoring/db/scripts/get_detailed_power.py +++ b/monitoring/db/scripts/get_detailed_power.py @@ -54,9 +54,12 @@ class Power: return cls -# @classmethod -# def from_db(cls, db): - + @classmethod + def from_db(cls, db, jobid, interval): + all_list = db.db_to_list(jobid, interval) + + return Power.from_list(all_list) + def to_file(self, jobid): """Dumps power data to file. Returns filename is succesfull and None if unsucessfull.""" @@ -186,9 +189,8 @@ if __name__ == "__main__": config.interval = 5 DB = MonitoringDB(config.verbose) - all_list = DB.db_to_list(config.jobid, config.interval) - power = Power.from_list(all_list) + power = Power.from_db(DB, config.jobid, config.interval) #print("#epochs", len(power.epochs)) # #print(power.header())