Exemplo n.º 1
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)
Exemplo n.º 2
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)