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); } } }
public void RetrainerTest() { var retrainer = new WebServiceRetrainer(RetrainServiceUrl, RetrainApiKey); var result = retrainer.Retrain(_inputData, _outputData); result.Wait(); var resultTuple = result.Result; Assert.NotNull(resultTuple); Assert.NotNull(resultTuple.Item2); var resultList = resultTuple.Item2.ToList(); Assert.AreEqual(1, resultList.Count); }
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]); }