Add factory function for power from data base

This commit is contained in:
Jose Gracia 2023-11-22 09:01:05 +01:00
parent f9ebd68654
commit 36bfb06228

View file

@ -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())