def create_experiment(self, name, artifact_location=None): if name is None or name == '': raise MlflowException('Invalid experiment name', INVALID_PARAMETER_VALUE) with self.ManagedSessionMaker() as session: try: experiment = SqlExperiment( name=name, lifecycle_stage=LifecycleStage.ACTIVE, artifact_location=artifact_location) session.add(experiment) if not artifact_location: # this requires a double write. The first one to generate an autoincrement-ed ID eid = session.query(SqlExperiment).filter_by( name=name).first().experiment_id experiment.artifact_location = self._get_artifact_location( eid) except sqlalchemy.exc.IntegrityError as e: raise MlflowException( 'Experiment(name={}) already exists. ' 'Error: {}'.format(name, str(e)), RESOURCE_ALREADY_EXISTS) session.flush() return str(experiment.experiment_id)
def create_experiment(self, name, artifact_location=None): if name is None or name == '': raise MlflowException('Invalid experiment name', INVALID_PARAMETER_VALUE) try: experiment = SqlExperiment( name=name, lifecycle_stage=Experiment.ACTIVE_LIFECYCLE, artifact_location=artifact_location ) self.session.add(experiment) self.session.commit() except sqlalchemy.exc.IntegrityError as e: self.session.rollback() print(e) raise MlflowException('Experiment(name={}) already exists'.format(name), RESOURCE_ALREADY_EXISTS, exc_info=e) return experiment.to_mlflow_entity()
def create_experiment(self, name, artifact_location=None): if name is None or name == '': raise MlflowException('Invalid experiment name', INVALID_PARAMETER_VALUE) try: experiment = SqlExperiment(name=name, lifecycle_stage=LifecycleStage.ACTIVE, artifact_location=artifact_location) self.session.add(experiment) self.session.commit() except sqlalchemy.exc.IntegrityError as e: self.session.rollback() raise MlflowException( 'Experiment(name={}) already exists. ' 'Error: {}'.format(name, str(e)), RESOURCE_ALREADY_EXISTS) return experiment.experiment_id