Пример #1
0
    def test_creation_and_hydration(self):
        rd1, metrics, params = self._create()
        self._check(rd1, metrics, params)

        as_dict = {"metrics": metrics, "params": params}
        self.assertEqual(dict(rd1), as_dict)

        proto = rd1.to_proto()
        rd2 = RunData.from_proto(proto)
        self._check(rd2, metrics, params)

        rd3 = RunData.from_dictionary(as_dict)
        self._check(rd3, metrics, params)
Пример #2
0
 def get_run(self, run_uuid):
     run_dir = self._find_run_root(run_uuid)
     if run_dir is None:
         raise Exception("Run '%s' not found" % run_uuid)
     run_info = self.get_run_info(run_dir)
     metrics = self.get_all_metrics(run_uuid)
     params = self.get_all_params(run_uuid)
     return Run(run_info, RunData(metrics, params))
Пример #3
0
 def from_dictionary(cls, the_dict):
     if "info" not in the_dict or "data" not in the_dict:
         raise Exception(
             "Malformed input '%s'. Run cannot be constructed." %
             str(the_dict))
     the_info = RunInfo.from_dictionary(the_dict.get("info"))
     the_data = RunData.from_dictionary(the_dict.get("data"))
     return cls(the_info, the_data)
Пример #4
0
 def _create():
     metrics = [
         Metric(random_str(10), random_int(),
                int(time.time() + random_int(-1e4, 1e4)))
         for x in range(100)
     ]  # noqa
     params = [
         Param(random_str(10), random_str(random_int(10, 35)))
         for x in range(10)
     ]  # noqa
     rd = RunData()
     for p in params:
         rd.add_param(p)
     for m in metrics:
         rd.add_metric(m)
     return rd, metrics, params
Пример #5
0
 def from_proto(cls, proto):
     return cls(RunInfo.from_proto(proto.info), RunData.from_proto(proto.data))