Skip to content

Commit

Permalink
[formrecognizer] arch board feedback renames (#12207)
Browse files Browse the repository at this point in the history
* renames requested_on -> training_started_on and completed_on -> training_completed_on

* update docstring
  • Loading branch information
kristapratico authored Jun 26, 2020
1 parent 230afcf commit 32dbdce
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 85 deletions.
2 changes: 2 additions & 0 deletions sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

- Remove `RecognizedReceipts` Class.
- `begin_recognize_receipts` and `begin_recognize_receipts_from_url` now return `RecognizedForm`.
- `requested_on` renamed to `training_started_on` and `completed_on` renamed to `training_completed_on` on `CustomFormModel`
and `CustomFormModelInfo`

## 1.0.0b3 (2020-06-10)

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 @@ -260,8 +260,8 @@ model = poller.result()
# Custom model information
print("Model ID: {}".format(model.model_id))
print("Status: {}".format(model.status))
print("Requested on: {}".format(model.requested_on))
print("Completed on: {}".format(model.completed_on))
print("Training started on: {}".format(model.training_started_on))
print("Training completed on: {}".format(model.training_completed_on))

print("Recognized fields:")
# looping through the submodels, which contains the fields they were trained on
Expand Down Expand Up @@ -309,8 +309,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("Requested on: {}".format(custom_model.requested_on))
print("Completed on: {}".format(custom_model.completed_on))
print("Training started on: {}".format(custom_model.training_started_on))
print("Training completed on: {}".format(custom_model.training_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 @@ -517,9 +517,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 requested_on:
The date and time (UTC) when model training was requested.
:ivar ~datetime.datetime completed_on:
:ivar ~datetime.datetime training_started_on:
The date and time (UTC) when model training was started.
:ivar ~datetime.datetime training_completed_on:
Date and time (UTC) when model training completed.
:ivar list[~azure.ai.formrecognizer.CustomFormSubmodel] submodels:
A list of submodels that are part of this model, each of
Expand All @@ -533,8 +533,8 @@ class CustomFormModel(object):
def __init__(self, **kwargs):
self.model_id = kwargs.get("model_id", None)
self.status = kwargs.get("status", None)
self.requested_on = kwargs.get("requested_on", None)
self.completed_on = kwargs.get("completed_on", None)
self.training_started_on = kwargs.get("training_started_on", None)
self.training_completed_on = kwargs.get("training_completed_on", None)
self.submodels = kwargs.get("submodels", None)
self.errors = kwargs.get("errors", None)
self.training_documents = kwargs.get("training_documents", [])
Expand All @@ -544,8 +544,8 @@ def _from_generated(cls, model):
return cls(
model_id=model.model_info.model_id,
status=model.model_info.status,
requested_on=model.model_info.created_date_time,
completed_on=model.model_info.last_updated_date_time,
training_started_on=model.model_info.created_date_time,
training_completed_on=model.model_info.last_updated_date_time,
submodels=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 @@ -554,11 +554,10 @@ def _from_generated(cls, model):
)

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


class CustomFormSubmodel(object):
Expand Down Expand Up @@ -698,17 +697,17 @@ 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 requested_on:
Date and time (UTC) when model training was requested.
:ivar ~datetime.datetime completed_on:
:ivar ~datetime.datetime training_started_on:
Date and time (UTC) when model training was started.
:ivar ~datetime.datetime training_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.requested_on = kwargs.get("requested_on", None)
self.completed_on = kwargs.get("completed_on", None)
self.training_started_on = kwargs.get("training_started_on", None)
self.training_completed_on = kwargs.get("training_completed_on", None)

@classmethod
def _from_generated(cls, model, model_id=None):
Expand All @@ -717,13 +716,13 @@ def _from_generated(cls, model, model_id=None):
return cls(
model_id=model_id if model_id else model.model_id,
status=model.status,
requested_on=model.created_date_time,
completed_on=model.last_updated_date_time
training_started_on=model.created_date_time,
training_completed_on=model.last_updated_date_time
)

def __repr__(self):
return "CustomFormModelInfo(model_id={}, status={}, requested_on={}, completed_on={})".format(
self.model_id, self.status, self.requested_on, self.completed_on
return "CustomFormModelInfo(model_id={}, status={}, training_started_on={}, training_completed_on={})".format(
self.model_id, self.status, self.training_started_on, self.training_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("Requested on: {}".format(custom_model.requested_on))
print("Completed on: {}".format(custom_model.completed_on))
print("Training started on: {}".format(custom_model.training_started_on))
print("Training completed on: {}".format(custom_model.training_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 @@ -51,8 +51,8 @@ async def train_model_with_labels(self):
# Custom model information
print("Model ID: {}".format(model.model_id))
print("Status: {}".format(model.status))
print("Requested on: {}".format(model.requested_on))
print("Completed on: {}".format(model.completed_on))
print("Training started on: {}".format(model.training_started_on))
print("Training completed on: {}".format(model.training_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("Requested on: {}".format(model.requested_on))
print("Completed on: {}".format(model.completed_on))
print("Training started on: {}".format(model.training_started_on))
print("Training completed on: {}".format(model.training_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("Requested on: {}".format(custom_model.requested_on))
print("Completed on: {}".format(custom_model.completed_on))
print("Training started on: {}".format(custom_model.training_started_on))
print("Training completed on: {}".format(custom_model.training_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("Requested on: {}".format(model.requested_on))
print("Completed on: {}".format(model.completed_on))
print("Training started on: {}".format(model.training_started_on))
print("Training completed on: {}".format(model.training_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 @@ -44,8 +44,8 @@ def train_model_without_labels(self):
# Custom model information
print("Model ID: {}".format(model.model_id))
print("Status: {}".format(model.status))
print("Requested on: {}".format(model.requested_on))
print("Completed on: {}".format(model.completed_on))
print("Training started on: {}".format(model.training_started_on))
print("Training completed on: {}".format(model.training_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 test_copy_model_successful(self, client, container_sas_url, location, resour
copied_model = client.get_custom_model(copy.model_id)

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

actual = raw_response[0]
copy = raw_response[1]
self.assertEqual(copy.requested_on, actual.created_date_time)
self.assertEqual(copy.training_started_on, actual.created_date_time)
self.assertEqual(copy.status, actual.status)
self.assertEqual(copy.completed_on, actual.last_updated_date_time)
self.assertEqual(copy.training_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 @@ -47,8 +47,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, "ready")
self.assertIsNotNone(copy.requested_on)
self.assertIsNotNone(copy.completed_on)
self.assertIsNotNone(copy.training_started_on)
self.assertIsNotNone(copy.training_completed_on)
self.assertEqual(target["modelId"], copy.model_id)
self.assertNotEqual(target["modelId"], model.model_id)
self.assertIsNotNone(copied_model)
Expand Down Expand Up @@ -104,9 +104,9 @@ def callback(response, _, headers):

actual = raw_response[0]
copy = raw_response[1]
self.assertEqual(copy.requested_on, actual.created_date_time)
self.assertEqual(copy.training_started_on, actual.created_date_time)
self.assertEqual(copy.status, actual.status)
self.assertEqual(copy.completed_on, actual.last_updated_date_time)
self.assertEqual(copy.training_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 @@ -87,8 +87,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.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.training_started_on, labeled_model_from_get.training_started_on)
self.assertEqual(labeled_model_from_train.training_completed_on, labeled_model_from_get.training_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 @@ -104,8 +104,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.requested_on)
self.assertIsNotNone(model.completed_on)
self.assertIsNotNone(model.training_started_on)
self.assertIsNotNone(model.training_completed_on)

client.delete_model(labeled_model_from_train.model_id)

Expand All @@ -123,8 +123,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.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.training_started_on, unlabeled_model_from_get.training_started_on)
self.assertEqual(unlabeled_model_from_train.training_completed_on, unlabeled_model_from_get.training_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 @@ -139,8 +139,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.requested_on)
self.assertIsNotNone(model.completed_on)
self.assertIsNotNone(model.training_started_on)
self.assertIsNotNone(model.training_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 @@ -97,8 +97,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.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.training_started_on, labeled_model_from_get.training_started_on)
self.assertEqual(labeled_model_from_train.training_completed_on, labeled_model_from_get.training_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 @@ -114,8 +114,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.requested_on)
self.assertIsNotNone(model.completed_on)
self.assertIsNotNone(model.training_started_on)
self.assertIsNotNone(model.training_completed_on)

await client.delete_model(labeled_model_from_train.model_id)

Expand All @@ -131,8 +131,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.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.training_started_on, unlabeled_model_from_get.training_started_on)
self.assertEqual(unlabeled_model_from_train.training_completed_on, unlabeled_model_from_get.training_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 @@ -147,8 +147,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.requested_on)
self.assertIsNotNone(model.completed_on)
self.assertIsNotNone(model.training_started_on)
self.assertIsNotNone(model.training_completed_on)

await client.delete_model(unlabeled_model_from_train.model_id)

Expand Down
Loading

0 comments on commit 32dbdce

Please sign in to comment.