Skip to content

Commit 3ae2d0f

Browse files
[Form Recognizer] Consistency changes (Azure#23069)
* update API * changelog * upodate readme * test fixes
1 parent dc0d31c commit 3ae2d0f

File tree

12 files changed

+63
-60
lines changed

12 files changed

+63
-60
lines changed

sdk/formrecognizer/ai-form-recognizer/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
### Breaking Changes
1010

11-
- Renamed the `getModel` and `listModels` methods of `DocumentModelAdministrationClient` to `getDocumentModel` and `listDocumentModels` respectively.
11+
- Renamed `DocumentModelAdministrationClient` methods to have the word `Document` in them, for example `getModel` and `listModels` are updated to `getDocumentModel` and `listDocumentModels` respectively.
1212

1313
## 4.0.0-beta.6 (2022-08-09)
1414

sdk/formrecognizer/ai-form-recognizer/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ const client = new DocumentAnalysisClient("<endpoint>", new DefaultAzureCredenti
143143

144144
`DocumentModelAdministrationClient` provides operations for managing (creating, reading, listing, and deleting) models in the Form Recognizer resource:
145145

146-
- `beginBuildModel` starts an operation to create a new document model from your own training data set. The created model can extract fields according to a custom schema. The training data are expected to be located in an Azure Storage container and organized according to a particular convention. See the [service's documentation on creating a training data set][fr-build-training-set] for a more detailed explanation of applying labels to a training data set.
147-
- `beginComposeModel` starts an operation to compose multiple models into a single model. When used for custom form recognition, the new composed model will first perform a classification of the input documents to determine which of its submodels is most appropriate.
146+
- `beginBuildDocumentModel` starts an operation to create a new document model from your own training data set. The created model can extract fields according to a custom schema. The training data are expected to be located in an Azure Storage container and organized according to a particular convention. See the [service's documentation on creating a training data set][fr-build-training-set] for a more detailed explanation of applying labels to a training data set.
147+
- `beginComposeDocumentModel` starts an operation to compose multiple models into a single model. When used for custom form recognition, the new composed model will first perform a classification of the input documents to determine which of its submodels is most appropriate.
148148
- `beginCopyModelTo` starts an operation to copy a custom model from one Form Recognizer resource to another (or even to the same Form Recognizer resource). It requires a `CopyAuthorization` from the target Form Recognizer resource, which can be generated using the `getCopyAuthorization` method.
149149
- `getResourceDetails` retrieves information about the Form Recognizer resource's limits, such as the number of custom models and the maximum number of models the resource can support.
150-
- `getModel`, `listModels`, and `deleteModel` enable managing models in the resource.
150+
- `getDocumentModel`, `listDocumentModels`, and `deleteDocumentModel` enable managing models in the resource.
151151
- `getOperation` and `listOperations` enable viewing the status of model creation operations, even those operations that are ongoing or that have failed. Operations are retained for 24 hours.
152152

153153
Please note that models can also be created using the Form Recognizer service's graphical user interface: [Form Recognizer Studio (Preview)][fr-studio].
@@ -320,7 +320,7 @@ Each of the above prebuilt models produces `documents` (extracted instances of t
320320

321321
For information about the fields of all of these models, see [the service's documentation of the available prebuilt models](https://aka.ms/azsdk/formrecognizer/models).
322322

323-
The fields of all prebuilt models may also be accessed programmatically using the `getModel` method (by their model IDs) of `DocumentModelAdministrationClient` and inspecting the `docTypes` field in the result.
323+
The fields of all prebuilt models may also be accessed programmatically using the `getDocumentModel` method (by their model IDs) of `DocumentModelAdministrationClient` and inspecting the `docTypes` field in the result.
324324

325325
### Use the "layout" prebuilt
326326

@@ -518,7 +518,7 @@ async function main() {
518518
// The second parameter is the SAS-encoded URL to an Azure Storage container with the training documents.
519519
// The third parameter is the build mode: one of "template" (the only mode prior to 4.0.0-beta.3) or "neural".
520520
// See https://aka.ms/azsdk/formrecognizer/buildmode for more information about build modes.
521-
const poller = await client.beginBuildModel("<model ID>", containerSasUrl, "template", {
521+
const poller = await client.beginBuildDocumentModel("<model ID>", containerSasUrl, "template", {
522522
// The model description is optional and can be any text.
523523
description: "This is my new model!",
524524
onProgress: ({ status }) => {
@@ -571,34 +571,34 @@ async function main() {
571571
const apiKey = "<api key>";
572572
const client = new DocumentModelAdministrationClient(endpoint, new AzureKeyCredential(apiKey));
573573
574-
// Produces an async iterable that supports paging (`PagedAsyncIterableIterator`). The `listModels` method will only
574+
// Produces an async iterable that supports paging (`PagedAsyncIterableIterator`). The `listDocumentModels` method will only
575575
// iterate over model summaries, which do not include detailed schema information. Schema information is only returned
576-
// from `getModel` as part of the full model information.
577-
const models = client.listModels();
576+
// from `getDocumentModel` as part of the full model information.
577+
const models = client.listDocumentModels();
578578
let i = 1;
579579
for await (const summary of models) {
580580
console.log(`Model ${i++}:`, summary);
581581
}
582582
583583
// The iterable is paged, and the application can control the flow of paging if needed
584584
i = 1;
585-
for await (const page of client.listModels().byPage()) {
585+
for await (const page of client.listDocumentModels().byPage()) {
586586
for (const summary of page) {
587587
console.log(`Model ${i++}`, summary);
588588
}
589589
}
590590
591591
// We can also get a full ModelInfo by ID. Here we only show the basic information. See the documentation and the
592-
// `getModel` sample program for information about the `docTypes` field, which contains the model's document type
592+
// `getDocumentModel` sample program for information about the `docTypes` field, which contains the model's document type
593593
// schemas.
594-
const model = await client.getModel("<model ID>");
594+
const model = await client.getDocumentModel("<model ID>");
595595
console.log("ID", model.modelId);
596596
console.log("Created:", model.createdDateTime);
597597
console.log("Description: ", model.description ?? "<none>");
598598
599599
// A model can also be deleted by its model ID. Once it is deleted, it CANNOT be recovered.
600600
const modelIdToDelete = "<model ID that should be deleted forever>";
601-
await client.deleteModel(modelIdToDelete);
601+
await client.deleteDocumentModel(modelIdToDelete);
602602
}
603603
604604
main().catch((err) => {

sdk/formrecognizer/ai-form-recognizer/review/ai-form-recognizer.api.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ export type AnalyzeResultOperationStatus = "notStarted" | "running" | "failed" |
7171
export { AzureKeyCredential }
7272

7373
// @public
74-
export interface BeginBuildModelOptions extends CreateModelOptions {
74+
export interface BeginBuildDocumentModelOptions extends CreateDocumentModelOptions {
7575
}
7676

7777
// @public
78-
export interface BeginComposeModelOptions extends CreateModelOptions {
78+
export interface BeginComposeDocumentModelOptions extends CreateDocumentModelOptions {
7979
}
8080

8181
// @public
@@ -104,11 +104,11 @@ export interface CopyAuthorization {
104104
}
105105

106106
// @public
107-
export function createModelFromSchema(schema: Omit<DocumentModelDetails, "createdDateTime">): DocumentModel<AnalyzeResult<unknown>>;
107+
export interface CreateDocumentModelOptions extends OperationOptions, CommonModelCreationOptions, PollerOptions<DocumentModelOperationState> {
108+
}
108109

109110
// @public
110-
export interface CreateModelOptions extends OperationOptions, CommonModelCreationOptions, PollerOptions<DocumentModelOperationState> {
111-
}
111+
export function createModelFromSchema(schema: Omit<DocumentModelDetails, "createdDateTime">): DocumentModel<AnalyzeResult<unknown>>;
112112

113113
// @public
114114
export interface CurrencyValue {
@@ -123,7 +123,7 @@ export interface CustomDocumentModelsDetails {
123123
}
124124

125125
// @public
126-
export interface DeleteModelOptions extends OperationOptions {
126+
export interface DeleteDocumentModelOptions extends OperationOptions {
127127
}
128128

129129
// @public
@@ -267,10 +267,10 @@ export class DocumentModelAdministrationClient {
267267
constructor(endpoint: string, credential: TokenCredential, options?: DocumentModelAdministrationClientOptions);
268268
constructor(endpoint: string, credential: KeyCredential, options?: DocumentModelAdministrationClientOptions);
269269
constructor(endpoint: string, credential: KeyCredential | TokenCredential, options?: DocumentModelAdministrationClientOptions);
270-
beginBuildModel(modelId: string, containerUrl: string, buildMode: DocumentModelBuildMode, options?: BeginBuildModelOptions): Promise<DocumentModelPoller>;
271-
beginComposeModel(modelId: string, componentModelIds: Iterable<string>, options?: BeginComposeModelOptions): Promise<DocumentModelPoller>;
270+
beginBuildDocumentModel(modelId: string, containerUrl: string, buildMode: DocumentModelBuildMode, options?: BeginBuildDocumentModelOptions): Promise<DocumentModelPoller>;
271+
beginComposeDocumentModel(modelId: string, componentModelIds: Iterable<string>, options?: BeginComposeDocumentModelOptions): Promise<DocumentModelPoller>;
272272
beginCopyModelTo(sourceModelId: string, authorization: CopyAuthorization, options?: BeginCopyModelOptions): Promise<DocumentModelPoller>;
273-
deleteModel(modelId: string, options?: DeleteModelOptions): Promise<void>;
273+
deleteDocumentModel(modelId: string, options?: DeleteDocumentModelOptions): Promise<void>;
274274
getCopyAuthorization(destinationModelId: string, options?: GetCopyAuthorizationOptions): Promise<CopyAuthorization>;
275275
getDocumentModel(modelId: string, options?: GetModelOptions): Promise<DocumentModelDetails>;
276276
getOperation(operationId: string, options?: GetOperationOptions): Promise<OperationDetails>;

sdk/formrecognizer/ai-form-recognizer/samples-dev/buildModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async function main() {
3434

3535
const client = new DocumentModelAdministrationClient(endpoint, credential);
3636

37-
const poller = await client.beginBuildModel(
37+
const poller = await client.beginBuildDocumentModel(
3838
modelId,
3939
trainingDataSasUrl,
4040
DocumentModelBuildMode.Template

sdk/formrecognizer/ai-form-recognizer/samples-dev/composeModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function main() {
5454
Object.entries(purchaseOrderSasUrls)
5555
.map(async ([kind, sasUrl]) => {
5656
const modelId = kind + "ComponentModel" + random.substring(random.length - 6);
57-
const poller = await client.beginBuildModel(
57+
const poller = await client.beginBuildDocumentModel(
5858
modelId,
5959
sasUrl,
6060
DocumentModelBuildMode.Neural,
@@ -74,7 +74,7 @@ export async function main() {
7474
// Finally, create the composed model.
7575

7676
const composedModelId = "purchaseOrders" + random.substring(random.length - 6);
77-
const poller = await client.beginComposeModel(composedModelId, modelIds, {
77+
const poller = await client.beginComposeDocumentModel(composedModelId, modelIds, {
7878
description:
7979
"A composed model that classifies purchase order documents and extracts data from them.",
8080
onProgress(state) {

sdk/formrecognizer/ai-form-recognizer/src/documentModelAdministrationClient.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
import { lro } from "./lro/util/poller";
2727
import {
2828
BeginCopyModelOptions,
29-
DeleteModelOptions,
29+
DeleteDocumentModelOptions,
3030
DocumentModelAdministrationClientOptions,
3131
GetCopyAuthorizationOptions,
3232
GetResourceDetailsOptions,
@@ -36,8 +36,8 @@ import {
3636
ListOperationsOptions,
3737
} from "./options";
3838
import {
39-
BeginBuildModelOptions,
40-
BeginComposeModelOptions,
39+
BeginBuildDocumentModelOptions,
40+
BeginComposeDocumentModelOptions,
4141
DocumentModelBuildMode,
4242
} from "./options/BuildModelOptions";
4343
import { Mappers, SERIALIZER, makeServiceClient } from "./util";
@@ -168,7 +168,7 @@ export class DocumentModelAdministrationClient {
168168
* const modelId = "aNewModel";
169169
* const containerUrl = "<training data container SAS URL>";
170170
*
171-
* const poller = await client.beginBuildModel(modelId, containerUrl, {
171+
* const poller = await client.beginBuildDocumentModel(modelId, containerUrl, {
172172
* // Optionally, a text description may be attached to the model
173173
* description: "This is an example model!"
174174
* });
@@ -191,14 +191,14 @@ export class DocumentModelAdministrationClient {
191191
* @param options - optional settings for the model build operation
192192
* @returns a long-running operation (poller) that will eventually produce the created model information or an error
193193
*/
194-
public async beginBuildModel(
194+
public async beginBuildDocumentModel(
195195
modelId: string,
196196
containerUrl: string,
197197
buildMode: DocumentModelBuildMode,
198-
options: BeginBuildModelOptions = {}
198+
options: BeginBuildDocumentModelOptions = {}
199199
): Promise<DocumentModelPoller> {
200200
return this._tracing.withSpan(
201-
"DocumentModelAdministrationClient.beginBuildModel",
201+
"DocumentModelAdministrationClient.beginBuildDocumentModel",
202202
options,
203203
(finalOptions) =>
204204
this.createDocumentModelPoller({
@@ -237,7 +237,7 @@ export class DocumentModelAdministrationClient {
237237
*
238238
* // The resulting composed model can classify and extract data from documents
239239
* // conforming to any of the above document types
240-
* const poller = await client.beginComposeModel(modelId, subModelIds, {
240+
* const poller = await client.beginComposeDocumentModel(modelId, subModelIds, {
241241
* description: "This is a composed model that can handle several document types."
242242
* });
243243
*
@@ -258,13 +258,13 @@ export class DocumentModelAdministrationClient {
258258
* @param options - optional settings for model creation
259259
* @returns a long-running operation (poller) that will eventually produce the created model information or an error
260260
*/
261-
public async beginComposeModel(
261+
public async beginComposeDocumentModel(
262262
modelId: string,
263263
componentModelIds: Iterable<string>,
264-
options: BeginComposeModelOptions = {}
264+
options: BeginComposeDocumentModelOptions = {}
265265
): Promise<DocumentModelPoller> {
266266
return this._tracing.withSpan(
267-
"DocumentModelAdministrationClient.beginComposeModel",
267+
"DocumentModelAdministrationClient.beginComposeDocumentModel",
268268
options,
269269
(finalOptions) =>
270270
this.createDocumentModelPoller({
@@ -701,7 +701,10 @@ export class DocumentModelAdministrationClient {
701701
* @param modelId - the unique ID of the model to delete from the resource
702702
* @param options - optional settings for the request
703703
*/
704-
public deleteModel(modelId: string, options: DeleteModelOptions = {}): Promise<void> {
704+
public deleteDocumentModel(
705+
modelId: string,
706+
options: DeleteDocumentModelOptions = {}
707+
): Promise<void> {
705708
return this._tracing.withSpan(
706709
"DocumentModelAdministrationClient.deleteDocumentModel",
707710
options,

sdk/formrecognizer/ai-form-recognizer/src/options/BuildModelOptions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ export interface CommonModelCreationOptions {
5656
/**
5757
* Options for the model creation operation.
5858
*/
59-
export interface CreateModelOptions
59+
export interface CreateDocumentModelOptions
6060
extends OperationOptions,
6161
CommonModelCreationOptions,
6262
PollerOptions<DocumentModelOperationState> {}
6363

6464
/**
6565
* Options for the model build operation.
6666
*/
67-
export interface BeginBuildModelOptions extends CreateModelOptions {}
67+
export interface BeginBuildDocumentModelOptions extends CreateDocumentModelOptions {}
6868

6969
/**
7070
* Options for the model compose operation.
7171
*/
72-
export interface BeginComposeModelOptions extends CreateModelOptions {}
72+
export interface BeginComposeDocumentModelOptions extends CreateDocumentModelOptions {}

sdk/formrecognizer/ai-form-recognizer/src/options/DeleteModelOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import { OperationOptions } from "@azure/core-client";
66
/**
77
* Options for model deletion.
88
*/
9-
export interface DeleteModelOptions extends OperationOptions {}
9+
export interface DeleteDocumentModelOptions extends OperationOptions {}

sdk/formrecognizer/ai-form-recognizer/src/options/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
import { AnalyzeDocumentOptions } from "./AnalyzeDocumentsOptions";
55
import {
6-
CreateModelOptions,
6+
CreateDocumentModelOptions,
77
CommonModelCreationOptions,
88
DocumentModelBuildMode,
9-
BeginBuildModelOptions,
10-
BeginComposeModelOptions,
9+
BeginBuildDocumentModelOptions,
10+
BeginComposeDocumentModelOptions,
1111
} from "./BuildModelOptions";
1212
import { BeginCopyModelOptions } from "./BeginCopyModelOptions";
13-
import { DeleteModelOptions } from "./DeleteModelOptions";
13+
import { DeleteDocumentModelOptions } from "./DeleteModelOptions";
1414
import {
1515
DocumentAnalysisClientOptions,
1616
DocumentModelAdministrationClientOptions,
@@ -28,9 +28,9 @@ import { PollerOptions } from "./PollerOptions";
2828

2929
export {
3030
AnalyzeDocumentOptions,
31-
CreateModelOptions,
32-
BeginBuildModelOptions,
33-
BeginComposeModelOptions,
31+
CreateDocumentModelOptions,
32+
BeginBuildDocumentModelOptions,
33+
BeginComposeDocumentModelOptions,
3434
CommonModelCreationOptions,
3535
BeginCopyModelOptions,
3636
DocumentModelBuildMode,
@@ -41,7 +41,7 @@ export {
4141
GetResourceDetailsOptions,
4242
GetModelOptions,
4343
GetOperationOptions,
44-
DeleteModelOptions,
44+
DeleteDocumentModelOptions,
4545
ListModelsOptions,
4646
ListOperationsOptions,
4747
PollerOptions,

sdk/formrecognizer/ai-form-recognizer/test/private/tracing.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,25 @@ describe("supports tracing", function () {
106106
it("deleteModel", () =>
107107
assert.supportsTracing(
108108
fakeIt(async (options: { tracingOptions?: OperationTracingOptions }) => {
109-
await dmac.deleteModel("test", options);
109+
await dmac.deleteDocumentModel("test", options);
110110
}),
111111
["DocumentModelAdministrationClient.deleteDocumentModel"]
112112
));
113113

114114
it("beginBuildModel", () =>
115115
assert.supportsTracing(
116116
fakeIt(async (options: { tracingOptions?: OperationTracingOptions }) => {
117-
await (await dmac.beginBuildModel("test", "test", "neural", options)).poll();
117+
await (await dmac.beginBuildDocumentModel("test", "test", "neural", options)).poll();
118118
}),
119-
["DocumentModelAdministrationClient.beginBuildModel"]
119+
["DocumentModelAdministrationClient.beginBuildDocumentModel"]
120120
));
121121

122122
it("beginComposeModel", () =>
123123
assert.supportsTracing(
124124
fakeIt(async (options: { tracingOptions?: OperationTracingOptions }) => {
125-
await dmac.beginComposeModel("test", [], options);
125+
await dmac.beginComposeDocumentModel("test", [], options);
126126
}),
127-
["DocumentModelAdministrationClient.beginComposeModel"]
127+
["DocumentModelAdministrationClient.beginComposeDocumentModel"]
128128
));
129129

130130
it("getCopyAuthorization", () =>

0 commit comments

Comments
 (0)