Exemple #1
0
 def _get_metric_from_file(parent_path, metric_name):
     _validate_metric_name(metric_name)
     metric_data = read_file_lines(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))
Exemple #2
0
 def get_metric_history(self, run_id, metric_key):
     _validate_run_id(run_id)
     _validate_metric_name(metric_key)
     parent_path, metric_files = self._get_run_files(run_id, "metric")
     if metric_key not in metric_files:
         raise MlflowException("Metric '%s' not found under run '%s'" % (metric_key, run_id),
                               databricks_pb2.RESOURCE_DOES_NOT_EXIST)
     return [FileStore._get_metric_from_line(metric_key, line)
             for line in read_file_lines(parent_path, metric_key)]
Exemple #3
0
 def _get_param_from_file(parent_path, param_name):
     _validate_param_name(param_name)
     param_data = read_file_lines(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()))
Exemple #4
0
 def _get_param_from_file(parent_path, param_name):
     _validate_param_name(param_name)
     param_data = read_file_lines(parent_path, param_name)
     if len(param_data) > 1:
         raise Exception("Unexpected data for param '%s'. Param recorded more than once"
                         % param_name)
     # The only cause for param_data's length to be zero is the param's
     # value is an empty string
     value = '' if len(param_data) == 0 else str(param_data[0].strip())
     return Param(param_name, value)
Exemple #5
0
 def _get_metric_from_file(parent_path, metric_name):
     _validate_metric_name(metric_name)
     metric_objs = [FileStore._get_metric_from_line(metric_name, line)
                    for line in read_file_lines(parent_path, metric_name)]
     if len(metric_objs) == 0:
         raise ValueError("Metric '%s' is malformed. No data found." % metric_name)
     # Python performs element-wise comparison of equal-length tuples, ordering them
     # based on their first differing element. Therefore, we use max() operator to find the
     # largest value at the largest timestamp. For more information, see
     # https://docs.python.org/3/reference/expressions.html#value-comparisons
     return max(metric_objs, key=lambda m: (m.step, m.timestamp, m.value))
Exemple #6
0
 def get_metric_history(self, run_uuid, metric_key):
     _validate_run_id(run_uuid)
     _validate_metric_name(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_lines(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
Exemple #7
0
 def _get_metric_from_file(parent_path, metric_name):
     _validate_metric_name(metric_name)
     metric_data = []
     for line in read_file_lines(parent_path, metric_name):
         metric_timestamp, metric_value = line.split()
         metric_data.append((int(metric_timestamp), float(metric_value)))
     if len(metric_data) == 0:
         raise ValueError("Metric '%s' is malformed. No data found." %
                          metric_name)
     # Python performs element-wise comparison of equal-length tuples, ordering them
     # based on their first differing element. Therefore, we use max() operator to find the
     # largest value at the largest timestamp. For more information, see
     # https://docs.python.org/3/reference/expressions.html#value-comparisons
     max_timestamp, max_value = max(metric_data)
     return Metric(metric_name, max_value, max_timestamp)