Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
- `USReceiptType` is renamed to `ReceiptType`
- `use_training_labels` is now a required positional param in the `begin_training` APIs.
- `stream` and `url` parameters found on methods for `FormRecognizerClient` have been renamed to `form` and `form_url`, respectively.
For recognize receipt methods, parameters have been renamed to `receipt` and `receipt_url`.
- For recognize receipt methods, parameters have been renamed to `receipt` and `receipt_url`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also update the readme, i.e. here (i think there are two code snippets that need updating): https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/formrecognizer/azure-ai-formrecognizer/README.md#train-a-model

- `created_on` and `last_modified` are renamed to `requested_on` and `completed_on` in the
`CustomFormModel` and `CustomFormModelInfo` models.

**New features**

Expand Down
8 changes: 4 additions & 4 deletions sdk/formrecognizer/azure-ai-formrecognizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ model = poller.result()
# Custom model information
print("Model ID: {}".format(model.model_id))
print("Status: {}".format(model.status))
print("Created on: {}".format(model.created_on))
print("Last modified: {}".format(model.last_modified))
print("Requested on: {}".format(model.requested_on))
print("Completed on: {}".format(model.completed_on))

print("Recognized fields:")
# looping through the submodels, which contains the fields they were trained on
Expand Down Expand Up @@ -314,8 +314,8 @@ model_id = "<model id from the Train a Model sample>"
custom_model = form_training_client.get_custom_model(model_id=model_id)
print("Model ID: {}".format(custom_model.model_id))
print("Status: {}".format(custom_model.status))
print("Created on: {}".format(custom_model.created_on))
print("Last modified: {}".format(custom_model.last_modified))
print("Requested on: {}".format(custom_model.requested_on))
print("Completed on: {}".format(custom_model.completed_on))

