Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_ws(self, create_if_not_exist = False):
if self.ws is None:
self.ws = AzureProject(self.ctx)._get_ws(
create_if_not_exist=create_if_not_exist)
return self.ws
def __init__(self, ctx):
super(AzureProject, self).__init__()
self.ctx = ctx
self.credentials = Credentials(self.ctx).load()
self.credentials.verify()
def stop(self, run_id = None):
ws = AzureProject(self.ctx)._get_ws()
experiment_name = self.ctx.config.get('experiment/name', None)
if experiment_name is None:
raise AzureException('Please specify Experiment name...')
if run_id is None:
run_id = self.ctx.config.get('experiment/run_id', None)
if run_id is None:
raise AzureException(
'Pleae provide Run ID (experiment/run_id)...')
experiment = Experiment(ws, experiment_name)
run = AutoMLRun(experiment = experiment, run_id = run_id)
run.cancel()
return {'stopped': experiment_name}
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}
def _get_experiment(self):
from azureml.core import Experiment
from .project import AzureProject
ws = AzureProject(self.ctx)._get_ws()
experiment_name = self.ctx.config.get('experiment/name', None)
if experiment_name is None:
raise AzureException('Please specify Experiment name...')
experiment = Experiment(ws, experiment_name)
return ws, experiment