Outline main into class
This commit is contained in:
parent
36bfb06228
commit
ee106619ea
1 changed files with 17 additions and 4 deletions
|
@ -10,7 +10,7 @@ def parse_arguments():
|
|||
parser.add_argument('-v', '--verbose', action='store_true',
|
||||
help='Show database querries, etc.')
|
||||
parser.add_argument('jobid', type=parse_jobid,
|
||||
# nargs='+',
|
||||
nargs='+',
|
||||
help='Job ID such as "2260215" or "2260215.hawk-pbs5"')
|
||||
|
||||
return parser.parse_args()
|
||||
|
@ -183,14 +183,27 @@ class MonitoringDB:
|
|||
query = self.build_query(jobid, interval)
|
||||
return pd.read_sql(query, con=self.connection)
|
||||
|
||||
class App:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
self.db = MonitoringDB(self.config.verbose)
|
||||
|
||||
def run_all(self):
|
||||
for jobid in self.config.jobid:
|
||||
power = Power.from_db(self.db, jobid, self.config.interval)
|
||||
fn = power.to_file(jobid)
|
||||
if fn:
|
||||
print('Created file {fn}'.format(fn=fn))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
config = parse_arguments()
|
||||
config.interval = 5
|
||||
|
||||
DB = MonitoringDB(config.verbose)
|
||||
main = App(config)
|
||||
main.run_all()
|
||||
|
||||
power = Power.from_db(DB, config.jobid, config.interval)
|
||||
#power = Power.from_db(DB, config.jobid, config.interval)
|
||||
#print("#epochs", len(power.epochs))
|
||||
#
|
||||
#print(power.header())
|
||||
|
@ -201,7 +214,7 @@ if __name__ == "__main__":
|
|||
#print('time:', power.summarize_time(ts))
|
||||
#print('values:', power.summarize_values(values))
|
||||
#print('epoch:', power.pretty_print(power.summarize_epoch((ts, values))))
|
||||
print("filename: ", power.to_file(config.jobid))
|
||||
#print("filename: ", power.to_file(config.jobid))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue