Exemplo n.º 1
0
        public static async Task Run(
            [BlobTrigger("container/{name}", Connection = "AzureWebJobsStorage")] CloudBlockBlob myBlob,
            string name, TraceWriter log)
        {
            log.Info($"C# Blob trigger function Initialized by blob\n Name:{name}\nURI:{myBlob.StorageUri}");

            var inputData  = new AzureStorageData(AzureStorageName, AzureStorageKey, StorageContainerName, name);
            var outputData = new AzureStorageData(AzureStorageName, AzureStorageKey,
                                                  AzureLearningContainerName, Path.GetFileNameWithoutExtension(name) + "_outputresults.ilearner");

            log.Info("Retraining of Machine Learning started...");

            var retrainer      = new WebServiceRetrainer(RetrainServiceUrl, RetrainApiKey);
            var retrainResults = await retrainer.Retrain(inputData, outputData);

            if (retrainResults.Item2 == null)
            {
                log.Info("Retraining finished with an error.");
                log.Info(retrainResults.Item1);
            }
            else
            {
                log.Info("Retraining finished successfully.");
                log.Info("Model update started...");
                var updater      = new WebServiceUpdater(PredictiveServiceUrl, PredictiveUpdateEndpointApiKey);
                var updateResult = await updater.UpdateModel(retrainResults.Item2, RetrainServiceName);

                foreach (var info in updateResult)
                {
                    log.Info(info);
                }
            }
        }
Exemplo n.º 2
0
        public void UpdaterTest()
        {
            var updater    = new WebServiceUpdater(PredictiveServiceUrl, PredictiveUpdateEndpointApiKey);
            var references = new List <AzureBlobDataReference>
            {
                // fill below data with valid one before running test!
                new AzureBlobDataReference
                {
                    BaseLocation     = "https://service.blob.core.windows.net/",
                    RelativeLocation = "<container with data>/<blob with output .ilearner>",
                    SasBlobToken     = "?<sastoken>"
                }
            };
            var result = updater.UpdateModel(references, RetrainServiceName);

            result.Wait();
            var resultString = result.Result;

            Assert.NotNull(resultString);
            Assert.AreEqual(1, resultString.Count);
            Assert.AreEqual("Web Service updated successfully with <container with data>/<blob with output.ilearner>", resultString[0]);
        }
Exemplo n.º 3
0
        public void RetrainAndUpdateTest()
        {
            var retrainer     = new WebServiceRetrainer(RetrainServiceUrl, RetrainApiKey);
            var retrainResult = retrainer.Retrain(_inputData, _outputData);

            retrainResult.Wait();
            var resultTuple = retrainResult.Result;

            Assert.NotNull(resultTuple);
            Assert.NotNull(resultTuple.Item2);
            var resultList = resultTuple.Item2.ToList();

            Assert.AreEqual(1, resultList.Count);

            var updater      = new WebServiceUpdater(PredictiveServiceUrl, PredictiveUpdateEndpointApiKey);
            var updateResult = updater.UpdateModel(resultList, RetrainServiceName);

            updateResult.Wait();
            var resultString = updateResult.Result;

            Assert.NotNull(resultString);
            Assert.AreEqual(1, resultString.Count);
            Assert.AreEqual("Web Service updated successfully with <container with data>/<blob with output.ilearner>", resultString[0]);
        }