# Finally, we will delete this model by ID
form_training_client.delete_model(model_id=custom_model.model_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,9 @@ class CustomFormModel(object):
Status indicating the model's readiness for use,
:class:`~azure.ai.formrecognizer.CustomFormModelStatus`.
Possible values include: 'creating', 'ready', 'invalid'.
:ivar ~datetime.datetime created_on:
The date and time (UTC) when model training was started.
:ivar ~datetime.datetime last_modified:
:ivar ~datetime.datetime requested_on:
The date and time (UTC) when model training was requested.
:ivar ~datetime.datetime completed_on:
Date and time (UTC) when model training completed.
:ivar list[~azure.ai.formrecognizer.CustomFormSubModel] models:
A list of submodels that are part of this model, each of
Expand All @@ -688,8 +688,8 @@ class CustomFormModel(object):
def __init__(self, **kwargs):
self.model_id = kwargs.get("model_id", None)
self.status = kwargs.get("status", None)
self.created_on = kwargs.get("created_on", None)
self.last_modified = kwargs.get("last_modified", None)
self.requested_on = kwargs.get("requested_on", None)
self.completed_on = kwargs.get("completed_on", None)
self.models = kwargs.get("models", None)
self.errors = kwargs.get("errors", None)
self.training_documents = kwargs.get("training_documents", [])
Expand All @@ -699,8 +699,8 @@ def _from_generated(cls, model):
return cls(
model_id=model.model_info.model_id,
status=model.model_info.status,
created_on=model.model_info.created_date_time,
last_modified=model.model_info.last_updated_date_time,
requested_on=model.model_info.created_date_time,
completed_on=model.model_info.last_updated_date_time,
models=CustomFormSubModel._from_generated_unlabeled(model)
if model.keys else CustomFormSubModel._from_generated_labeled(model),
errors=FormRecognizerError._from_generated(model.train_result.errors) if model.train_result else None,
Expand All @@ -709,9 +709,9 @@ def _from_generated(cls, model):
)

def __repr__(self):
return "CustomFormModel(model_id={}, status={}, created_on={}, last_modified={}, models={}, " \
return "CustomFormModel(model_id={}, status={}, requested_on={}, completed_on={}, models={}, " \
"errors={}, training_documents={})".format(
self.model_id, self.status, self.created_on, self.last_modified, repr(self.models),
self.model_id, self.status, self.requested_on, self.completed_on, repr(self.models),
repr(self.errors), repr(self.training_documents)
)[:1024]

Expand Down Expand Up @@ -853,30 +853,30 @@ class CustomFormModelInfo(object):
:ivar str status:
The status of the model, :class:`~azure.ai.formrecognizer.CustomFormModelStatus`.
Possible values include: 'creating', 'ready', 'invalid'.
:ivar ~datetime.datetime created_on:
Date and time (UTC) when model training was started.
:ivar ~datetime.datetime last_modified:
:ivar ~datetime.datetime requested_on:
Date and time (UTC) when model training was requested.
:ivar ~datetime.datetime completed_on:
Date and time (UTC) when model training completed.
"""

def __init__(self, **kwargs):
self.model_id = kwargs.get("model_id", None)
self.status = kwargs.get("status", None)
self.created_on = kwargs.get("created_on", None)
self.last_modified = kwargs.get("last_modified", None)
self.requested_on = kwargs.get("requested_on", None)
self.completed_on = kwargs.get("completed_on", None)

@classmethod
def _from_generated(cls, model, model_id=None):
return cls(
model_id=model_id if model_id else model.model_id,
status=model.status,
created_on=model.created_date_time,
last_modified=model.last_updated_date_time
requested_on=model.created_date_time,
completed_on=model.last_updated_date_time
)

def __repr__(self):
return "CustomFormModelInfo(model_id={}, status={}, created_on={}, last_modified={})".format(
self.model_id, self.status, self.created_on, self.last_modified
return "CustomFormModelInfo(model_id={}, status={}, requested_on={}, completed_on={})".format(
self.model_id, self.status, self.requested_on, self.completed_on
)[:1024]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ async def manage_custom_models(self):
custom_model = await form_training_client.get_custom_model(model_id=first_model.model_id)
print("Model ID: {}".format(custom_model.model_id))
print("Status: {}".format(custom_model.status))
print("Created on: {}".format(custom_model.created_on))
print("Last modified: {}".format(custom_model.last_modified))
print("Requested on: {}".format(custom_model.requested_on))
print("Completed on: {}".format(custom_model.completed_on))
# [END get_custom_model_async]

# Finally, we will delete this model by ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ async def train_model_with_labels(self):
# Custom model information
print("Model ID: {}".format(model.model_id))
print("Status: {}".format(model.status))
print("Created on: {}".format(model.created_on))
print("Last modified: {}".format(model.last_modified))
print("Requested on: {}".format(model.requested_on))
print("Completed on: {}".format(model.completed_on))

print("Recognized fields:")
# looping through the submodels, which contains the fields they were trained on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ async def train_model_without_labels(self):
# Custom model information
print("Model ID: {}".format(model.model_id))
print("Status: {}".format(model.status))
print("Created on: {}".format(model.created_on))
print("Last modified: {}".format(model.last_modified))
print("Requested on: {}".format(model.requested_on))
print("Completed on: {}".format(model.completed_on))

print("Recognized fields:")
# Looping through the submodels, which contains the fields they were trained on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def manage_custom_models(self):
custom_model = form_training_client.get_custom_model(model_id=first_model.model_id)
print("Model ID: {}".format(custom_model.model_id))
print("Status: {}".format(custom_model.status))
print("Created on: {}".format(custom_model.created_on))
print("Last modified: {}".format(custom_model.last_modified))
print("Requested on: {}".format(custom_model.requested_on))
print("Completed on: {}".format(custom_model.completed_on))
# [END get_custom_model]

# Finally, we will delete this model by ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def train_model_with_labels(self):
# Custom model information
print("Model ID: {}".format(model.model_id))
print("Status: {}".format(model.status))
print("Created on: {}".format(model.created_on))
print("Last modified: {}".format(model.last_modified))
print("Requested on: {}".format(model.requested_on))
print("Completed on: {}".format(model.completed_on))

print("Recognized fields:")
# looping through the submodels, which contains the fields they were trained on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def train_model_without_labels(self):
# Custom model information
print("Model ID: {}".format(model.model_id))
print("Status: {}".format(model.status))
print("Created on: {}".format(model.created_on))
print("Last modified: {}".format(model.last_modified))
print("Requested on: {}".format(model.requested_on))
print("Completed on: {}".format(model.completed_on))

print("Recognized fields:")
# Looping through the submodels, which contains the fields they were trained on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def test_copy_model_successful(self, client, container_sas_url, location, resour
copied_model = client.get_custom_model(copy.model_id)

self.assertEqual(copy.status, "succeeded")
self.assertIsNotNone(copy.created_on)
self.assertIsNotNone(copy.last_modified)
self.assertIsNotNone(copy.requested_on)
self.assertIsNotNone(copy.completed_on)
self.assertEqual(target["modelId"], copy.model_id)
self.assertNotEqual(target["modelId"], model.model_id)
self.assertIsNotNone(copied_model)
Expand Down Expand Up @@ -74,9 +74,9 @@ def callback(response, _, headers):

actual = raw_response[0]
copy = raw_response[1]
self.assertEqual(copy.created_on, actual.created_date_time)
self.assertEqual(copy.requested_on, actual.created_date_time)
self.assertEqual(copy.status, actual.status)
self.assertEqual(copy.last_modified, actual.last_updated_date_time)
self.assertEqual(copy.completed_on, actual.last_updated_date_time)
self.assertEqual(copy.model_id, target["modelId"])

@GlobalFormRecognizerAccountPreparer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ async def test_copy_model_successful(self, client, container_sas_url, location,
copied_model = await client.get_custom_model(copy.model_id)

self.assertEqual(copy.status, "succeeded")
self.assertIsNotNone(copy.created_on)
self.assertIsNotNone(copy.last_modified)
self.assertIsNotNone(copy.requested_on)
self.assertIsNotNone(copy.completed_on)
self.assertEqual(target["modelId"], copy.model_id)
self.assertNotEqual(target["modelId"], model.model_id)
self.assertIsNotNone(copied_model)
Expand Down Expand Up @@ -69,9 +69,9 @@ def callback(response, _, headers):

actual = raw_response[0]
copy = raw_response[1]
self.assertEqual(copy.created_on, actual.created_date_time)
self.assertEqual(copy.requested_on, actual.created_date_time)
self.assertEqual(copy.status, actual.status)
self.assertEqual(copy.last_modified, actual.last_updated_date_time)
self.assertEqual(copy.completed_on, actual.last_updated_date_time)
self.assertEqual(copy.model_id, target["modelId"])

@GlobalFormRecognizerAccountPreparer()
Expand Down
16 changes: 8 additions & 8 deletions sdk/formrecognizer/azure-ai-formrecognizer/tests/test_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def test_mgmt_model_labeled(self, client, container_sas_url):

self.assertEqual(labeled_model_from_train.model_id, labeled_model_from_get.model_id)
self.assertEqual(labeled_model_from_train.status, labeled_model_from_get.status)
self.assertEqual(labeled_model_from_train.created_on, labeled_model_from_get.created_on)
self.assertEqual(labeled_model_from_train.last_modified, labeled_model_from_get.last_modified)
self.assertEqual(labeled_model_from_train.requested_on, labeled_model_from_get.requested_on)
self.assertEqual(labeled_model_from_train.completed_on, labeled_model_from_get.completed_on)
self.assertEqual(labeled_model_from_train.errors, labeled_model_from_get.errors)
for a, b in zip(labeled_model_from_train.training_documents, labeled_model_from_get.training_documents):
self.assertEqual(a.document_name, b.document_name)
Expand All @@ -80,8 +80,8 @@ def test_mgmt_model_labeled(self, client, container_sas_url):
for model in models_list:
self.assertIsNotNone(model.model_id)
self.assertIsNotNone(model.status)
self.assertIsNotNone(model.created_on)
self.assertIsNotNone(model.last_modified)
self.assertIsNotNone(model.requested_on)
self.assertIsNotNone(model.completed_on)

client.delete_model(labeled_model_from_train.model_id)

Expand All @@ -99,8 +99,8 @@ def test_mgmt_model_unlabeled(self, client, container_sas_url):

self.assertEqual(unlabeled_model_from_train.model_id, unlabeled_model_from_get.model_id)
self.assertEqual(unlabeled_model_from_train.status, unlabeled_model_from_get.status)
self.assertEqual(unlabeled_model_from_train.created_on, unlabeled_model_from_get.created_on)
self.assertEqual(unlabeled_model_from_train.last_modified, unlabeled_model_from_get.last_modified)
self.assertEqual(unlabeled_model_from_train.requested_on, unlabeled_model_from_get.requested_on)
self.assertEqual(unlabeled_model_from_train.completed_on, unlabeled_model_from_get.completed_on)
self.assertEqual(unlabeled_model_from_train.errors, unlabeled_model_from_get.errors)
for a, b in zip(unlabeled_model_from_train.training_documents, unlabeled_model_from_get.training_documents):
self.assertEqual(a.document_name, b.document_name)
Expand All @@ -115,8 +115,8 @@ def test_mgmt_model_unlabeled(self, client, container_sas_url):
for model in models_list:
self.assertIsNotNone(model.model_id)
self.assertIsNotNone(model.status)
self.assertIsNotNone(model.created_on)
self.assertIsNotNone(model.last_modified)
self.assertIsNotNone(model.requested_on)
self.assertIsNotNone(model.completed_on)

client.delete_model(unlabeled_model_from_train.model_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ async def test_mgmt_model_labeled(self, client, container_sas_url):

self.assertEqual(labeled_model_from_train.model_id, labeled_model_from_get.model_id)
self.assertEqual(labeled_model_from_train.status, labeled_model_from_get.status)
self.assertEqual(labeled_model_from_train.created_on, labeled_model_from_get.created_on)
self.assertEqual(labeled_model_from_train.last_modified, labeled_model_from_get.last_modified)
self.assertEqual(labeled_model_from_train.requested_on, labeled_model_from_get.requested_on)
self.assertEqual(labeled_model_from_train.completed_on, labeled_model_from_get.completed_on)
self.assertEqual(labeled_model_from_train.errors, labeled_model_from_get.errors)
for a, b in zip(labeled_model_from_train.training_documents, labeled_model_from_get.training_documents):
self.assertEqual(a.document_name, b.document_name)
Expand All @@ -80,8 +80,8 @@ async def test_mgmt_model_labeled(self, client, container_sas_url):
async for model in models_list:
self.assertIsNotNone(model.model_id)
self.assertIsNotNone(model.status)
self.assertIsNotNone(model.created_on)
self.assertIsNotNone(model.last_modified)
self.assertIsNotNone(model.requested_on)
self.assertIsNotNone(model.completed_on)

await client.delete_model(labeled_model_from_train.model_id)

Expand All @@ -97,8 +97,8 @@ async def test_mgmt_model_unlabeled(self, client, container_sas_url):

self.assertEqual(unlabeled_model_from_train.model_id, unlabeled_model_from_get.model_id)
self.assertEqual(unlabeled_model_from_train.status, unlabeled_model_from_get.status)
self.assertEqual(unlabeled_model_from_train.created_on, unlabeled_model_from_get.created_on)
self.assertEqual(unlabeled_model_from_train.last_modified, unlabeled_model_from_get.last_modified)
self.assertEqual(unlabeled_model_from_train.requested_on, unlabeled_model_from_get.requested_on)
self.assertEqual(unlabeled_model_from_train.completed_on, unlabeled_model_from_get.completed_on)
self.assertEqual(unlabeled_model_from_train.errors, unlabeled_model_from_get.errors)
for a, b in zip(unlabeled_model_from_train.training_documents, unlabeled_model_from_get.training_documents):
self.assertEqual(a.document_name, b.document_name)
Expand All @@ -113,8 +113,8 @@ async def test_mgmt_model_unlabeled(self, client, container_sas_url):
async for model in models_list:
self.assertIsNotNone(model.model_id)
self.assertIsNotNone(model.status)
self.assertIsNotNone(model.created_on)
self.assertIsNotNone(model.last_modified)
self.assertIsNotNone(model.requested_on)
self.assertIsNotNone(model.completed_on)

await client.delete_model(unlabeled_model_from_train.model_id)

Expand Down
12 changes: 6 additions & 6 deletions sdk/formrecognizer/azure-ai-formrecognizer/tests/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,25 +205,25 @@ def test_custom_form_model(self, custom_form_sub_model, form_recognizer_error, t
model = _models.CustomFormModel(
model_id=1,
status=_models.CustomFormModelStatus.creating,
created_on=datetime.datetime(1, 1, 1),
last_modified=datetime.datetime(1, 1, 1),
requested_on=datetime.datetime(1, 1, 1),
completed_on=datetime.datetime(1, 1, 1),
models=[custom_form_sub_model[0], custom_form_sub_model[0]],
errors=[form_recognizer_error[0]],
training_documents=[training_document_info[0], training_document_info[0]]
)

model_repr = "CustomFormModel(model_id=1, status=creating, created_on=0001-01-01 00:00:00, " \
"last_modified=0001-01-01 00:00:00, models=[{}, {}], errors=[{}], training_documents=[{}, {}])".format(
model_repr = "CustomFormModel(model_id=1, status=creating, requested_on=0001-01-01 00:00:00, " \
"completed_on=0001-01-01 00:00:00, models=[{}, {}], errors=[{}], training_documents=[{}, {}])".format(
custom_form_sub_model[1], custom_form_sub_model[1], form_recognizer_error[1], training_document_info[1], training_document_info[1]
)[:1024]

assert repr(model) == model_repr

def test_custom_form_model_info(self):
model = _models.CustomFormModelInfo(
model_id=1, status=_models.CustomFormModelStatus.ready, created_on=datetime.datetime(1, 1, 1), last_modified=datetime.datetime(1, 1, 1)
model_id=1, status=_models.CustomFormModelStatus.ready, requested_on=datetime.datetime(1, 1, 1), completed_on=datetime.datetime(1, 1, 1)
)
model_repr = "CustomFormModelInfo(model_id=1, status=ready, created_on=0001-01-01 00:00:00, last_modified=0001-01-01 00:00:00)"[:1024]
model_repr = "CustomFormModelInfo(model_id=1, status=ready, requested_on=0001-01-01 00:00:00, completed_on=0001-01-01 00:00:00)"[:1024]
assert repr(model) == model_repr

def test_account_properties(self):
Expand Down
Loading