Skip to content

Commit

Permalink
[formrecognizer] Fix v2 custom forms tests (Azure#20923)
Browse files Browse the repository at this point in the history
* fix v2 custom forms tests

* update prebuilt document pages tests
  • Loading branch information
catalinaperalta authored Sep 29, 2021
1 parent 77820ae commit b9211fb
Show file tree
Hide file tree
Showing 8 changed files with 506 additions and 240 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def test_analyze_document_empty_model_id(self, formrecognizer_test_endpoint, for

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_unlabeled(self, client, formrecognizer_storage_container_sas_url):
def test_custom_form_unlabeled(self, client, formrecognizer_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(formrecognizer_storage_container_sas_url, use_training_labels=False)
poller = client.begin_training(formrecognizer_storage_container_sas_url_v2, use_training_labels=False)
model = poller.result()

with open(self.form_jpg, "rb") as stream:
Expand All @@ -54,10 +54,10 @@ def test_custom_form_unlabeled(self, client, formrecognizer_storage_container_sa

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_multipage_unlabeled(self, client, formrecognizer_multipage_storage_container_sas_url):
def test_custom_form_multipage_unlabeled(self, client, formrecognizer_multipage_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url, use_training_labels=False)
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_v2, use_training_labels=False)
model = poller.result()

with open(self.multipage_invoice_pdf, "rb") as stream:
Expand All @@ -76,11 +76,11 @@ def test_custom_form_multipage_unlabeled(self, client, formrecognizer_multipage_

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_labeled(self, client, formrecognizer_storage_container_sas_url):
def test_custom_form_labeled(self, client, formrecognizer_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(
formrecognizer_storage_container_sas_url,
formrecognizer_storage_container_sas_url_v2,
use_training_labels=True,
model_name="labeled"
)
Expand All @@ -97,11 +97,11 @@ def test_custom_form_labeled(self, client, formrecognizer_storage_container_sas_

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_multipage_labeled(self, client, formrecognizer_multipage_storage_container_sas_url):
def test_custom_form_multipage_labeled(self, client, formrecognizer_multipage_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(
formrecognizer_multipage_storage_container_sas_url,
formrecognizer_multipage_storage_container_sas_url_v2,
use_training_labels=True
)
model = poller.result()
Expand All @@ -122,10 +122,10 @@ def test_custom_form_multipage_labeled(self, client, formrecognizer_multipage_st

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_unlabeled_transform(self, client, formrecognizer_storage_container_sas_url):
def test_custom_form_unlabeled_transform(self, client, formrecognizer_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(formrecognizer_storage_container_sas_url, use_training_labels=False)
poller = client.begin_training(formrecognizer_storage_container_sas_url_v2, use_training_labels=False)
model = poller.result()

responses = []
Expand Down Expand Up @@ -175,10 +175,10 @@ def callback(raw_response, _, headers):

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_multipage_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url):
def test_custom_form_multipage_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url, use_training_labels=False)
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_v2, use_training_labels=False)
model = poller.result()

responses = []
Expand Down Expand Up @@ -304,10 +304,10 @@ def callback(raw_response, _, headers):
@FormRecognizerPreparer()
@FormTrainingClientPreparer()
@pytest.mark.live_test_only
def test_custom_form_continuation_token(self, client, formrecognizer_storage_container_sas_url):
def test_custom_form_continuation_token(self, client, formrecognizer_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(formrecognizer_storage_container_sas_url, use_training_labels=False)
poller = client.begin_training(formrecognizer_storage_container_sas_url_v2, use_training_labels=False)
model = poller.result()

with open(self.form_jpg, "rb") as fd:
Expand All @@ -328,10 +328,10 @@ def test_custom_form_continuation_token(self, client, formrecognizer_storage_con

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_multipage_vendor_set_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2):
def test_custom_form_multipage_vendor_set_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2_v2):
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_2, use_training_labels=False)
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_2_v2, use_training_labels=False)
model = poller.result()

responses = []
Expand Down Expand Up @@ -367,10 +367,10 @@ def callback(raw_response, _, headers):

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_multipage_vendor_set_labeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2):
def test_custom_form_multipage_vendor_set_labeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2_v2):
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_2, use_training_labels=True)
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_2_v2, use_training_labels=True)
model = poller.result()

