def _create_experiment_with_id(self, name, experiment_id): self._check_root_dir() meta_dir = mkdir(self.root_directory, str(experiment_id)) artifact_uri = build_path(self.artifact_root_uri, str(experiment_id)) experiment = Experiment(experiment_id, name, artifact_uri) write_yaml(meta_dir, FileStore.META_DATA_FILE_NAME, dict(experiment)) return experiment_id
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)
def _create_experiment_with_id(self, name, experiment_id): self._check_root_dir() location = mkdir(self.root_directory, str(experiment_id)) experiment = Experiment(experiment_id, name, location) write_yaml(location, FileStore.META_DATA_FILE_NAME, dict(experiment)) return experiment_id
def _get_experiment(experiment_dir_path): meta = read_yaml(experiment_dir_path, FileStore.META_DATA_FILE_NAME) return Experiment.from_dictionary(meta)