Skip to content

Commit

Permalink
[formrecognizer] Arch board renames (Azure#25345)
Browse files Browse the repository at this point in the history
* rename DocumentModelInfo to DocumentModelDetails

* rename info suffixes to details

* remove kwargs from get_words

* remove unused import
  • Loading branch information
catalinaperalta authored Jul 25, 2022
1 parent 73a21c3 commit 72e3ab4
Show file tree
Hide file tree
Showing 23 changed files with 187 additions and 185 deletions.
8 changes: 5 additions & 3 deletions sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

### Breaking Changes
- Renamed `begin_create_composed_model()` on `DocumentModelAdministrationClient` to `begin_compose_model()`.
- Renamed `get_account_info()` on `DocumentModelAdministrationClient` to `get_resource_info()`.
- Renamed `AccountInfo` model to `ResourceInfo`.
- Renamed `get_account_info()` on `DocumentModelAdministrationClient` to `get_resource_details()`.
- Renamed `AccountInfo` model to `ResourceDetails`.
- Renamed `DocumentModelInfo` model to `DocumentModelSummary`.
- Renamed `DocumentModel` to `DocumentModelInfo`.
- Renamed `DocumentModel` to `DocumentModelDetails`.
- Renamed `ModelOperation` to `ModelOperationDetails`.
- Renamed `ModelOperationInfo` to `ModelOperationSummary`.
- Renamed `model` parameter to `model_id` on `begin_analyze_document()` and `begin_analyze_document_from_url()`.
- Removed `continuation_token` keyword from `begin_analyze_document()` and `begin_analyze_document_from_url()` on `DocumentAnalysisClient` and from `begin_build_model()`, `begin_compose_model()` and `begin_copy_model_to()` on `DocumentModelAdministrationClient`.
- Changed return type of `get_copy_authorization()` from `dict[str, str]` to `TargetAuthorization`.
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 @@ -166,7 +166,7 @@ More information about analyzing documents, including supported features, locale
### DocumentModelAdministrationClient
`DocumentModelAdministrationClient` provides operations for:

- Building custom models to analyze specific fields you specify by labeling your custom documents. A `DocumentModelInfo` is returned indicating the document type(s) the model can analyze, as well as the estimated confidence for each field. See the [service documentation][fr-build-model] for a more detailed explanation.
- Building custom models to analyze specific fields you specify by labeling your custom documents. A `DocumentModelDetails` is returned indicating the document type(s) the model can analyze, as well as the estimated confidence for each field. See the [service documentation][fr-build-model] for a more detailed explanation.
- Creating a composed model from a collection of existing models.
- Managing models created in your account.
- Listing document model operations or getting a specific model operation created within the last 24 hours.
Expand Down Expand Up @@ -518,7 +518,7 @@ credential = AzureKeyCredential("<api_key>")

document_model_admin_client = DocumentModelAdministrationClient(endpoint, credential)

account_info = document_model_admin_client.get_resource_info()
account_info = document_model_admin_client.get_resource_details()
print("Our account has {} custom models, and we can have at most {} custom models".format(
account_info.document_model_count, account_info.document_model_limit
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
DocumentTable,
DocumentTableCell,
DocumentWord,
ModelOperationInfo,
ModelOperation,
DocumentModelInfo,
ModelOperationSummary,
ModelOperationDetails,
DocumentModelDetails,
DocumentModelSummary,
DocTypeInfo,
ResourceInfo,
ResourceDetails,
DocumentAnalysisError,
DocumentAnalysisInnerError,
TargetAuthorization,
Expand Down Expand Up @@ -120,13 +120,13 @@
"DocumentTableCell",
"DocumentWord",
"DocumentModelAdministrationLROPoller",
"ModelOperationInfo",
"ModelOperation",
"ModelOperationSummary",
"ModelOperationDetails",
"DocumentAnalysisApiVersion",
"DocumentModelInfo",
"DocumentModelDetails",
"DocumentModelSummary",
"DocTypeInfo",
"ResourceInfo",
"ResourceDetails",
"DocumentAnalysisError",
"DocumentAnalysisInnerError",
"TargetAuthorization",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
from ._document_analysis_client import DocumentAnalysisClient
from ._models import (
DocumentBuildMode,
DocumentModelInfo,
DocumentModelDetails,
DocumentModelSummary,
ModelOperation,
ModelOperationInfo,
ResourceInfo,
ModelOperationDetails,
ModelOperationSummary,
ResourceDetails,
TargetAuthorization,
)

Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, TokenCre
@distributed_trace
def begin_build_model(
self, source: str, build_mode: Union[str, DocumentBuildMode], **kwargs: Any
) -> DocumentModelAdministrationLROPoller[DocumentModelInfo]:
) -> DocumentModelAdministrationLROPoller[DocumentModelDetails]:
"""Build a custom model.
The request must include a `source` parameter that is an
Expand All @@ -119,8 +119,8 @@ def begin_build_model(
:keyword tags: List of user defined key-value tag attributes associated with the model.
:paramtype tags: dict[str, str]
:return: An instance of an DocumentModelAdministrationLROPoller. Call `result()` on the poller
object to return a :class:`~azure.ai.formrecognizer.DocumentModelInfo`.
:rtype: ~azure.ai.formrecognizer.DocumentModelAdministrationLROPoller[DocumentModelInfo]
object to return a :class:`~azure.ai.formrecognizer.DocumentModelDetails`.
:rtype: ~azure.ai.formrecognizer.DocumentModelAdministrationLROPoller[DocumentModelDetails]
:raises ~azure.core.exceptions.HttpResponseError:
.. versionadded:: v2022-01-30-preview
Expand All @@ -143,7 +143,7 @@ def callback(raw_response, _, headers): # pylint: disable=unused-argument
model_info = self._deserialize(
self._generated_models.ModelInfo, op_response.result
)
return DocumentModelInfo._from_generated(model_info)
return DocumentModelDetails._from_generated(model_info)

description = kwargs.pop("description", None)
model_id = kwargs.pop("model_id", None)
Expand Down Expand Up @@ -181,7 +181,7 @@ def callback(raw_response, _, headers): # pylint: disable=unused-argument
@distributed_trace
def begin_compose_model(
self, component_model_ids: List[str], **kwargs: Any
) -> DocumentModelAdministrationLROPoller[DocumentModelInfo]:
) -> DocumentModelAdministrationLROPoller[DocumentModelDetails]:
"""Creates a composed model from a collection of existing models.
A composed model allows multiple models to be called with a single model ID. When a document is
Expand All @@ -195,8 +195,8 @@ def begin_compose_model(
:keyword tags: List of user defined key-value tag attributes associated with the model.
:paramtype tags: dict[str, str]
:return: An instance of an DocumentModelAdministrationLROPoller. Call `result()` on the poller
object to return a :class:`~azure.ai.formrecognizer.DocumentModelInfo`.
:rtype: ~azure.ai.formrecognizer.DocumentModelAdministrationLROPoller[DocumentModelInfo]
object to return a :class:`~azure.ai.formrecognizer.DocumentModelDetails`.
:rtype: ~azure.ai.formrecognizer.DocumentModelAdministrationLROPoller[DocumentModelDetails]
:raises ~azure.core.exceptions.HttpResponseError:
.. versionadded:: v2022-01-30-preview
Expand All @@ -221,7 +221,7 @@ def _compose_callback(
model_info = self._deserialize(
self._generated_models.ModelInfo, op_response.result
)
return DocumentModelInfo._from_generated(model_info)
return DocumentModelDetails._from_generated(model_info)

model_id = kwargs.pop("model_id", None)
description = kwargs.pop("description", None)
Expand Down Expand Up @@ -298,7 +298,7 @@ def begin_copy_model_to(
model_id: str,
target: TargetAuthorization,
**kwargs: Any
) -> DocumentModelAdministrationLROPoller[DocumentModelInfo]:
) -> DocumentModelAdministrationLROPoller[DocumentModelDetails]:
"""Copy a model stored in this resource (the source) to the user specified
target Form Recognizer resource.
Expand All @@ -311,8 +311,8 @@ def begin_copy_model_to(
The copy authorization generated from the target resource's call to
:func:`~get_copy_authorization()`.
:return: An instance of a DocumentModelAdministrationLROPoller. Call `result()` on the poller
object to return a :class:`~azure.ai.formrecognizer.DocumentModelInfo`.
:rtype: ~azure.ai.formrecognizer.DocumentModelAdministrationLROPoller[DocumentModelInfo]
object to return a :class:`~azure.ai.formrecognizer.DocumentModelDetails`.
:rtype: ~azure.ai.formrecognizer.DocumentModelAdministrationLROPoller[DocumentModelDetails]
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand All @@ -332,7 +332,7 @@ def _copy_callback(raw_response, _, headers): # pylint: disable=unused-argument
model_info = self._deserialize(
self._generated_models.ModelInfo, op_response.result
)
return DocumentModelInfo._from_generated(model_info)
return DocumentModelDetails._from_generated(model_info)

if not model_id:
raise ValueError("model_id cannot be None or empty.")
Expand Down Expand Up @@ -416,33 +416,33 @@ def list_models(self, **kwargs: Any) -> ItemPaged[DocumentModelSummary]:
)

@distributed_trace
def get_resource_info(self, **kwargs: Any) -> ResourceInfo:
def get_resource_details(self, **kwargs: Any) -> ResourceDetails:
"""Get information about the models under the Form Recognizer resource.
:return: Summary of models under the resource - model count and limit.
:rtype: ~azure.ai.formrecognizer.ResourceInfo
:rtype: ~azure.ai.formrecognizer.ResourceDetails
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
.. literalinclude:: ../samples/v3.2-beta/sample_manage_models.py
:start-after: [START get_resource_info]
:end-before: [END get_resource_info]
:start-after: [START get_resource_details]
:end-before: [END get_resource_details]
:language: python
:dedent: 4
:caption: Get model counts and limits under the Form Recognizer resource.
"""

response = self._client.get_info(**kwargs)
return ResourceInfo._from_generated(response.custom_document_models)
return ResourceDetails._from_generated(response.custom_document_models)

@distributed_trace
def get_model(self, model_id: str, **kwargs: Any) -> DocumentModelInfo:
def get_model(self, model_id: str, **kwargs: Any) -> DocumentModelDetails:
"""Get a model by its ID.
:param str model_id: Model identifier.
:return: DocumentModelInfo
:rtype: ~azure.ai.formrecognizer.DocumentModelInfo
:return: DocumentModelDetails
:rtype: ~azure.ai.formrecognizer.DocumentModelDetails
:raises ~azure.core.exceptions.HttpResponseError or ~azure.core.exceptions.ResourceNotFoundError:
.. admonition:: Example:
Expand All @@ -459,18 +459,18 @@ def get_model(self, model_id: str, **kwargs: Any) -> DocumentModelInfo:
raise ValueError("model_id cannot be None or empty.")

response = self._client.get_model(model_id=model_id, **kwargs)
return DocumentModelInfo._from_generated(response)
return DocumentModelDetails._from_generated(response)

@distributed_trace
def list_operations(self, **kwargs: Any) -> ItemPaged[ModelOperationInfo]:
def list_operations(self, **kwargs: Any) -> ItemPaged[ModelOperationSummary]:
"""List information for each document model operation.
Lists all document model operations associated with the Form Recognizer resource.
Note that operation information only persists for 24 hours. If the operation was successful,
the document model can be accessed using the :func:`~get_model` or :func:`~list_models` APIs.
:return: A pageable of ModelOperationInfo.
:rtype: ~azure.core.paging.ItemPaged[ModelOperationInfo]
:return: A pageable of ModelOperationSummary.
:rtype: ~azure.core.paging.ItemPaged[ModelOperationSummary]
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand All @@ -486,22 +486,22 @@ def list_operations(self, **kwargs: Any) -> ItemPaged[ModelOperationInfo]:
return self._client.get_operations( # type: ignore
cls=kwargs.pop(
"cls",
lambda objs: [ModelOperationInfo._from_generated(x) for x in objs],
lambda objs: [ModelOperationSummary._from_generated(x) for x in objs],
),
**kwargs
)

@distributed_trace
def get_operation(self, operation_id: str, **kwargs: Any) -> ModelOperation:
def get_operation(self, operation_id: str, **kwargs: Any) -> ModelOperationDetails:
"""Get a document model operation by its ID.
Get a document model operation associated with the Form Recognizer resource.
Note that operation information only persists for 24 hours. If the operation was successful,
the document model can be accessed using the :func:`~get_model` or :func:`~list_models` APIs.
:param str operation_id: The operation ID.
:return: ModelOperation
:rtype: ~azure.ai.formrecognizer.ModelOperation
:return: ModelOperationDetails
:rtype: ~azure.ai.formrecognizer.ModelOperationDetails
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand All @@ -517,7 +517,7 @@ def get_operation(self, operation_id: str, **kwargs: Any) -> ModelOperation:
if not operation_id:
raise ValueError("'operation_id' cannot be None or empty.")

return ModelOperation._from_generated(
return ModelOperationDetails._from_generated(
self._client.get_operation(operation_id, **kwargs),
api_version=self._api_version,
)
Expand Down
Loading

0 comments on commit 72e3ab4

Please sign in to comment.