responses = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ async def test_analyze_document_empty_model_id(self, formrecognizer_test_endpoin

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
async def test_custom_form_unlabeled(self, client, formrecognizer_storage_container_sas_url):
async def test_custom_form_unlabeled(self, client, formrecognizer_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

with open(self.form_jpg, "rb") as fd:
myfile = fd.read()

async with client:
training_poller = await client.begin_training(formrecognizer_storage_container_sas_url, use_training_labels=False)
training_poller = await client.begin_training(formrecognizer_storage_container_sas_url_v2, use_training_labels=False)
model = await training_poller.result()

async with fr_client:
Expand All @@ -57,13 +57,13 @@ async def test_custom_form_unlabeled(self, client, formrecognizer_storage_contai

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
async def test_custom_form_multipage_unlabeled(self, client, formrecognizer_multipage_storage_container_sas_url):
async def test_custom_form_multipage_unlabeled(self, client, formrecognizer_multipage_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()
with open(self.multipage_invoice_pdf, "rb") as fd:
myfile = fd.read()

async with client:
training_poller = await client.begin_training(formrecognizer_multipage_storage_container_sas_url, use_training_labels=False)
training_poller = await client.begin_training(formrecognizer_multipage_storage_container_sas_url_v2, use_training_labels=False)
model = await training_poller.result()

async with fr_client:
Expand All @@ -82,14 +82,14 @@ async def test_custom_form_multipage_unlabeled(self, client, formrecognizer_mult

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
async def test_custom_form_multipage_labeled(self, client, formrecognizer_multipage_storage_container_sas_url):
async def test_custom_form_multipage_labeled(self, client, formrecognizer_multipage_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()
with open(self.multipage_invoice_pdf, "rb") as fd:
myfile = fd.read()

async with client:
training_poller = await client.begin_training(
formrecognizer_multipage_storage_container_sas_url,
formrecognizer_multipage_storage_container_sas_url_v2,
use_training_labels=True
)
model = await training_poller.result()
Expand All @@ -108,7 +108,7 @@ async def test_custom_form_multipage_labeled(self, client, formrecognizer_multip

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
async def test_custom_forms_multipage_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url):
async def test_custom_forms_multipage_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

responses = []
Expand All @@ -123,7 +123,7 @@ def callback(raw_response, _, headers):
myfile = fd.read()

async with client:
training_poller = await client.begin_training(formrecognizer_multipage_storage_container_sas_url, use_training_labels=False)
training_poller = await client.begin_training(formrecognizer_multipage_storage_container_sas_url_v2, use_training_labels=False)
model = await training_poller.result()

async with fr_client:
Expand Down Expand Up @@ -244,13 +244,13 @@ def callback(raw_response, _, headers):
@FormRecognizerPreparer()
@FormTrainingClientPreparer()
@pytest.mark.live_test_only
async def test_custom_form_continuation_token(self, client, formrecognizer_storage_container_sas_url):
async def test_custom_form_continuation_token(self, client, formrecognizer_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()
with open(self.form_jpg, "rb") as fd:
myfile = fd.read()

async with client:
poller = await client.begin_training(formrecognizer_storage_container_sas_url, use_training_labels=False)
poller = await client.begin_training(formrecognizer_storage_container_sas_url_v2, use_training_labels=False)
model = await poller.result()

async with fr_client:
Expand All @@ -271,7 +271,7 @@ async def test_custom_form_continuation_token(self, client, formrecognizer_stora

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
async def test_custom_form_multipage_vendor_set_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2):
async def test_custom_form_multipage_vendor_set_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2_v2):
fr_client = client.get_form_recognizer_client()

responses = []
Expand All @@ -286,7 +286,7 @@ def callback(raw_response, _, headers):
myfile = fd.read()

async with client:
poller = await client.begin_training(formrecognizer_multipage_storage_container_sas_url_2, use_training_labels=False)
poller = await client.begin_training(formrecognizer_multipage_storage_container_sas_url_2_v2, use_training_labels=False)
model = await poller.result()

async with fr_client:
Expand All @@ -312,7 +312,7 @@ def callback(raw_response, _, headers):

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
async def test_custom_form_multipage_vendor_set_labeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2):
async def test_custom_form_multipage_vendor_set_labeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2_v2):
fr_client = client.get_form_recognizer_client()

responses = []
Expand All @@ -327,7 +327,7 @@ def callback(raw_response, _, headers):
responses.append(form)

async with client:
poller = await client.begin_training(formrecognizer_multipage_storage_container_sas_url_2, use_training_labels=True)
poller = await client.begin_training(formrecognizer_multipage_storage_container_sas_url_2_v2, use_training_labels=True)
model = await poller.result()

async with fr_client:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def test_document_analysis_empty_model_id(self, formrecognizer_test_endpoint, fo

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_form_multipage_unlabeled(self, client, formrecognizer_multipage_storage_container_sas_url):
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url, "multipage-training-data", "multipage_invoice1.pdf")
def test_form_multipage_unlabeled(self, client, formrecognizer_multipage_storage_container_sas_url_v2):
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url_v2, "multipage-training-data", "multipage_invoice1.pdf")
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url, use_training_labels=False)
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_v2, use_training_labels=False)
model = poller.result()

poller = fr_client.begin_recognize_custom_forms_from_url(
Expand All @@ -57,12 +57,12 @@ def test_form_multipage_unlabeled(self, client, formrecognizer_multipage_storage

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_form_multipage_labeled(self, client, formrecognizer_multipage_storage_container_sas_url):
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url, "multipage-training-data", "multipage_invoice1.pdf")
def test_form_multipage_labeled(self, client, formrecognizer_multipage_storage_container_sas_url_v2):
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url_v2, "multipage-training-data", "multipage_invoice1.pdf")
fr_client = client.get_form_recognizer_client()

poller = client.begin_training(
formrecognizer_multipage_storage_container_sas_url,
formrecognizer_multipage_storage_container_sas_url_v2,
use_training_labels=True
)
model = poller.result()
Expand All @@ -79,10 +79,10 @@ def test_form_multipage_labeled(self, client, formrecognizer_multipage_storage_c

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_multipage_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url):
def test_custom_form_multipage_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url, "multipage-training-data", "multipage_invoice1.pdf")
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url, use_training_labels=False)
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url_v2, "multipage-training-data", "multipage_invoice1.pdf")
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_v2, use_training_labels=False)
model = poller.result()

