def create_experiment(self, name, artifact_location=None): """Create an experiment. :param name: The experiment name. Must be unique. :param artifact_location: The location to store run artifacts. If not provided, the server picks an appropriate default. :return: Integer ID of the created experiment. """ _validate_experiment_name(name) _validate_experiment_artifact_location(artifact_location) return self.store.create_experiment(name=name, artifact_location=artifact_location,)
def create_experiment(self, name, artifact_location=None, tags=None): self._check_root_dir() _validate_experiment_name(name) self._validate_experiment_does_not_exist(name) # Get all existing experiments and find the one with largest numerical ID. # len(list_all(..)) would not work when experiments are deleted. experiments_ids = [ int(e.experiment_id) for e in self.list_experiments(ViewType.ALL) if e.experiment_id.isdigit() ] experiment_id = max(experiments_ids) + 1 if experiments_ids else 0 return self._create_experiment_with_id(name, str(experiment_id), artifact_location, tags)
def create_experiment(self, name, artifact_location=None): """Create an experiment. :param name: The experiment name. Must be unique. :param artifact_location: The location to store run artifacts. If not provided, the server picks an appropriate default. :return: Integer ID of the created experiment. """ if not self.ranger_can_authorize_create_experiment(): print("Access denied.") raise _validate_experiment_name(name) _validate_experiment_artifact_location(artifact_location) return self.store.create_experiment( name=name, artifact_location=artifact_location, )
def create_experiment(self, name, artifact_location=None, tags=None): """Create an experiment. :param name: The experiment name. Must be unique. :param artifact_location: The location to store run artifacts. If not provided, the server picks an appropriate default. :param tags: A dictionary of key-value pairs that are converted into :py:class:`mlflow.entities.ExperimentTag` objects. :return: Integer ID of the created experiment. """ _validate_experiment_name(name) _validate_experiment_artifact_location(artifact_location) return self.store.create_experiment( name=name, artifact_location=artifact_location, tags=[ExperimentTag(key, value) for (key, value) in tags.items()] if tags else [], )
def rename_experiment(self, experiment_id, new_name): _validate_experiment_name(new_name) meta_dir = os.path.join(self.root_directory, experiment_id) # if experiment is malformed, will raise error experiment = self._get_experiment(experiment_id) if experiment is None: raise MlflowException( "Experiment '%s' does not exist." % experiment_id, databricks_pb2.RESOURCE_DOES_NOT_EXIST, ) self._validate_experiment_does_not_exist(new_name) experiment._set_name(new_name) if experiment.lifecycle_stage != LifecycleStage.ACTIVE: raise Exception( "Cannot rename experiment in non-active lifecycle stage." " Current stage: %s" % experiment.lifecycle_stage) write_yaml(meta_dir, FileStore.META_DATA_FILE_NAME, dict(experiment), overwrite=True)
def test_validate_experiment_name(): _validate_experiment_name("validstring") bytestring = b"test byte string" _validate_experiment_name(bytestring.decode("utf-8")) for invalid_name in ["", 12, 12.7, None, {}, []]: with pytest.raises(MlflowException, match="Invalid experiment name"): _validate_experiment_name(invalid_name)