def list_experiments(self, view_type=ViewType.ACTIVE_ONLY): """ :return: a list of all known Experiment objects """ req_body = message_to_json(ListExperiments(view_type=view_type)) response_proto = self._call_endpoint(ListExperiments, req_body) return [ Experiment.from_proto(experiment_proto) for experiment_proto in response_proto.experiments ]
def get_experiment(self, experiment_id): """Fetch the experiment from the backend store. :param experiment_id: String id for the experiment :return: A single :py:class:`segmind_track.entities.Experiment` object if it exists, otherwise raises an Exception. """ req_body = message_to_json( GetExperiment(experiment_id=str(experiment_id))) response_proto = self._call_endpoint(GetExperiment, req_body) return Experiment.from_proto(response_proto.experiment)
def get_experiment_by_name(self, experiment_name): try: req_body = message_to_json( GetExperimentByName(experiment_name=experiment_name)) response_proto = self._call_endpoint(GetExperimentByName, req_body) return Experiment.from_proto(response_proto.experiment) except MlflowException as e: if e.error_code == errorcodes_pb2.ErrorCode.Name( errorcodes_pb2.RESOURCE_DOES_NOT_EXIST): return None elif e.error_code == errorcodes_pb2.ErrorCode.Name( errorcodes_pb2.ENDPOINT_NOT_FOUND): # Fall back to using ListExperiments-based implementation. for experiment in self.list_experiments(ViewType.ALL): if experiment.name == experiment_name: return experiment return None raise e