def getExperiment(workspace, experiment_name): ''' Gets an AMLS experiment. Searches through the provided workspace experiments first to see if it already exists. If not, create a new one, otherwise return the existing one. PARAMS: workspace : azureml.core.Workspace : Existing AMLS Workspace experiment_name : String : Name of experiment to retrieve/create RETURNS: azureml.core.Experiment ''' found = False return_experiment = None for experiment in Experiment.list(workspace): if experiment.name == experiment_name: print("Returning existing experiment", experiment_name) found = True return_experiment = experiment if not found: print("Creating new experiment", experiment_name) return_experiment = Experiment(workspace, experiment_name) return return_experiment
def list(self): ws = AzureProject(self.ctx)._get_ws() experiments = Experiment.list(workspace=ws) nexperiments = len(experiments) experiments = [e.name for e in experiments] for name in experiments: self.ctx.log(name) self.ctx.log('%s Experiment(s) listed' % str(nexperiments)) return {'experiments': experiments}