def _get_metric_from_file(parent_path, metric_name): metric_data = read_file(parent_path, metric_name) if len(metric_data) == 0: raise Exception("Metric '%s' is malformed. No data found." % metric_name) last_line = metric_data[-1] timestamp, val = last_line.strip().split(" ") return Metric(metric_name, float(val), int(timestamp))
def _get_param_from_file(parent_path, param_name): param_data = read_file(parent_path, param_name) if len(param_data) == 0: raise Exception("Param '%s' is malformed. No data found." % param_name) if len(param_data) > 1: raise Exception( "Unexpected data for param '%s'. Param recorded more than once" % param_name) return Param(param_name, str(param_data[0].strip()))
def _get_tag_from_file(parent_path, tag_name): _validate_tag_name(tag_name) tag_data = read_file(parent_path, tag_name) if len(tag_data) == 0: raise Exception("Tag '%s' is malformed. No data found." % tag_name) if len(tag_data) > 1: raise Exception( "Unexpected data for tag '%s'. Tag recorded more than once" % tag_name) return RunTag(tag_name, str(tag_data[0].strip()))
def get_metric_history(self, run_uuid, metric_key): parent_path, metric_files = self._get_run_files(run_uuid, "metric") if metric_key not in metric_files: raise Exception("Metric '%s' not found under run '%s'" % (metric_key, run_uuid)) metric_data = read_file(parent_path, metric_key) rsl = [] for pair in metric_data: ts, val = pair.strip().split(" ") rsl.append(Metric(metric_key, float(val), int(ts))) return rsl
def _get_tag_from_file(parent_path, tag_name): _validate_tag_name(tag_name) tag_data = read_file(parent_path, tag_name) return RunTag(tag_name, tag_data)
def _get_param_from_file(parent_path, param_name): _validate_param_name(param_name) value = read_file(parent_path, param_name) return Param(param_name, value)