responses = []
Expand Down Expand Up @@ -116,10 +116,10 @@ def callback(raw_response, _, headers):

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_multipage_labeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url):
def test_custom_form_multipage_labeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url, "multipage-training-data", "multipage_invoice1.pdf")
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url, use_training_labels=True)
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url_v2, "multipage-training-data", "multipage_invoice1.pdf")
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_v2, use_training_labels=True)
model = poller.result()

responses = []
Expand Down Expand Up @@ -155,10 +155,10 @@ def callback(raw_response, _, headers):
@FormRecognizerPreparer()
@FormTrainingClientPreparer()
@pytest.mark.live_test_only
def test_custom_form_continuation_token(self, client, formrecognizer_storage_container_sas_url):
def test_custom_form_continuation_token(self, client, formrecognizer_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

training_poller = client.begin_training(formrecognizer_storage_container_sas_url, use_training_labels=False)
training_poller = client.begin_training(formrecognizer_storage_container_sas_url_v2, use_training_labels=False)
model = training_poller.result()

initial_poller = fr_client.begin_recognize_custom_forms_from_url(
Expand All @@ -178,10 +178,10 @@ def test_custom_form_continuation_token(self, client, formrecognizer_storage_con

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_multipage_vendor_set_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2):
def test_custom_form_multipage_vendor_set_unlabeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2_v2):
fr_client = client.get_form_recognizer_client()
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url_2, "multipage-vendor-forms", "multi1.pdf")
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_2, use_training_labels=False)
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url_2_v2, "multipage-vendor-forms", "multi1.pdf")
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_2_v2, use_training_labels=False)
model = poller.result()

responses = []
Expand Down Expand Up @@ -215,10 +215,10 @@ def callback(raw_response, _, headers):

@FormRecognizerPreparer()
@FormTrainingClientPreparer()
def test_custom_form_multipage_vendor_set_labeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2):
def test_custom_form_multipage_vendor_set_labeled_transform(self, client, formrecognizer_multipage_storage_container_sas_url_2_v2):
fr_client = client.get_form_recognizer_client()
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url_2, "multipage-vendor-forms", "multi1.pdf")
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_2, use_training_labels=True)
blob_sas_url = self.get_blob_url(formrecognizer_multipage_storage_container_sas_url_2_v2, "multipage-vendor-forms", "multi1.pdf")
poller = client.begin_training(formrecognizer_multipage_storage_container_sas_url_2_v2, use_training_labels=True)
model = poller.result()

responses = []
Expand Down
Loading

0 comments on commit b9211fb

Please sign in to comment.