def list_experiments(self): """ :return: a list of all known Experiment objects """ response_proto = self._call_endpoint(ListExperiments, None) return [Experiment.from_proto(experiment_proto) for experiment_proto in response_proto.experiments]
def get_experiment(self, experiment_id): """ Fetches the experiment from the backend store. :param experiment_id: Integer id for the experiment :return: A single Experiment object if it exists, otherwise raises an Exception. """ req_body = _message_to_json(GetExperiment(experiment_id=experiment_id)) response_proto = self._call_endpoint(GetExperiment, req_body) return Experiment.from_proto(response_proto.experiment)
def test_creation_and_hydration(self): exp_id = random_int() name = "exp_%d_%d" % (random_int(), random_int()) location = random_file(".json") exp = Experiment(exp_id, name, location) self._check(exp, exp_id, name, location) as_dict = { "experiment_id": exp_id, "name": name, "artifact_location": location } self.assertEqual(dict(exp), as_dict) proto = exp.to_proto() exp2 = Experiment.from_proto(proto) self._check(exp2, exp_id, name, location) exp3 = Experiment.from_dictionary(as_dict) self._check(exp3, exp_id, name, location)