diff --git a/monitoring/db/scripts/get_detailed_power.py b/monitoring/db/scripts/get_detailed_power.py index 898f60f..54f44b5 100755 --- a/monitoring/db/scripts/get_detailed_power.py +++ b/monitoring/db/scripts/get_detailed_power.py @@ -74,7 +74,7 @@ class Power: self.by_node = by_node self.first_ts, self.last_ts = times[0], times[-1] self.warnings = "" # add check for warning, i.e. data gaps due to missing nodes - self.energy = self.summarize_energy() + self.energy = self._summarize_energy() def to_file(self, jobid, header=""): """Dumps power data to file. Returns filename is succesfull and None if unsucessfull.""" @@ -110,11 +110,11 @@ class Power: _body += self.pretty_print(*self.summarize_epoch(epoch)) return _body - def summarize_time(self, ts): + def _summarize_time(self, ts): return Power.to_csv(ts, "") @staticmethod - def summarize_values(df): + def _summarize_values(df): values = df['power'].values head = values[0] min, max = values.min(), values.max() @@ -124,11 +124,11 @@ class Power: def summarize_epoch(self, epoch): ts, values = epoch - return self.summarize_time(ts), \ - self.summarize_values(values), \ - self.all_values(values) + return self._summarize_time(ts), \ + self._summarize_values(values), \ + self._all_values(values) - def all_values(self, values): + def _all_values(self, values): # reindex frame to get all nodes; introduces gaps values = values[['node', 'power']].set_index('node').reindex(self.nodes) # hack to_csv() to transpose array @@ -139,17 +139,17 @@ class Power: def energy_total(self): energy = None if hasattr(self, "by_node"): - energy = self.by_node.apply(self.energy_node).sum() + energy = self.by_node.apply(self._energy_node).sum() return energy @staticmethod - def energy_node(group): + def _energy_node(group): """Left-sided Riemann sum is enough, as time is lower bound of bucket""" delta_t = group["time"].diff().shift(-1)/1000. # in seconds pow = group['power'] return (delta_t * pow).iloc[:-1].sum() - def summarize_energy(self): + def _summarize_energy(self): return "# Total energy consumed by job: {energy:.0f} J\n".format(energy=self.energy_total()) @staticmethod