Skip to content

Commit

Permalink
make it required (#12354)
Browse files Browse the repository at this point in the history
  • Loading branch information
maririos authored Jun 1, 2020
1 parent 27003d4 commit b6d7f43
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- `RecognizeCustomFormsOperation` now returns a `RecognizedFormCollection`.
- In preparation for service-side changes, `FieldValue.AsInt32` has been replaced by `FieldValue.AsInt64`, which returns a `long`.
- The order of the values for `USReceiptType` have changed so that `Other` has now a value of `1`.
- Parameter `useTrainingLabels` is now required for `FormTrainingClient.StartTraining`.

### New Features

Expand Down
4 changes: 2 additions & 2 deletions sdk/formrecognizer/Azure.AI.FormRecognizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Train a machine-learned model on your own form types. The resulting model will b
// https://docs.microsoft.com/azure/cognitive-services/form-recognizer/quickstarts/curl-train-extract#train-a-form-recognizer-model
FormTrainingClient client = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();

Console.WriteLine($"Custom Model Info:");
Console.WriteLine($" Model Id: {model.ModelId}");
Expand Down Expand Up @@ -275,7 +275,7 @@ foreach (CustomFormModelInfo modelInfo in models.Take(10))
}

// Create a new model to store in the account
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();

// Get the model that was just created
CustomFormModel modelCopy = client.GetCustomModel(model.ModelId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Train custom models to recognize all fields and values found in your custom form
// https://docs.microsoft.com/azure/cognitive-services/form-recognizer/quickstarts/curl-train-extract#train-a-form-recognizer-model
FormTrainingClient client = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();

Console.WriteLine($"Custom Model Info:");
Console.WriteLine($" Model Id: {model.ModelId}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ foreach (CustomFormModelInfo modelInfo in models.Take(10))
}

// Create a new model to store in the account
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();

// Get the model that was just created
CustomFormModel modelCopy = client.GetCustomModel(model.ModelId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public FormTrainingClient(Uri endpoint, TokenCredential credential, FormRecogniz
/// <returns>A <see cref="TrainingOperation"/> to wait on this long-running operation. Its <see cref="TrainingOperation"/>.Value upon successful
/// completion will contain meta-data about the trained model.</returns>
[ForwardsClientCalls]
public virtual TrainingOperation StartTraining(Uri trainingFilesUri, bool useTrainingLabels = false, TrainingFileFilter trainingFileFilter = default, CancellationToken cancellationToken = default)
public virtual TrainingOperation StartTraining(Uri trainingFilesUri, bool useTrainingLabels, TrainingFileFilter trainingFileFilter = default, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(trainingFilesUri, nameof(trainingFilesUri));

Expand All @@ -134,7 +134,7 @@ public virtual TrainingOperation StartTraining(Uri trainingFilesUri, bool useTra
/// <returns>A <see cref="TrainingOperation"/> to wait on this long-running operation. Its <see cref="TrainingOperation"/>.Value upon successful
/// completion will contain meta-data about the trained model.</returns>
[ForwardsClientCalls]
public virtual async Task<TrainingOperation> StartTrainingAsync(Uri trainingFilesUri, bool useTrainingLabels = false, TrainingFileFilter trainingFileFilter = default, CancellationToken cancellationToken = default)
public virtual async Task<TrainingOperation> StartTrainingAsync(Uri trainingFilesUri, bool useTrainingLabels, TrainingFileFilter trainingFileFilter = default, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(trainingFilesUri, nameof(trainingFilesUri));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public async Task StartTrainingError()

var containerUrl = new Uri("https://someUrl");

TrainingOperation operation = await client.StartTrainingAsync(containerUrl);
TrainingOperation operation = await client.StartTrainingAsync(containerUrl, useTrainingLabels: false);

await operation.WaitForCompletionAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public async Task StartTrainingEncodesBlankSpaces()
var encodedUriString = "https://fakeuri.com/blank%20space";
var decodedUriString = "https://fakeuri.com/blank space";

await client.StartTrainingAsync(new Uri(encodedUriString));
await client.StartTrainingAsync(new Uri(decodedUriString));
await client.StartTrainingAsync(new Uri(encodedUriString), useTrainingLabels: false);
await client.StartTrainingAsync(new Uri(decodedUriString), useTrainingLabels: false);

Assert.AreEqual(2, mockTransport.Requests.Count);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public void StartTrainingArgumentValidation()
{
FormTrainingClient client = CreateInstrumentedClient();

Assert.ThrowsAsync<UriFormatException>(() => client.StartTrainingAsync(new Uri(string.Empty)));
Assert.ThrowsAsync<ArgumentNullException>(() => client.StartTrainingAsync((Uri)null));
Assert.ThrowsAsync<UriFormatException>(() => client.StartTrainingAsync(new Uri(string.Empty), useTrainingLabels: false));
Assert.ThrowsAsync<ArgumentNullException>(() => client.StartTrainingAsync((Uri)null, useTrainingLabels: false));
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task RecognizeCustomFormsFromFile()
// https://docs.microsoft.com/azure/cognitive-services/form-recognizer/quickstarts/label-tool

FormTrainingClient trainingClient = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
CustomFormModel model = await trainingClient.StartTraining(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await trainingClient.StartTraining(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();

// Proceed with the custom form recognition.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task RecognizeCustomFormsFromUri()
// https://docs.microsoft.com/azure/cognitive-services/form-recognizer/quickstarts/label-tool

FormTrainingClient trainingClient = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
CustomFormModel model = await trainingClient.StartTraining(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await trainingClient.StartTraining(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();

// Proceed with the custom form recognition.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task TrainModelWithForms()
// https://docs.microsoft.com/azure/cognitive-services/form-recognizer/quickstarts/curl-train-extract#train-a-form-recognizer-model

FormTrainingClient client = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();

Console.WriteLine($"Custom Model Info:");
Console.WriteLine($" Model Id: {model.ModelId}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task ManageCustomModels()
}

// Create a new model to store in the account
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();

// Get the model that was just created
CustomFormModel modelCopy = client.GetCustomModel(model.ModelId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task ManageCustomModelsAsync()
}

// Create a new model to store in the account
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await client.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();

// Get the model that was just created
CustomFormModel modelCopy = await client.GetCustomModelAsync(model.ModelId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task CopyModel()

// For the purpose of this sample, we are going to create a trained model to copy. Please note that
// if you already have a model, this is not neccesary.
CustomFormModel model = await sourceClient.StartTraining(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await sourceClient.StartTraining(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();
string modelId = model.ModelId;

#region Snippet:FormRecognizerSample6CreateCopyTargetClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public async Task RecognizeCustomFormsFromFile()
// Firstly, create a trained model we can use to recognize the custom form.

FormTrainingClient trainingClient = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
CustomFormModel model = await trainingClient.StartTraining(new Uri(trainingFileUrl)).WaitForCompletionAsync();
CustomFormModel model = await trainingClient.StartTraining(new Uri(trainingFileUrl), useTrainingLabels: false).WaitForCompletionAsync();

// Proceed with the custom form recognition.

Expand Down

0 comments on commit b6d7f43

Please sign in to comment.