コード例 #1
0
        public async Task AdminOps(bool useTokenCredential)
        {
            var client           = CreateDocumentModelAdministrationClient(useTokenCredential);
            var trainingFilesUri = new Uri(TestEnvironment.BlobContainerSasUrl);
            var modelId          = Recording.GenerateId();

            BuildModelOperation operation = await client.StartBuildModelAsync(trainingFilesUri,
                                                                              modelId,
                                                                              new BuildModelOptions()
            {
                ModelDescription = "This is a test model."
            });

            await operation.WaitForCompletionAsync();

            DocumentModel resultModel = await client.GetModelAsync(modelId);

            ValidateDocumentModel(resultModel, true);

            DocumentModelInfo modelInfo = client.GetModelsAsync().ToEnumerableAsync().Result.FirstOrDefault();

            ValidateDocumentModelInfo(modelInfo);

            await client.DeleteModelAsync(modelId);

            RequestFailedException ex = Assert.ThrowsAsync <RequestFailedException>(() => client.GetModelAsync(modelId));

            Console.WriteLine(ex.ErrorCode);
        }
コード例 #2
0
        private void ValidateDocumentModelInfo(DocumentModelInfo model, string description = null, IReadOnlyDictionary <string, string> tags = null)
        {
            if (description != null)
            {
                Assert.AreEqual(description, model.Description);
            }

            if (tags != null)
            {
                CollectionAssert.AreEquivalent(tags, model.Tags);
            }

            Assert.IsNotNull(model.ModelId);
            Assert.IsNotNull(model.CreatedOn);
            Assert.AreNotEqual(new DateTimeOffset(), model.CreatedOn);
        }
コード例 #3
0
        public async Task AdminOps(bool useTokenCredential)
        {
            var client           = CreateDocumentModelAdministrationClient(useTokenCredential);
            var trainingFilesUri = new Uri(TestEnvironment.BlobContainerSasUrl);
            var modelId          = Recording.GenerateId();
            var description      = "This is a test model.";

            var options = new BuildModelOptions()
            {
                ModelDescription = description
            };

            foreach (var tag in TestingTags)
            {
                options.Tags.Add(tag);
            }

            BuildModelOperation operation = await client.StartBuildModelAsync(trainingFilesUri, DocumentBuildMode.Template, modelId, options);

            await operation.WaitForCompletionAsync();

            DocumentModel resultModel = await client.GetModelAsync(modelId);

            ValidateDocumentModel(resultModel, description, TestingTags);

            DocumentModelInfo modelInfo = client.GetModelsAsync().ToEnumerableAsync().Result
                                          .FirstOrDefault(m => m.ModelId == modelId);

            Assert.NotNull(modelInfo);

            ValidateDocumentModelInfo(modelInfo, description, TestingTags);

            await client.DeleteModelAsync(modelId);

            RequestFailedException ex = Assert.ThrowsAsync <RequestFailedException>(() => client.GetModelAsync(modelId));

            Console.WriteLine(ex.ErrorCode);
        }
コード例 #4
0
 private void ValidateDocumentModelInfo(DocumentModelInfo model)
 {
     Assert.IsNotNull(model.ModelId);
     Assert.IsNotNull(model.CreatedOn);
     Assert.AreNotEqual(new DateTimeOffset(), model.CreatedOn);
 }