Esempio n. 1
0
def listOperationOutputs(operationNoun, subscriptionId='default'):

    try:
        sub, version, workspace, apiVersion = getMetadata(subscriptionId)
        amlUtil = AzureMLUtils(workspace, version.ConfigFile)
        result = amlUtil.listAllOperationOutputs(operationNoun, sub.Owner,
                                                 sub.SubscriptionId)
        return jsonify(result)
    except Exception as e:
        return handleExceptions(e)
Esempio n. 2
0
def getOperationStatus(operationVerb, operationId, subscriptionId='default'):
    try:
        sub, version, workspace, apiVersion = getMetadata(subscriptionId)
        amlUtil = AzureMLUtils(workspace, version.ConfigFile)
        result = amlUtil.getOperationStatus(operationVerb, operationId,
                                            sub.Owner, sub.SubscriptionId)
        if result:
            return jsonify(result)
        else:
            raise LunaUserException(
                HTTPStatus.NOT_FOUND,
                'Object with id {} does not exist.'.format(operationId))
    except Exception as e:
        return handleExceptions(e)
Esempio n. 3
0
def executeChildOperation(parentOperationNoun,
                          parentOperationId,
                          operationVerb,
                          subscriptionId='default'):

    try:
        sub, version, workspace, apiVersion = getMetadata(subscriptionId)
        amlUtil = AzureMLUtils(workspace, version.ConfigFile)
        if version.VersionSourceType == 'git':
            if os.environ["AGENT_MODE"] == "SAAS":
                computeCluster = "default"
            else:
                computeCluster = sub.AMLWorkspaceComputeClusterName
            opId = amlUtil.runProject(sub.ProductName,
                                      sub.DeploymentName,
                                      apiVersion,
                                      operationVerb,
                                      json.dumps(request.json),
                                      parentOperationId,
                                      sub.Owner,
                                      sub.SubscriptionId,
                                      computeCluster=computeCluster)
        elif version.VersionSourceType == 'amlPipeline':
            if parentOperationNoun != 'models':
                return 'The parent resource type {} is not supported'.format(
                    parentOperationNoun)
            url = None
            if operationVerb == 'batchinference':
                url = version.BatchInferenceAPI
            elif operationVerb == 'deploy':
                url = version.DeployModelAPI

            if url and url != "":
                opId = amlUtil.submitPipelineRun(url, sub.ProductName,
                                                 sub.DeploymentName,
                                                 apiVersion, operationVerb,
                                                 json.dumps(request.json),
                                                 parentOperationId, sub.Owner,
                                                 sub.SubscriptionId)
            else:
                return 'The operation {} is not supported'.format(
                    operationVerb)

        return jsonify({'operationId': opId})

    except Exception as e:
        return handleExceptions(e)
Esempio n. 4
0
 def Get(workspaceName):
     session = Session()
     workspace = session.query(AMLWorkspace).filter_by(WorkspaceName = workspaceName).first()
     workspace.AADApplicationSecret = key_vault_helper.get_secret(workspace.AADApplicationSecretName)
     util = AzureMLUtils(workspace)
     workspace.ComputeClusters = util.getComputeClusters()
     workspace.DeploymentClusters = util.getDeploymentClusters()
     workspace.DeploymentTargetTypes = [{
             'id': 'aks',
             'displayName': 'Azure Kubernates Service'
         },
         {
             'id': 'aci',
             'displayName': 'Azure Container Instances'
         }]
     ## never return the workspace secret
     workspace.AADApplicationSecret = "notchanged"
     session.close()
     return workspace
Esempio n. 5
0
def getOperationOutput(operationNoun, operationId, subscriptionId='default'):

    try:
        sub, version, workspace, apiVersion = getMetadata(subscriptionId)
        amlUtil = AzureMLUtils(workspace, version.ConfigFile)
        result, outputType = amlUtil.getOperationOutput(
            operationNoun, operationId, sub.Owner, sub.SubscriptionId)
        if not result:
            raise LunaUserException(
                HTTP_Status.NOT_FOUND,
                "The specified operation didn't generate any output.")
        if outputType == "file":
            with open(result, 'rb') as bites:
                return send_file(
                    io.BytesIO(bites.read()),
                    attachment_filename='outputs_{}.zip'.format(operationId),
                    mimetype='application/zip')
        return jsonify(result)

    except Exception as e:
        return handleExceptions(e)