Skip to content

Commit c6a8752

Browse files
[formrecognizer] Update operation names to include document model (Azure#25843)
* update operation names to include document model * complete document model renames * changelog * docs * migration guide and docs * samples * update tests * fix CurrencyValue docs * update operations description * update async sample tags
1 parent 37c761c commit c6a8752

31 files changed

+254
-248
lines changed

sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
### Breaking Changes
1111
- This library will default to service API version `2022-08-31` going forward.
1212
- Removed `kind` property on `DocumentPage`.
13+
- Renamed `begin_build_model()` to `begin_build_document_model()` on the `DocumentModelAdministrationClient`.
14+
- Renamed `begin_compose_model()` to `begin_compose_document_model()` on the `DocumentModelAdministrationClient`.
15+
- Renamed `begin_copy_model_to()` to `begin_copy_document_model_to()` on the `DocumentModelAdministrationClient`.
16+
- Renamed `list_models()` to `list_document_models()` on the `DocumentModelAdministrationClient`.
17+
- Renamed `get_model()` to `get_document_model()` on the `DocumentModelAdministrationClient`.
18+
- Renamed `delete_model()` to `delete_document_model()` on the `DocumentModelAdministrationClient`.
1319
- Removed `document_model_count` and `document_model_limit` properties on `ResourceDetails`.
1420
- Renamed `DocumentModelOperationDetails` to `OperationDetails`.
1521
- Renamed `DocumentModelOperationSummary` to `OperationSummary`.

sdk/formrecognizer/azure-ai-formrecognizer/MIGRATION_GUIDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ New features provided by the `DocumentAnalysisClient` include:
3131

3232
New features provided by the `DocumentModelAdministrationClient` include:
3333
- Users can now assign their own model IDs and specify a description when building, composing, or copying models.
34-
- Users can specify the algorithm used to build the custom model through the required `build_mode` parameter on `begin_build_model()`. See more about `build_mode` [here][https://aka.ms/azsdk/formrecognizer/buildmode].
34+
- Users can specify the algorithm used to build the custom model through the required `build_mode` parameter on `begin_build_document_model()`. See more about `build_mode` [here][https://aka.ms/azsdk/formrecognizer/buildmode].
3535
- Listing models now includes both prebuilt and custom models.
36-
- When using `get_model()`, users can get the field schema (field names and types that the model can extract) for the model they specified, including for prebuilt models.
36+
- When using `get_document_model()`, users can get the field schema (field names and types that the model can extract) for the model they specified, including for prebuilt models.
3737
- Ability to get information from model operations that occurred in the last 24 hours.
3838

3939
The table below describes the relationship of each client and its supported API version(s):
@@ -632,11 +632,11 @@ for doc in model.training_documents:
632632
```
633633

634634
Train a custom model with `3.2.x`:
635-
Use `begin_build_model()` to build a custom model. Please note that this method has a required `build_mode` parameter. See https://aka.ms/azsdk/formrecognizer/buildmode for more information about build modes. Additionally, `blob_container_url` is a required keyword-only parameter.
635+
Use `begin_build_document_model()` to build a custom document model. Please note that this method has a required `build_mode` parameter. See https://aka.ms/azsdk/formrecognizer/buildmode for more information about build modes. Additionally, `blob_container_url` is a required keyword-only parameter.
636636

637637
```python
638638
document_model_admin_client = DocumentModelAdministrationClient(endpoint, AzureKeyCredential(key))
639-
poller = document_model_admin_client.begin_build_model(
639+
poller = document_model_admin_client.begin_build_document_model(
640640
"template", blob_container_url=container_sas_url, model_id="my-model-id", description="my model description"
641641
)
642642
model = poller.result()

sdk/formrecognizer/azure-ai-formrecognizer/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ credential = AzureKeyCredential("<api_key>")
421421
document_model_admin_client = DocumentModelAdministrationClient(endpoint, credential)
422422

423423
container_sas_url = "<container-sas-url>" # training documents uploaded to blob storage
424-
poller = document_model_admin_client.begin_build_model(
424+
poller = document_model_admin_client.begin_build_document_model(
425425
# For more information about build_mode, see: https://aka.ms/azsdk/formrecognizer/buildmode
426426
build_mode="template", blob_container_url=container_sas_url, model_id="my-first-model"
427427
)
@@ -524,24 +524,24 @@ print("Our account has {} custom models, and we can have at most {} custom model
524524
))
525525

526526
# Here we get a paged list of all of our models
527-
models = document_model_admin_client.list_models()
527+
models = document_model_admin_client.list_document_models()
528528
print("We have models with the following ids: {}".format(
529529
", ".join([m.model_id for m in models])
530530
))
531531

532532
# Replace with the custom model ID from the "Build a model" sample
533533
model_id = "<model_id from the Build a Model sample>"
534534

535-
custom_model = document_model_admin_client.get_model(model_id=model_id)
535+
custom_model = document_model_admin_client.get_document_model(model_id=model_id)
536536
print("Model ID: {}".format(custom_model.model_id))
537537
print("Description: {}".format(custom_model.description))
538538
print("Model created on: {}\n".format(custom_model.created_on))
539539

540540
# Finally, we will delete this model by ID
541-
document_model_admin_client.delete_model(model_id=custom_model.model_id)
541+
document_model_admin_client.delete_document_model(model_id=custom_model.model_id)
542542

543543
try:
544-
document_model_admin_client.get_model(model_id=custom_model.model_id)
544+
document_model_admin_client.get_document_model(model_id=custom_model.model_id)
545545
except ResourceNotFoundError:
546546
print("Successfully deleted model with id {}".format(custom_model.model_id))
547547
```

sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_document_model_administration_client.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, TokenCre
8686
)
8787

8888
@distributed_trace
89-
def begin_build_model(
89+
def begin_build_document_model(
9090
self, build_mode: Union[str, ModelBuildMode], *, blob_container_url: str, **kwargs: Any
9191
) -> DocumentModelAdministrationLROPoller[DocumentModelDetails]:
92-
"""Build a custom model.
92+
"""Build a custom document model.
9393
9494
The request must include a `blob_container_url` keyword parameter that is an
9595
externally accessible Azure storage blob container URI (preferably a Shared Access Signature URI). Note that
@@ -166,10 +166,10 @@ def callback(raw_response, _, headers): # pylint: disable=unused-argument
166166
)
167167

168168
@distributed_trace
169-
def begin_compose_model(
169+
def begin_compose_document_model(
170170
self, component_model_ids: List[str], **kwargs: Any
171171
) -> DocumentModelAdministrationLROPoller[DocumentModelDetails]:
172-
"""Creates a composed model from a collection of existing models.
172+
"""Creates a composed document model from a collection of existing models.
173173
174174
A composed model allows multiple models to be called with a single model ID. When a document is
175175
submitted to be analyzed with a composed model ID, a classification step is first performed to
@@ -238,7 +238,7 @@ def get_copy_authorization(self, **kwargs: Any) -> TargetAuthorization:
238238
"""Generate authorization for copying a custom model into the target Form Recognizer resource.
239239
240240
This should be called by the target resource (where the model will be copied to)
241-
and the output can be passed as the `target` parameter into :func:`~begin_copy_model_to()`.
241+
and the output can be passed as the `target` parameter into :func:`~begin_copy_document_model_to()`.
242242
243243
:keyword str model_id: A unique ID for your copied model.
244244
If not specified, a model ID will be created for you.
@@ -270,10 +270,10 @@ def get_copy_authorization(self, **kwargs: Any) -> TargetAuthorization:
270270
return target
271271

272272
@distributed_trace
273-
def begin_copy_model_to(
273+
def begin_copy_document_model_to(
274274
self, model_id: str, target: TargetAuthorization, **kwargs: Any
275275
) -> DocumentModelAdministrationLROPoller[DocumentModelDetails]:
276-
"""Copy a model stored in this resource (the source) to the user specified
276+
"""Copy a document model stored in this resource (the source) to the user specified
277277
target Form Recognizer resource.
278278
279279
This should be called with the source Form Recognizer resource
@@ -292,8 +292,8 @@ def begin_copy_model_to(
292292
.. admonition:: Example:
293293
294294
.. literalinclude:: ../samples/v3.2-beta/sample_copy_model.py
295-
:start-after: [START begin_copy_model_to]
296-
:end-before: [END begin_copy_model_to]
295+
:start-after: [START begin_copy_document_model_to]
296+
:end-before: [END begin_copy_document_model_to]
297297
:language: python
298298
:dedent: 4
299299
:caption: Copy a model from the source resource to the target resource
@@ -331,8 +331,8 @@ def _copy_callback(raw_response, _, headers): # pylint: disable=unused-argument
331331
)
332332

333333
@distributed_trace
334-
def delete_model(self, model_id: str, **kwargs: Any) -> None:
335-
"""Delete a custom model.
334+
def delete_document_model(self, model_id: str, **kwargs: Any) -> None:
335+
"""Delete a custom document model.
336336
337337
:param model_id: Model identifier.
338338
:type model_id: str
@@ -342,8 +342,8 @@ def delete_model(self, model_id: str, **kwargs: Any) -> None:
342342
.. admonition:: Example:
343343
344344
.. literalinclude:: ../samples/v3.2-beta/sample_manage_models.py
345-
:start-after: [START delete_model]
346-
:end-before: [END delete_model]
345+
:start-after: [START delete_document_model]
346+
:end-before: [END delete_document_model]
347347
:language: python
348348
:dedent: 4
349349
:caption: Delete a model.
@@ -355,7 +355,7 @@ def delete_model(self, model_id: str, **kwargs: Any) -> None:
355355
return self._client.delete_document_model(model_id=model_id, **kwargs)
356356

357357
@distributed_trace
358-
def list_models(self, **kwargs: Any) -> ItemPaged[DocumentModelSummary]:
358+
def list_document_models(self, **kwargs: Any) -> ItemPaged[DocumentModelSummary]:
359359
"""List information for each model, including its model ID,
360360
description, and when it was created.
361361
@@ -366,8 +366,8 @@ def list_models(self, **kwargs: Any) -> ItemPaged[DocumentModelSummary]:
366366
.. admonition:: Example:
367367
368368
.. literalinclude:: ../samples/v3.2-beta/sample_manage_models.py
369-
:start-after: [START list_models]
370-
:end-before: [END list_models]
369+
:start-after: [START list_document_models]
370+
:end-before: [END list_document_models]
371371
:language: python
372372
:dedent: 4
373373
:caption: List all models that were built successfully under the Form Recognizer resource.
@@ -403,8 +403,8 @@ def get_resource_details(self, **kwargs: Any) -> ResourceDetails:
403403
return ResourceDetails._from_generated(response.custom_document_models)
404404

405405
@distributed_trace
406-
def get_model(self, model_id: str, **kwargs: Any) -> DocumentModelDetails:
407-
"""Get a model by its ID.
406+
def get_document_model(self, model_id: str, **kwargs: Any) -> DocumentModelDetails:
407+
"""Get a document model by its ID.
408408
409409
:param str model_id: Model identifier.
410410
:return: DocumentModelDetails
@@ -414,8 +414,8 @@ def get_model(self, model_id: str, **kwargs: Any) -> DocumentModelDetails:
414414
.. admonition:: Example:
415415
416416
.. literalinclude:: ../samples/v3.2-beta/sample_manage_models.py
417-
:start-after: [START get_model]
418-
:end-before: [END get_model]
417+
:start-after: [START get_document_model]
418+
:end-before: [END get_document_model]
419419
:language: python
420420
:dedent: 4
421421
:caption: Get a model by its ID.
@@ -429,11 +429,11 @@ def get_model(self, model_id: str, **kwargs: Any) -> DocumentModelDetails:
429429

430430
@distributed_trace
431431
def list_operations(self, **kwargs: Any) -> ItemPaged[OperationSummary]:
432-
"""List information for each document model operation.
432+
"""List information for each operation.
433433
434-
Lists all document model operations associated with the Form Recognizer resource.
435-
Note that operation information only persists for 24 hours. If the operation was successful,
436-
the document model can be accessed using the :func:`~get_model` or :func:`~list_models` APIs.
434+
Lists all operations associated with the Form Recognizer resource.
435+
Note that operation information only persists for 24 hours. If a document model operation was successful,
436+
the document model can be accessed using the :func:`~get_document_model` or :func:`~list_document_models` APIs.
437437
438438
:return: A pageable of OperationSummary.
439439
:rtype: ~azure.core.paging.ItemPaged[OperationSummary]
@@ -459,11 +459,11 @@ def list_operations(self, **kwargs: Any) -> ItemPaged[OperationSummary]:
459459

460460
@distributed_trace
461461
def get_operation(self, operation_id: str, **kwargs: Any) -> OperationDetails:
462-
"""Get a document model operation by its ID.
462+
"""Get an operation by its ID.
463463
464-
Get a document model operation associated with the Form Recognizer resource.
465-
Note that operation information only persists for 24 hours. If the operation was successful,
466-
the document model can be accessed using the :func:`~get_model` or :func:`~list_models` APIs.
464+
Get an operation associated with the Form Recognizer resource.
465+
Note that operation information only persists for 24 hours. If the document model operation was successful,
466+
the model can be accessed using the :func:`~get_document_model` or :func:`~list_document_models` APIs.
467467
468468
:param str operation_id: The operation ID.
469469
:return: OperationDetails

sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,9 +2120,9 @@ class CurrencyValue:
21202120
"""A currency value element.
21212121
21222122
:ivar amount: The currency amount.
2123-
:vartype: float
2123+
:vartype amount: float
21242124
:ivar symbol: The currency symbol, if found.
2125-
:vartype: Optional[str]
2125+
:vartype symbol: Optional[str]
21262126
"""
21272127

21282128
def __init__(self, **kwargs):
@@ -3266,7 +3266,7 @@ class OperationSummary:
32663266
created, and more.
32673267
32683268
Note that operation information only persists for 24 hours. If the operation was successful,
3269-
the model can be accessed using the :func:`~get_model` or :func:`~list_models` APIs.
3269+
the model can be accessed using the :func:`~get_document_model` or :func:`~list_document_models` APIs.
32703270
To find out why an operation failed, use :func:`~get_operation` and provide the `operation_id`.
32713271
32723272
:ivar operation_id: Operation ID.
@@ -3371,7 +3371,7 @@ class OperationDetails(OperationSummary):
33713371
error of the operation if it has completed.
33723372
33733373
Note that operation information only persists for 24 hours. If the operation was successful,
3374-
the model can also be accessed using the :func:`~get_model` or :func:`~list_models` APIs.
3374+
the model can also be accessed using the :func:`~get_document_model` or :func:`~list_document_models` APIs.
33753375
33763376
:ivar operation_id: Operation ID.
33773377
:vartype operation_id: str

0 commit comments

Comments
 (0)