Beispiel #1
0
 public string StartDatasetSchemaGen(WorkspaceSetting setting, string dataTypeId, string uploadFileId, string datasetName, string description, string uploadFileName)
 {
     ValidateWorkspaceSetting(setting);
     Util.AuthorizationToken = setting.AuthorizationToken;            
     dynamic schemaJob = new
     {
         DataSource = new
         {
             Name = datasetName,
             DataTypeId = dataTypeId,
             Description = description,
             FamilyId = string.Empty,
             Owner = "PowerShell",
             SourceOrigin = "FromResourceUpload"
         },
         UploadId = uploadFileId,
         UploadedFromFileName = Path.GetFileName(uploadFileName),
         ClientPoll = true
     };
     string query = StudioApi + string.Format("workspaces/{0}/datasources", setting.WorkspaceId);
     HttpResult hr = Util.HttpPost(query, jss.Serialize(schemaJob)).Result;
     if (!hr.IsSuccess)
         throw new AmlRestApiException(hr);
     string dataSourceId = hr.Payload.Replace("\"", "");
     return dataSourceId;
 }
Beispiel #2
0
        public void PromoteUserAsset(WorkspaceSetting setting, string experimentId, string nodeId, string nodeOutputName, string assetName, string assetDescription, UserAssetType assetType, string familyId)
        {
            ValidateWorkspaceSetting(setting);
            Util.AuthorizationToken = setting.AuthorizationToken;

            string queryUrl = StudioApi + string.Format("workspaces/{0}/{1}", setting.WorkspaceId, assetType == UserAssetType.Transform ? "transformmodules" : (assetType == UserAssetType.TrainedModel ? "trainedmodels" : "datasources"));
            string postPayloadInJson = string.Empty;
            switch (assetType)
            {
                case UserAssetType.Transform:
                    var transformPayload = new
                    {
                        ExperimentId = experimentId,
                        ModuleNodeId = nodeId,
                        OutputName = nodeOutputName,
                        Transform = new
                        {
                            Name = assetName,
                            DataTypeId = "iTransformDotNet",
                            Description = assetDescription,
                            SourceOrigin = "FromOutputPromotion",
                            FamilyId = familyId
                        }
                    };
                    postPayloadInJson = jss.Serialize(transformPayload);
                    break;
                case UserAssetType.TrainedModel:
                    var trainedModelPayload = new
                    {
                        ExperimentId = experimentId,
                        ModuleNodeId = nodeId,
                        OutputName = nodeOutputName,
                        TrainedModel = new
                        {
                            Name = assetName,
                            DataTypeId = "iLearnerDotNet",
                            Description = assetDescription,
                            SourceOrigin = "FromOutputPromotion",
                            FamilyId = familyId
                        }
                    };
                    postPayloadInJson = jss.Serialize(trainedModelPayload);
                    break;
                case UserAssetType.Dataset:
                    var datasetPayload = new
                    {
                        ExperimentId = experimentId,
                        ModuleNodeId = nodeId,
                        OutputName = nodeOutputName,
                        DataSource = new
                        {
                            Name = assetName,
                            DataTypeId = "Dataset",
                            Description = assetDescription,
                            SourceOrigin = "FromOutputPromotion",
                            FamilyId = familyId
                        }
                    };
                    postPayloadInJson = jss.Serialize(datasetPayload);
                    break;
            }
            HttpResult hr = Util.HttpPost(queryUrl, postPayloadInJson).Result;
            if (hr.IsSuccess)
            {
                return;
            }
            throw new AmlRestApiException(hr);
        }
        protected override void ProcessRecord()
        {            
            ProgressRecord pr = new ProgressRecord(1, "Patch Web Service Endpoint", "Web Service");
            pr.PercentComplete = 1;
            pr.CurrentOperation = "Getting web service...";
            WriteProgress(pr);
            WebService ws = Sdk.GetWebServicesById(GetWorkspaceSetting(), WebServiceId);

            pr.PercentComplete = 10;
            pr.StatusDescription = "Web Service \"" + ws.Name + "\"";
            pr.CurrentOperation = "Getting web service endpoint...";
            WriteProgress(pr);

            WebServiceEndPoint wep = Sdk.GetWebServiceEndpointByName(GetWorkspaceSetting(), WebServiceId, EndpointName);
            pr.PercentComplete = 20;
            pr.StatusDescription = "Web Service \"" + ws.Name + "\", Endpoint \"" + wep.Name + "\"";
            pr.CurrentOperation = "Patching web service endpoint with new trained model...";
            WriteProgress(pr);

            dynamic patchReq = new
            {
                Resources = new[] {
                    new {
                        Name = ResourceName,
                        Location = new {
                            BaseLocation = BaseLocation,
                            RelativeLocation = RelativeLocation,
                            SasBlobToken = SasBlobToken
                        }
                    }
                }
            };
            Sdk.PatchWebServiceEndpoint(GetWorkspaceSetting(), WebServiceId, EndpointName, patchReq);
            WriteObject(string.Format("Endpoint \"{0}\" resource \"{1}\" successfully patched.", wep.Name, wep.Resources[0].Name));
        }