Skip to content

Commit eeb6adc

Browse files
[formrecognizer] Rename some beta components (Azure#23448)
* rename copy model and composed model APIs * update AccountInfo property names
1 parent 80d2b2f commit eeb6adc

16 files changed

+82
-78
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
### Features Added
66

77
### Breaking Changes
8+
- Renamed `begin_copy_model()` to `begin_copy_model_to()`.
9+
- In `begin_create_composed_model()`, renamed required parameter `model_ids` to `component_model_ids`.
10+
- Renamed `model_count` and `model_limit` on `AccountInfo` to `document_model_count` and `document_model_limit`.
811

912
### Bugs Fixed
1013

1114
### Other Changes
15+
- Renamed `sample_copy_model.py` and `sample_copy_model_async.py` to `sample_copy_model_to.py` and `sample_copy_model_to_async.py` under the `3.2-beta` samples folder. Updated the samples to use renamed copy model method.
1216

1317
## 3.2.0b3 (2022-02-10)
1418

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ document_model_admin_client = DocumentModelAdministrationClient(endpoint, creden
544544

545545
account_info = document_model_admin_client.get_account_info()
546546
print("Our account has {} custom models, and we can have at most {} custom models".format(
547-
account_info.model_count, account_info.model_limit
547+
account_info.document_model_count, account_info.document_model_limit
548548
))
549549

550550
# Here we get a paged list of all of our models

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ def callback(raw_response, _, headers): # pylint: disable=unused-argument
181181
)
182182

183183
@distributed_trace
184-
def begin_create_composed_model(self, model_ids, **kwargs):
184+
def begin_create_composed_model(self, component_model_ids, **kwargs):
185185
# type: (List[str], Any) -> DocumentModelAdministrationLROPoller[DocumentModel]
186186
"""Creates a composed model from a collection of existing models.
187187
188188
A composed model allows multiple models to be called with a single model ID. When a document is
189189
submitted to be analyzed with a composed model ID, a classification step is first performed to
190190
route it to the correct custom model.
191191
192-
:param list[str] model_ids: List of model IDs to use in the composed model.
192+
:param list[str] component_model_ids: List of model IDs to use in the composed model.
193193
:keyword str model_id: A unique ID for your composed model.
194194
If not specified, a model ID will be created for you.
195195
:keyword str description: An optional description to add to the model.
@@ -243,9 +243,9 @@ def _compose_callback(
243243
tags=tags,
244244
component_models=[
245245
self._generated_models.ComponentModelInfo(model_id=model_id)
246-
for model_id in model_ids
246+
for model_id in component_model_ids
247247
]
248-
if model_ids
248+
if component_model_ids
249249
else [],
250250
),
251251
cls=kwargs.pop("cls", _compose_callback),
@@ -264,7 +264,7 @@ def get_copy_authorization(self, **kwargs):
264264
"""Generate authorization for copying a custom model into the target Form Recognizer resource.
265265
266266
This should be called by the target resource (where the model will be copied to)
267-
and the output can be passed as the `target` parameter into :func:`~begin_copy_model()`.
267+
and the output can be passed as the `target` parameter into :func:`~begin_copy_model_to()`.
268268
269269
:keyword str model_id: A unique ID for your copied model.
270270
If not specified, a model ID will be created for you.
@@ -296,7 +296,7 @@ def get_copy_authorization(self, **kwargs):
296296
return target
297297

298298
@distributed_trace
299-
def begin_copy_model(
299+
def begin_copy_model_to(
300300
self,
301301
model_id, # type: str
302302
target, # type: Dict
@@ -323,8 +323,8 @@ def begin_copy_model(
323323
.. admonition:: Example:
324324
325325
.. literalinclude:: ../samples/v3.2-beta/sample_copy_model.py
326-
:start-after: [START begin_copy_model]
327-
:end-before: [END begin_copy_model]
326+
:start-after: [START begin_copy_model_to]
327+
:end-before: [END begin_copy_model_to]
328328
:language: python
329329
:dedent: 4
330330
:caption: Copy a model from the source resource to the target resource

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4086,30 +4086,30 @@ def from_dict(cls, data):
40864086
class AccountInfo(object):
40874087
"""Info regarding models under the Form Recognizer resource.
40884088
4089-
:ivar int model_count: Number of custom models in the current resource.
4090-
:ivar int model_limit: Maximum number of custom models supported in the current resource.
4089+
:ivar int document_model_count: Number of custom models in the current resource.
4090+
:ivar int document_model_limit: Maximum number of custom models supported in the current resource.
40914091
"""
40924092

40934093
def __init__(
40944094
self,
40954095
**kwargs
40964096
):
4097-
self.model_count = kwargs.get('model_count', None)
4098-
self.model_limit = kwargs.get('model_limit', None)
4097+
self.document_model_count = kwargs.get('document_model_count', None)
4098+
self.document_model_limit = kwargs.get('document_model_limit', None)
40994099

41004100
def __repr__(self):
41014101
return (
4102-
"AccountInfo(model_count={}, model_limit={})".format(
4103-
self.model_count,
4104-
self.model_limit,
4102+
"AccountInfo(document_model_count={}, document_model_limit={})".format(
4103+
self.document_model_count,
4104+
self.document_model_limit,
41054105
)
41064106
)
41074107

41084108
@classmethod
41094109
def _from_generated(cls, info):
41104110
return cls(
4111-
model_count=info.count,
4112-
model_limit=info.limit,
4111+
document_model_count=info.count,
4112+
document_model_limit=info.limit,
41134113
)
41144114

41154115

@@ -4121,8 +4121,8 @@ def to_dict(self):
41214121
:rtype: dict
41224122
"""
41234123
return {
4124-
"model_count": self.model_count,
4125-
"model_limit": self.model_limit,
4124+
"document_model_count": self.document_model_count,
4125+
"document_model_limit": self.document_model_limit,
41264126
}
41274127

41284128
@classmethod
@@ -4135,8 +4135,8 @@ def from_dict(cls, data):
41354135
:rtype: AccountInfo
41364136
"""
41374137
return cls(
4138-
model_count=data.get("model_count", None),
4139-
model_limit=data.get("model_limit", None),
4138+
document_model_count=data.get("document_model_count", None),
4139+
document_model_limit=data.get("document_model_limit", None),
41404140
)
41414141

41424142

sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_document_model_administration_client_async.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ def callback(raw_response, _, headers): # pylint: disable=unused-argument
186186
)
187187

188188
@distributed_trace_async
189-
async def begin_create_composed_model(self, model_ids, **kwargs):
189+
async def begin_create_composed_model(self, component_model_ids, **kwargs):
190190
# type: (List[str], Any) -> AsyncDocumentModelAdministrationLROPoller[DocumentModel]
191191
"""Creates a composed model from a collection of existing models.
192192
193193
A composed model allows multiple models to be called with a single model ID. When a document is
194194
submitted to be analyzed with a composed model ID, a classification step is first performed to
195195
route it to the correct custom model.
196196
197-
:param list[str] model_ids: List of model IDs to use in the composed model.
197+
:param list[str] component_model_ids: List of model IDs to use in the composed model.
198198
:keyword str model_id: A unique ID for your composed model.
199199
If not specified, a model ID will be created for you.
200200
:keyword str description: An optional description to add to the model.
@@ -248,9 +248,9 @@ def _compose_callback(
248248
tags=tags,
249249
component_models=[
250250
self._generated_models.ComponentModelInfo(model_id=model_id)
251-
for model_id in model_ids
251+
for model_id in component_model_ids
252252
]
253-
if model_ids
253+
if component_model_ids
254254
else [],
255255
),
256256
cls=kwargs.pop("cls", _compose_callback),
@@ -268,7 +268,7 @@ async def get_copy_authorization(self, **kwargs: Any) -> Dict[str, str]:
268268
"""Generate authorization for copying a custom model into the target Form Recognizer resource.
269269
270270
This should be called by the target resource (where the model will be copied to)
271-
and the output can be passed as the `target` parameter into :func:`~begin_copy_model()`.
271+
and the output can be passed as the `target` parameter into :func:`~begin_copy_model_to()`.
272272
273273
:keyword str model_id: A unique ID for your copied model.
274274
If not specified, a model ID will be created for you.
@@ -300,7 +300,7 @@ async def get_copy_authorization(self, **kwargs: Any) -> Dict[str, str]:
300300
return target
301301

302302
@distributed_trace_async
303-
async def begin_copy_model(
303+
async def begin_copy_model_to(
304304
self, model_id: str, target: dict, **kwargs: Any
305305
) -> AsyncDocumentModelAdministrationLROPoller[DocumentModel]:
306306
"""Copy a model stored in this resource (the source) to the user specified
@@ -322,9 +322,9 @@ async def begin_copy_model(
322322
323323
.. admonition:: Example:
324324
325-
.. literalinclude:: ../samples/v3.2-beta/async_samples/sample_copy_model_async.py
326-
:start-after: [START begin_copy_model_async]
327-
:end-before: [END begin_copy_model_async]
325+
.. literalinclude:: ../samples/v3.2-beta/async_samples/sample_copy_model_to_async.py
326+
:start-after: [START begin_copy_model_to_async]
327+
:end-before: [END begin_copy_model_to_async]
328328
:language: python
329329
:dedent: 4
330330
:caption: Copy a model from the source resource to the target resource

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ All of these samples need the endpoint to your Form Recognizer resource ([instru
4040
|[sample_create_composed_model.py][sample_composed_model] and [sample_create_composed_model_async.py][sample_composed_model_async]|Create a composed model from a collection of existing models to be called with a single model ID|
4141
|[sample_manage_models.py][sample_manage_models] and [sample_manage_models_async.py][sample_manage_models_async]|Manage the models in your account|
4242
|[sample_get_operations.py][sample_get_operations] and [sample_get_operations_async.py][sample_get_operations_async]|Get and list the document model operations created within the past 24 hours|
43-
|[sample_copy_model.py][sample_copy] and [sample_copy_model_async.py][sample_copy_async]|Copy a custom model from one Form Recognizer resource to another|
43+
|[sample_copy_model_to.py][sample_copy] and [sample_copy_model_to_async.py][sample_copy_async]|Copy a custom model from one Form Recognizer resource to another|
4444
|[sample_get_words_on_document_line.py][sample_get_words_on_document_line] and [sample_get_words_on_document_line_async.py][sample_get_words_on_document_line_async]|Get the words in a DocumentLine|
4545
|[sample_convert_to_and_from_dict.py][sample_convert_to_and_from_dict_v3_2] and [sample_convert_to_and_from_dict_async.py][sample_convert_to_and_from_dict_async_v3_2]|Convert model types to a dictionary that can be used to create JSON content, then convert the same dictionary back to the original model type|
4646
|[sample_get_elements_with_spans.py][sample_get_elements_with_spans] and [sample_get_elements_with_spans_async.py][sample_get_elements_with_spans_async]|Get elements, such as words, lines, and styles, in the result of an analyze operation by searching with spans|
@@ -139,8 +139,8 @@ what you can do with the Azure Form Recognizer client library.
139139
[sample_manage_models_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_manage_models_async.py
140140
[sample_get_operations]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_get_operations.py
141141
[sample_get_operations_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_get_operations_async.py
142-
[sample_copy]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_copy_model.py
143-
[sample_copy_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_copy_model_async.py
142+
[sample_copy]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_copy_model_to.py
143+
[sample_copy_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_copy_model_to_async.py
144144
[sample_get_words_on_document_line]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_get_words_on_document_line.py
145145
[sample_get_words_on_document_line_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_get_words_on_document_line_async.py
146146
[sample_get_elements_with_spans]: https://aka.ms/azsdk/python/formrecognizer/spansamplesync

sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_copy_model_async.py renamed to sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_copy_model_to_async.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# --------------------------------------------------------------------------
88

99
"""
10-
FILE: sample_copy_model_async.py
10+
FILE: sample_copy_model_to_async.py
1111
1212
DESCRIPTION:
1313
This sample demonstrates how to copy a custom model from a source Form Recognizer resource
@@ -17,7 +17,7 @@
1717
training files in https://aka.ms/azsdk/formrecognizer/sampletrainingfiles
1818
1919
USAGE:
20-
python sample_copy_model_async.py
20+
python sample_copy_model_to_async.py
2121
2222
Set the environment variables with your own values before running the sample:
2323
1) AZURE_FORM_RECOGNIZER_SOURCE_ENDPOINT - the endpoint to your source Form Recognizer resource.
@@ -34,8 +34,8 @@
3434
import asyncio
3535

3636

37-
async def sample_copy_model_async(custom_model_id):
38-
# [START begin_copy_model_async]
37+
async def sample_copy_model_to_async(custom_model_id):
38+
# [START begin_copy_model_to_async]
3939
from azure.core.credentials import AzureKeyCredential
4040
from azure.ai.formrecognizer.aio import DocumentModelAdministrationClient
4141

@@ -53,7 +53,7 @@ async def sample_copy_model_async(custom_model_id):
5353

5454
source_client = DocumentModelAdministrationClient(endpoint=source_endpoint, credential=AzureKeyCredential(source_key))
5555
async with source_client:
56-
poller = await source_client.begin_copy_model(
56+
poller = await source_client.begin_copy_model_to(
5757
model_id=source_model_id,
5858
target=target # output from target client's call to get_copy_authorization()
5959
)
@@ -69,7 +69,7 @@ async def sample_copy_model_async(custom_model_id):
6969
print("Field: '{}' has type '{}' and confidence score {}".format(
7070
field_name, field["type"], doc_type.field_confidence[field_name]
7171
))
72-
# [END begin_copy_model_async]
72+
# [END begin_copy_model_to_async]
7373

7474

7575
async def main():
@@ -93,7 +93,7 @@ async def main():
9393
model = await (await document_model_admin_client.begin_build_model(os.getenv("CONTAINER_SAS_URL"), DocumentBuildMode.TEMPLATE)).result()
9494
model_id = model.model_id
9595

96-
await sample_copy_model_async(model_id)
96+
await sample_copy_model_to_async(model_id)
9797

9898
if __name__ == '__main__':
9999
asyncio.run(main())

sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_manage_models_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def sample_manage_models_async():
4242
async with document_model_admin_client:
4343
account_info = await document_model_admin_client.get_account_info()
4444
print("Our account has {} custom models, and we can have at most {} custom models\n".format(
45-
account_info.model_count, account_info.model_limit
45+
account_info.document_model_count, account_info.document_model_limit
4646
))
4747
# [END get_account_info_async]
4848

sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_copy_model.py renamed to sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_copy_model_to.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# --------------------------------------------------------------------------
88

99
"""
10-
FILE: sample_copy_model.py
10+
FILE: sample_copy_model_to.py
1111
1212
DESCRIPTION:
1313
This sample demonstrates how to copy a custom model from a source Form Recognizer resource
@@ -17,7 +17,7 @@
1717
training files in https://aka.ms/azsdk/formrecognizer/sampletrainingfiles
1818
1919
USAGE:
20-
python sample_copy_model.py
20+
python sample_copy_model_to.py
2121
2222
Set the environment variables with your own values before running the sample:
2323
1) AZURE_FORM_RECOGNIZER_SOURCE_ENDPOINT - the endpoint to your source Form Recognizer resource.
@@ -32,8 +32,8 @@
3232

3333
import os
3434

35-
def sample_copy_model(custom_model_id):
36-
# [START begin_copy_model]
35+
def sample_copy_model_to(custom_model_id):
36+
# [START begin_copy_model_to]
3737
from azure.core.credentials import AzureKeyCredential
3838
from azure.ai.formrecognizer import DocumentModelAdministrationClient
3939

@@ -50,7 +50,7 @@ def sample_copy_model(custom_model_id):
5050
)
5151

5252
source_client = DocumentModelAdministrationClient(endpoint=source_endpoint, credential=AzureKeyCredential(source_key))
53-
poller = source_client.begin_copy_model(
53+
poller = source_client.begin_copy_model_to(
5454
model_id=source_model_id,
5555
target=target # output from target client's call to get_copy_authorization()
5656
)
@@ -66,7 +66,7 @@ def sample_copy_model(custom_model_id):
6666
print("Field: '{}' has type '{}' and confidence score {}".format(
6767
field_name, field["type"], doc_type.field_confidence[field_name]
6868
))
69-
# [END begin_copy_model]
69+
# [END begin_copy_model_to]
7070

7171

7272
if __name__ == '__main__':
@@ -88,4 +88,4 @@ def sample_copy_model(custom_model_id):
8888
model = document_model_admin_client.begin_build_model(os.getenv("CONTAINER_SAS_URL"), DocumentBuildMode.TEMPLATE).result()
8989
model_id = model.model_id
9090

91-
sample_copy_model(model_id)
91+
sample_copy_model_to(model_id)

sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_manage_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def sample_manage_models():
3939

4040
account_info = document_model_admin_client.get_account_info()
4141
print("Our account has {} custom models, and we can have at most {} custom models\n".format(
42-
account_info.model_count, account_info.model_limit
42+
account_info.document_model_count, account_info.document_model_limit
4343
))
4444
# [END get_account_info]
4545

0 commit comments

Comments
 (0)