Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@error_handler
@authenticated
@with_dataset
def leaderboard(self, dataset, run_id = None):
name = self.ctx.config.get('experiment/name', None)
if name is None:
raise AugerException('Please specify Experiment name...')
if run_id is None:
run_id = self.ctx.config.get(
'experiment/experiment_session_id', None)
leaderboard, status, run_id = Experiment(
self.ctx, dataset, name).leaderboard(run_id)
if leaderboard is None:
raise AugerException('No leaderboard was found...')
self.ctx.log('Leaderboard for Run %s' % run_id)
print_table(self.ctx.log, leaderboard[::-1])
messages = {
@error_handler
@authenticated
def review(self, model_id):
pass
@error_handler
@authenticated
@with_dataset
def stop(self, dataset, run_id = None):
name = self.ctx.config.get('experiment/name', None)
if name is None:
raise AugerException('Please specify Experiment name...')
if run_id is None:
run_id = self.ctx.config.get(
'experiment/experiment_session_id', None)
if Experiment(self.ctx, dataset, name).stop(run_id):
self.ctx.log('Search is stopped...')
else:
self.ctx.log('Search is not running. Stop is ignored.')
return {'stopped': name}
@error_handler
@authenticated
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}
@error_handler
@authenticated
def select(self, name = None):
self._select(name)
self.ctx.log('Selected dataset %s' % name)
return {'selected': name}
@error_handler
@authenticated
@with_dataset
def list(self, dataset):
count = 0
for exp in iter(Experiment(self.ctx, dataset).list()):
self.ctx.log(exp.get('name'))
count += 1
self.ctx.log('%s Experiment(s) listed' % str(count))
return {'experiments': Experiment(self.ctx, dataset).list()}
@error_handler
@authenticated
@with_dataset
def history(self, dataset):
name = self.ctx.config.get('experiment/name', None)
if name is None:
raise AugerException('Please specify Experiment name...')
for exp_run in iter(Experiment(self.ctx, dataset, name).history()):
self.ctx.log("run id: {}, start time: {}, status: {}".format(
exp_run.get('id'),
exp_run.get('model_settings').get('start_time'),
exp_run.get('status')))
return {'history': Experiment(self.ctx, dataset, name).history()}
@error_handler
@authenticated
def list(self):
selected = self.ctx.config.get('dataset', None)
datasets = Dataset.get_all(self._get_ws())
ndatasts = len(datasets)
for name in datasets.keys():
self.ctx.log(
('[%s] ' % ('x' if selected == name else ' ')) + name)
self.ctx.log('%s DataSet(s) listed' % ndatasts)
return {'datasets': [name for name in datasets.keys()]}
@error_handler
@authenticated
@with_project(autocreate=False)
def review(self, project, model_id):
pass
@error_handler
@authenticated
def deploy(self, model_id, locally, review):
if locally:
is_loaded, model_path = self.verify_local_model(model_id)
if is_loaded:
self.ctx.log('Model already deployed to %s' % model_path)
return {'model_id': model_id}
from azureml.train.automl.run import AutoMLRun
ws, experiment = self._get_experiment()
model_run = AutoMLRun(experiment = experiment, run_id = model_id)
result = self._deploy_locally(model_id, model_run, ws, experiment) if locally else \
self._deploy_remotly(model_id, model_run, ws, experiment)