Add factory function for power from data base
This commit is contained in:
parent
f9ebd68654
commit
36bfb06228
1 changed files with 7 additions and 5 deletions
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue