From 8b885da8e24fe699acf9f1670f43c4cb29c0417d Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Thu, 30 Sep 2021 10:30:28 -0700 Subject: [PATCH] [formrecognizer] sample fixes (#20964) * remove passing api_version in v3.1.x samples and uncomment list models * skip mgmt samples failing due to list models --- scripts/devops_tasks/test_run_samples.py | 4 ++++ .../v3.1/async_samples/sample_authentication_async.py | 8 ++++---- .../samples/v3.1/async_samples/sample_copy_model_async.py | 6 +++--- .../async_samples/sample_create_composed_model_async.py | 2 +- .../sample_differentiate_output_labeled_tables_async.py | 6 +++--- ...output_models_trained_with_and_without_labels_async.py | 4 ++-- .../v3.1/async_samples/sample_get_bounding_boxes_async.py | 4 ++-- .../async_samples/sample_manage_custom_models_async.py | 8 ++++---- .../sample_recognize_business_cards_async.py | 2 +- .../v3.1/async_samples/sample_recognize_content_async.py | 2 +- .../async_samples/sample_recognize_custom_forms_async.py | 4 ++-- .../sample_recognize_identity_documents_async.py | 2 +- .../v3.1/async_samples/sample_recognize_invoices_async.py | 2 +- .../v3.1/async_samples/sample_recognize_receipts_async.py | 2 +- .../sample_recognize_receipts_from_url_async.py | 2 +- .../sample_strongly_typing_recognized_form_async.py | 2 +- .../async_samples/sample_train_model_with_labels_async.py | 2 +- .../sample_train_model_without_labels_async.py | 2 +- .../samples/v3.1/sample_authentication.py | 8 ++++---- .../samples/v3.1/sample_copy_model.py | 6 +++--- .../samples/v3.1/sample_create_composed_model.py | 2 +- .../v3.1/sample_differentiate_output_labeled_tables.py | 6 +++--- ...tiate_output_models_trained_with_and_without_labels.py | 4 ++-- .../samples/v3.1/sample_get_bounding_boxes.py | 4 ++-- .../samples/v3.1/sample_manage_custom_models.py | 8 ++++---- .../samples/v3.1/sample_recognize_business_cards.py | 2 +- .../samples/v3.1/sample_recognize_content.py | 2 +- .../samples/v3.1/sample_recognize_custom_forms.py | 4 ++-- .../samples/v3.1/sample_recognize_identity_documents.py | 2 +- .../samples/v3.1/sample_recognize_invoices.py | 2 +- .../samples/v3.1/sample_recognize_receipts.py | 2 +- .../samples/v3.1/sample_recognize_receipts_from_url.py | 2 +- .../v3.1/sample_strongly_typing_recognized_form.py | 2 +- .../samples/v3.1/sample_train_model_with_labels.py | 2 +- .../samples/v3.1/sample_train_model_without_labels.py | 2 +- 35 files changed, 64 insertions(+), 60 deletions(-) diff --git a/scripts/devops_tasks/test_run_samples.py b/scripts/devops_tasks/test_run_samples.py index 2dae08c2f310..aeb14e8cdb35 100644 --- a/scripts/devops_tasks/test_run_samples.py +++ b/scripts/devops_tasks/test_run_samples.py @@ -125,6 +125,10 @@ "sample_list_translations_with_filters.py", "sample_translation_with_custom_model.py", "sample_translation_with_custom_model_async.py", + ], + "azure-ai-formrecognizer": [ + "sample_manage_custom_models.py", + "sample_manage_custom_models_async.py", ] } diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_authentication_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_authentication_async.py index e6df75d36622..edb62df41a7d 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_authentication_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_authentication_async.py @@ -45,7 +45,7 @@ async def authentication_with_api_key_credential_form_recognizer_client_async(se endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"] key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] - form_recognizer_client = FormRecognizerClient(endpoint, AzureKeyCredential(key), api_version="2.1") + form_recognizer_client = FormRecognizerClient(endpoint, AzureKeyCredential(key)) # [END create_fr_client_with_key_async] async with form_recognizer_client: poller = await form_recognizer_client.begin_recognize_content_from_url(self.url) @@ -62,7 +62,7 @@ async def authentication_with_azure_active_directory_form_recognizer_client_asyn endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"] credential = DefaultAzureCredential() - form_recognizer_client = FormRecognizerClient(endpoint, credential, api_version="2.1") + form_recognizer_client = FormRecognizerClient(endpoint, credential) # [END create_fr_client_with_aad_async] async with form_recognizer_client: poller = await form_recognizer_client.begin_recognize_content_from_url(self.url) @@ -75,7 +75,7 @@ async def authentication_with_api_key_credential_form_training_client_async(self endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"] key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] - form_training_client = FormTrainingClient(endpoint, AzureKeyCredential(key), api_version="2.1") + form_training_client = FormTrainingClient(endpoint, AzureKeyCredential(key)) # [END create_ft_client_with_key_async] async with form_training_client: properties = await form_training_client.get_account_properties() @@ -91,7 +91,7 @@ async def authentication_with_azure_active_directory_form_training_client_async( endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"] credential = DefaultAzureCredential() - form_training_client = FormTrainingClient(endpoint, credential, api_version="2.1") + form_training_client = FormTrainingClient(endpoint, credential) # [END create_ft_client_with_aad_async] async with form_training_client: properties = await form_training_client.get_account_properties() diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_copy_model_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_copy_model_async.py index 00d91a4d1c29..ec6eb26aee43 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_copy_model_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_copy_model_async.py @@ -52,7 +52,7 @@ async def copy_model_async(self, custom_model_id): target_resource_id = os.environ["AZURE_FORM_RECOGNIZER_TARGET_RESOURCE_ID"] # [START get_copy_authorization_async] - target_client = FormTrainingClient(endpoint=target_endpoint, credential=AzureKeyCredential(target_key), api_version="2.1") + target_client = FormTrainingClient(endpoint=target_endpoint, credential=AzureKeyCredential(target_key)) async with target_client: target = await target_client.get_copy_authorization( @@ -64,7 +64,7 @@ async def copy_model_async(self, custom_model_id): # [END get_copy_authorization_async] # [START copy_model_async] - source_client = FormTrainingClient(endpoint=source_endpoint, credential=AzureKeyCredential(source_key), api_version="2.1") + source_client = FormTrainingClient(endpoint=source_endpoint, credential=AzureKeyCredential(source_key)) async with source_client: poller = await source_client.begin_copy_model( @@ -93,7 +93,7 @@ async def main(): raise ValueError("Please provide endpoint and API key to run the samples.") form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) async with form_training_client: model = await (await form_training_client.begin_training( diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_create_composed_model_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_create_composed_model_async.py index 37eb03e0d687..c6282e36d74f 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_create_composed_model_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_create_composed_model_async.py @@ -53,7 +53,7 @@ async def create_composed_model_async(self): po_furniture = os.environ['PURCHASE_ORDER_OFFICE_FURNITURE_SAS_URL_V2'] po_cleaning_supplies = os.environ['PURCHASE_ORDER_OFFICE_CLEANING_SUPPLIES_SAS_URL_V2'] - form_training_client = FormTrainingClient(endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1") + form_training_client = FormTrainingClient(endpoint=endpoint, credential=AzureKeyCredential(key)) async with form_training_client: supplies_poller = await form_training_client.begin_training( po_supplies, use_training_labels=True, model_name="Purchase order - Office supplies" diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_differentiate_output_labeled_tables_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_differentiate_output_labeled_tables_async.py index 051e4c7730f8..18b6d214bb15 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_differentiate_output_labeled_tables_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_differentiate_output_labeled_tables_async.py @@ -53,7 +53,7 @@ async def test_recognize_tables_fixed_rows_async(self, custom_model_id): model_id_fixed_rows_table = os.getenv("MODEL_ID_FIXED_ROW_TABLES", custom_model_id) form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__), @@ -96,7 +96,7 @@ async def test_recognize_tables_dynamic_rows_async(self, custom_model_id): model_id_dynamic_rows_table = os.getenv("MODEL_ID_DYNAMIC_ROW_TABLES", custom_model_id) form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__), @@ -149,7 +149,7 @@ async def main(): raise ValueError("Please provide endpoint and API key to run the samples.") form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) async with form_training_client: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_differentiate_output_models_trained_with_and_without_labels_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_differentiate_output_models_trained_with_and_without_labels_async.py index 228a1d25bf84..4d951bbc6359 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_differentiate_output_models_trained_with_and_without_labels_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_differentiate_output_models_trained_with_and_without_labels_async.py @@ -59,7 +59,7 @@ async def recognize_custom_forms(self, labeled_model_id, unlabeled_model_id): path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "..", "./sample_forms/forms/Form_1.jpg")) async with FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) as form_recognizer_client: with open(path_to_sample_forms, "rb") as f: @@ -143,7 +143,7 @@ async def main(): raise ValueError("Please provide endpoint and API key to run the samples.") form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) async with form_training_client: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_get_bounding_boxes_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_get_bounding_boxes_async.py index c71f4cc9c7af..7ab408f9bb70 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_get_bounding_boxes_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_get_bounding_boxes_async.py @@ -51,7 +51,7 @@ async def get_bounding_boxes(self, custom_model_id): model_id = os.getenv("CUSTOM_TRAINED_MODEL_ID", custom_model_id) form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__), @@ -135,7 +135,7 @@ async def main(): raise ValueError("Please provide endpoint and API key to run the samples.") form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) async with form_training_client: model = await (await form_training_client.begin_training( diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_manage_custom_models_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_manage_custom_models_async.py index 3b3690980185..cb93556c966c 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_manage_custom_models_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_manage_custom_models_async.py @@ -39,7 +39,7 @@ async def manage_custom_models(self): # [START get_account_properties_async] async with FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) as form_training_client: # First, we see how many custom models we have, and what our limit is account_properties = await form_training_client.get_account_properties() @@ -52,9 +52,9 @@ async def manage_custom_models(self): # [START list_custom_models_async] custom_models = form_training_client.list_custom_models() - # print("We have models with the following IDs:") TODO list models is returning null for some models - # async for model in custom_models: - # print(model.model_id) + print("We have models with the following IDs:") + async for model in custom_models: + print(model.model_id) # [END list_custom_models_async] # let's train a model to use for this sample diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_business_cards_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_business_cards_async.py index 2342eb8ad5b5..dd55efaf271a 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_business_cards_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_business_cards_async.py @@ -41,7 +41,7 @@ async def recognize_business_card_async(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) async with form_recognizer_client: with open(path_to_sample_forms, "rb") as f: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_content_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_content_async.py index 7d994ce256b6..c9d849cb592d 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_content_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_content_async.py @@ -48,7 +48,7 @@ async def recognize_content(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] async with FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) as form_recognizer_client: with open(path_to_sample_forms, "rb") as f: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_custom_forms_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_custom_forms_async.py index 4bdec624340c..56054a5f9428 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_custom_forms_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_custom_forms_async.py @@ -48,7 +48,7 @@ async def recognize_custom_forms(self, custom_model_id): model_id = os.getenv("CUSTOM_TRAINED_MODEL_ID", custom_model_id) async with FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) as form_recognizer_client: # Make sure your form's type is included in the list of form types the custom model can recognize @@ -121,7 +121,7 @@ async def main(): raise ValueError("Please provide endpoint and API key to run the samples.") form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) async with form_training_client: model = await (await form_training_client.begin_training( diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_identity_documents_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_identity_documents_async.py index 0ddcbdde3081..45c645dcf70b 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_identity_documents_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_identity_documents_async.py @@ -41,7 +41,7 @@ async def recognize_identity_documents(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] async with FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) as form_recognizer_client: with open(path_to_sample_forms, "rb") as f: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_invoices_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_invoices_async.py index 36eebfb2286d..948a3ccbb6ca 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_invoices_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_invoices_async.py @@ -41,7 +41,7 @@ async def recognize_invoice(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] async with FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) as form_recognizer_client: with open(path_to_sample_forms, "rb") as f: poller = await form_recognizer_client.begin_recognize_invoices(invoice=f, locale="en-US") diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_receipts_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_receipts_async.py index 00695047350a..87122dffb7fd 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_receipts_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_receipts_async.py @@ -42,7 +42,7 @@ async def recognize_receipts(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] async with FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) as form_recognizer_client: with open(path_to_sample_forms, "rb") as f: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_receipts_from_url_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_receipts_from_url_async.py index 985c7084fd58..50bb1afac659 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_receipts_from_url_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_recognize_receipts_from_url_async.py @@ -40,7 +40,7 @@ async def recognize_receipts_from_url(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] async with FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) as form_recognizer_client: url = "https://raw.githubusercontent.com/Azure/azure-sdk-for-python/main/sdk/formrecognizer/azure-ai-formrecognizer/tests/sample_forms/receipt/contoso-receipt.png" poller = await form_recognizer_client.begin_recognize_receipts_from_url(receipt_url=url) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_strongly_typing_recognized_form_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_strongly_typing_recognized_form_async.py index df2cd8ec4ac8..a99faab58315 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_strongly_typing_recognized_form_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_strongly_typing_recognized_form_async.py @@ -83,7 +83,7 @@ async def strongly_typed_receipt_async(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] async with FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) as form_recognizer_client: with open(path_to_sample_forms, "rb") as f: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_train_model_with_labels_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_train_model_with_labels_async.py index d521fa68e8f8..535e8b3b6370 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_train_model_with_labels_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_train_model_with_labels_async.py @@ -45,7 +45,7 @@ async def train_model_with_labels(self): container_sas_url = os.environ["CONTAINER_SAS_URL_V2"] form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) async with form_training_client: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_train_model_without_labels_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_train_model_without_labels_async.py index 98881b1a7823..3941012df1ca 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_train_model_without_labels_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/async_samples/sample_train_model_without_labels_async.py @@ -43,7 +43,7 @@ async def train_model_without_labels(self): container_sas_url = os.environ["CONTAINER_SAS_URL_V2"] async with FormTrainingClient( - endpoint, AzureKeyCredential(key), api_version="2.1" + endpoint, AzureKeyCredential(key) ) as form_training_client: poller = await form_training_client.begin_training(container_sas_url, use_training_labels=False) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_authentication.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_authentication.py index 51eb8ea52a97..9b1279b5ebd4 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_authentication.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_authentication.py @@ -44,7 +44,7 @@ def authentication_with_api_key_credential_form_recognizer_client(self): endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"] key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] - form_recognizer_client = FormRecognizerClient(endpoint, AzureKeyCredential(key), api_version="2.1") + form_recognizer_client = FormRecognizerClient(endpoint, AzureKeyCredential(key)) # [END create_fr_client_with_key] poller = form_recognizer_client.begin_recognize_content_from_url(self.url) result = poller.result() @@ -60,7 +60,7 @@ def authentication_with_azure_active_directory_form_recognizer_client(self): endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"] credential = DefaultAzureCredential() - form_recognizer_client = FormRecognizerClient(endpoint, credential, api_version="2.1") + form_recognizer_client = FormRecognizerClient(endpoint, credential) # [END create_fr_client_with_aad] poller = form_recognizer_client.begin_recognize_content_from_url(self.url) result = poller.result() @@ -72,7 +72,7 @@ def authentication_with_api_key_credential_form_training_client(self): endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"] key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] - form_training_client = FormTrainingClient(endpoint, AzureKeyCredential(key), api_version="2.1") + form_training_client = FormTrainingClient(endpoint, AzureKeyCredential(key)) # [END create_ft_client_with_key] properties = form_training_client.get_account_properties() @@ -87,7 +87,7 @@ def authentication_with_azure_active_directory_form_training_client(self): endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"] credential = DefaultAzureCredential() - form_training_client = FormTrainingClient(endpoint, credential, api_version="2.1") + form_training_client = FormTrainingClient(endpoint, credential) # [END create_ft_client_with_aad] properties = form_training_client.get_account_properties() diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_copy_model.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_copy_model.py index 42510ef6af04..fe2cefd29af8 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_copy_model.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_copy_model.py @@ -51,7 +51,7 @@ def copy_model(self, custom_model_id): target_resource_id = os.environ["AZURE_FORM_RECOGNIZER_TARGET_RESOURCE_ID"] # [START get_copy_authorization] - target_client = FormTrainingClient(endpoint=target_endpoint, credential=AzureKeyCredential(target_key), api_version="2.1") + target_client = FormTrainingClient(endpoint=target_endpoint, credential=AzureKeyCredential(target_key)) target = target_client.get_copy_authorization( resource_region=target_region, @@ -62,7 +62,7 @@ def copy_model(self, custom_model_id): # [END get_copy_authorization] # [START begin_copy_model] - source_client = FormTrainingClient(endpoint=source_endpoint, credential=AzureKeyCredential(source_key), api_version="2.1") + source_client = FormTrainingClient(endpoint=source_endpoint, credential=AzureKeyCredential(source_key)) poller = source_client.begin_copy_model( model_id=source_model_id, @@ -90,7 +90,7 @@ def copy_model(self, custom_model_id): raise ValueError("Please provide endpoint and API key to run the samples.") form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) model = form_training_client.begin_training(os.getenv("CONTAINER_SAS_URL_V2"), use_training_labels=True).result() model_id = model.model_id diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_create_composed_model.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_create_composed_model.py index 552841d967f8..fc54f9fa3cb4 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_create_composed_model.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_create_composed_model.py @@ -52,7 +52,7 @@ def create_composed_model(self): po_furniture = os.environ['PURCHASE_ORDER_OFFICE_FURNITURE_SAS_URL_V2'] po_cleaning_supplies = os.environ['PURCHASE_ORDER_OFFICE_CLEANING_SUPPLIES_SAS_URL_V2'] - form_training_client = FormTrainingClient(endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1") + form_training_client = FormTrainingClient(endpoint=endpoint, credential=AzureKeyCredential(key)) supplies_poller = form_training_client.begin_training( po_supplies, use_training_labels=True, model_name="Purchase order - Office supplies" ) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_differentiate_output_labeled_tables.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_differentiate_output_labeled_tables.py index b0dd8f96f043..dff016c22a24 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_differentiate_output_labeled_tables.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_differentiate_output_labeled_tables.py @@ -52,7 +52,7 @@ def test_recognize_tables_fixed_rows(self, custom_model_id): model_id_fixed_rows_table = os.getenv("MODEL_ID_FIXED_ROW_TABLES", custom_model_id) form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__), @@ -94,7 +94,7 @@ def test_recognize_tables_dynamic_rows(self, custom_model_id): model_id_dynamic_rows_table = os.getenv("MODEL_ID_DYNAMIC_ROW_TABLES", custom_model_id) form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__), @@ -146,7 +146,7 @@ def test_recognize_tables_dynamic_rows(self, custom_model_id): raise ValueError("Please provide endpoint and API key to run the samples.") form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) if fixed: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_differentiate_output_models_trained_with_and_without_labels.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_differentiate_output_models_trained_with_and_without_labels.py index 7ff61356bd5e..0fa15996107f 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_differentiate_output_models_trained_with_and_without_labels.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_differentiate_output_models_trained_with_and_without_labels.py @@ -56,7 +56,7 @@ def recognize_custom_forms(self, labeled_model_id, unlabeled_model_id): model_trained_without_labels_id = os.getenv("ID_OF_MODEL_TRAINED_WITHOUT_LABELS", unlabeled_model_id) form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "./sample_forms/forms/Form_1.jpg")) @@ -143,7 +143,7 @@ def recognize_custom_forms(self, labeled_model_id, unlabeled_model_id): raise ValueError("Please provide endpoint and API key to run the samples.") form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) if labeled: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_get_bounding_boxes.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_get_bounding_boxes.py index 9aaa2ae10272..48651b9f2da8 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_get_bounding_boxes.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_get_bounding_boxes.py @@ -50,7 +50,7 @@ def get_bounding_boxes(self, custom_model_id): model_id = os.getenv("CUSTOM_TRAINED_MODEL_ID", custom_model_id) form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__), @@ -131,7 +131,7 @@ def get_bounding_boxes(self, custom_model_id): raise ValueError("Please provide endpoint and API key to run the samples.") form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) model = form_training_client.begin_training(os.getenv("CONTAINER_SAS_URL_V2"), use_training_labels=False).result() model_id = model.model_id diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_manage_custom_models.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_manage_custom_models.py index cdff4576b85d..7fad685f6071 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_manage_custom_models.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_manage_custom_models.py @@ -37,7 +37,7 @@ def manage_custom_models(self): container_sas_url = os.environ["CONTAINER_SAS_URL_V2"] # [START get_account_properties] - form_training_client = FormTrainingClient(endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1") + form_training_client = FormTrainingClient(endpoint=endpoint, credential=AzureKeyCredential(key)) # First, we see how many custom models we have, and what our limit is account_properties = form_training_client.get_account_properties() print("Our account has {} custom models, and we can have at most {} custom models\n".format( @@ -49,9 +49,9 @@ def manage_custom_models(self): # [START list_custom_models] custom_models = form_training_client.list_custom_models() - # print("We have models with the following IDs:") TODO list models is returning null for some models - # for model in custom_models: - # print(model.model_id) + print("We have models with the following IDs:") + for model in custom_models: + print(model.model_id) # [END list_custom_models] # let's train a model to use for this sample diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_business_cards.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_business_cards.py index 416772a53435..53b800c5eea1 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_business_cards.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_business_cards.py @@ -39,7 +39,7 @@ def recognize_business_card(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) with open(path_to_sample_forms, "rb") as f: poller = form_recognizer_client.begin_recognize_business_cards(business_card=f, locale="en-US") diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_content.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_content.py index 26ad101c2d5a..b76b17f48de0 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_content.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_content.py @@ -46,7 +46,7 @@ def recognize_content(self): endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"] key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] - form_recognizer_client = FormRecognizerClient(endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1") + form_recognizer_client = FormRecognizerClient(endpoint=endpoint, credential=AzureKeyCredential(key)) with open(path_to_sample_forms, "rb") as f: poller = form_recognizer_client.begin_recognize_content(form=f) form_pages = poller.result() diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_custom_forms.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_custom_forms.py index 68a7663b3952..35b2e20cd6af 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_custom_forms.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_custom_forms.py @@ -47,7 +47,7 @@ def recognize_custom_forms(self, custom_model_id): model_id = os.getenv("CUSTOM_TRAINED_MODEL_ID", custom_model_id) form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) # Make sure your form's type is included in the list of form types the custom model can recognize @@ -120,7 +120,7 @@ def recognize_custom_forms(self, custom_model_id): raise ValueError("Please provide endpoint and API key to run the samples.") form_training_client = FormTrainingClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) model = form_training_client.begin_training(os.getenv("CONTAINER_SAS_URL_V2"), use_training_labels=True).result() model_id = model.model_id diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_identity_documents.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_identity_documents.py index 218bb16a5d5c..63e4572e6793 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_identity_documents.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_identity_documents.py @@ -40,7 +40,7 @@ def recognize_identity_documents(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) with open(path_to_sample_forms, "rb") as f: poller = form_recognizer_client.begin_recognize_identity_documents(identity_document=f) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_invoices.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_invoices.py index fbe64b0a95a2..48a529dc21a6 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_invoices.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_invoices.py @@ -40,7 +40,7 @@ def recognize_invoice(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) with open(path_to_sample_forms, "rb") as f: poller = form_recognizer_client.begin_recognize_invoices(invoice=f, locale="en-US") diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_receipts.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_receipts.py index 968b47b79c25..e20945584d26 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_receipts.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_receipts.py @@ -41,7 +41,7 @@ def recognize_receipts(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) with open(path_to_sample_forms, "rb") as f: poller = form_recognizer_client.begin_recognize_receipts(receipt=f, locale="en-US") diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_receipts_from_url.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_receipts_from_url.py index ece40f5ba83c..b3b4a3cc97f5 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_receipts_from_url.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_recognize_receipts_from_url.py @@ -39,7 +39,7 @@ def recognize_receipts_from_url(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) url = "https://raw.githubusercontent.com/Azure/azure-sdk-for-python/main/sdk/formrecognizer/azure-ai-formrecognizer/tests/sample_forms/receipt/contoso-receipt.png" poller = form_recognizer_client.begin_recognize_receipts_from_url(receipt_url=url) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_strongly_typing_recognized_form.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_strongly_typing_recognized_form.py index e74a53105aca..3545d9a4dd02 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_strongly_typing_recognized_form.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_strongly_typing_recognized_form.py @@ -82,7 +82,7 @@ def strongly_typed_receipt(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] form_recognizer_client = FormRecognizerClient( - endpoint=endpoint, credential=AzureKeyCredential(key), api_version="2.1" + endpoint=endpoint, credential=AzureKeyCredential(key) ) with open(path_to_sample_forms, "rb") as f: poller = form_recognizer_client.begin_recognize_receipts(receipt=f) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_train_model_with_labels.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_train_model_with_labels.py index 7e553439ffb6..723487f777b9 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_train_model_with_labels.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_train_model_with_labels.py @@ -43,7 +43,7 @@ def train_model_with_labels(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] container_sas_url = os.environ["CONTAINER_SAS_URL_V2"] - form_training_client = FormTrainingClient(endpoint, AzureKeyCredential(key), api_version="2.1") + form_training_client = FormTrainingClient(endpoint, AzureKeyCredential(key)) poller = form_training_client.begin_training( container_sas_url, use_training_labels=True, model_name="mymodel" ) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_train_model_without_labels.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_train_model_without_labels.py index d90a6107dd59..422e1d5a790b 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_train_model_without_labels.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.1/sample_train_model_without_labels.py @@ -41,7 +41,7 @@ def train_model_without_labels(self): key = os.environ["AZURE_FORM_RECOGNIZER_KEY"] container_sas_url = os.environ["CONTAINER_SAS_URL_V2"] - form_training_client = FormTrainingClient(endpoint, AzureKeyCredential(key), api_version="2.1") + form_training_client = FormTrainingClient(endpoint, AzureKeyCredential(key)) poller = form_training_client.begin_training(container_sas_url, use_training_labels=False) model = poller.result()