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_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
def _get_name(self, name = None):
if name is None:
name = self.ctx.config.get('name', None)
if name is None:
raise AzureException('Please provide project name...')
return name
def verify(self):
if self.ctx.config.get('use_server'):
if not self.subscription_id or \
not self.directory_tenant_id or \
not self.application_client_id or \
not self.client_secret:
raise AzureException('Please provide azure.json file with Azure AD application and service principal.')
elif self.subscription_id is None:
raise AzureException('Please provide your credentials to Azure...')
return True
def history(self):
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)
runs = Run.list(experiment)
result = []
for run in runs:
details = run.get_details()
st = dt.datetime.strptime(
details['startTimeUtc'], '%Y-%m-%dT%H:%M:%S.%fZ')
et = dt.datetime.strptime(
details['endTimeUtc'], '%Y-%m-%dT%H:%M:%S.%fZ')
duratin = str(et-st)
result.append({
'id': run.id,
'start time': details['startTimeUtc'],
'duratin': duratin,
'status': details['status']
})
def verify(self):
if self.ctx.config.get('use_server'):
if not self.subscription_id or \
not self.directory_tenant_id or \
not self.application_client_id or \
not self.client_secret:
raise AzureException('Please provide azure.json file with Azure AD application and service principal.')
elif self.subscription_id is None:
raise AzureException('Please provide your credentials to Azure...')
return True
def start(self):
model_type = self.ctx.config.get('model_type')
if not model_type:
raise AzureException('Please specify model type...')
primary_metric = self.ctx.config.get(
'experiment/metric','spearman_correlation')
if not primary_metric:
raise AzureException('Please specify primary metric...')
#TODO: check if primary_metric is constent with model_type
target = self.ctx.config.get('target')
if not target:
raise AzureException('Please specify target column...')
dataset_name = self.ctx.config.get('dataset', None)
if dataset_name is None:
raise AzureException('Please specify Dataset name...')
experiment_name = self._fix_experiment_name(
self.ctx.config.get('experiment/name', dataset_name))
cluster_name = self._fix_cluster_name(
self.ctx.config.get('cluster/name', 'cpucluster'))
def delete(self, name = None):
ws = self._get_ws()
if name is None:
name = self.ctx.config.get('dataset', None)
if name is None:
raise AzureException('Please specify dataset name...')
ds = Dataset.get_by_name(ws, name)
ds.unregister_all_versions()
self._select(None, False)
self.ctx.log('Deleted dataset %s' % name)
return {'deleted': name}