diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_patch.py index 6d4b26ba54a2..7eafe1ae0543 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_patch.py @@ -33,6 +33,8 @@ from azure.core.pipeline.policies import AzureKeyCredentialPolicy from ._client import ConversationAnalysisClient as GeneratedConversationAnalysisClient +POLLING_INTERVAL_DEFAULT = 5 + def _authentication_policy(credential): authentication_policy = None @@ -85,6 +87,7 @@ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, TokenCre endpoint=endpoint, credential=credential, # type: ignore authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential)), + polling_interval=kwargs.pop("polling_interval", POLLING_INTERVAL_DEFAULT), **kwargs ) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_patch.py index 6c8d583a45da..06d1b0626a0f 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_patch.py @@ -33,6 +33,7 @@ from azure.core.credentials_async import AsyncTokenCredential from azure.core.pipeline.policies import AzureKeyCredentialPolicy from ._client import ConversationAnalysisClient as GeneratedConversationAnalysisClient +from .._patch import POLLING_INTERVAL_DEFAULT def _authentication_policy(credential): @@ -88,6 +89,7 @@ def __init__( endpoint=endpoint, credential=credential, # type: ignore authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential)), + polling_interval=kwargs.pop("polling_interval", POLLING_INTERVAL_DEFAULT), **kwargs ) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_patch.py index 5a201e73e34f..f32b0890cf8c 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_patch.py @@ -11,6 +11,8 @@ from azure.core.pipeline.policies import AzureKeyCredentialPolicy from ._client import ConversationAuthoringClient as GeneratedConversationAuthoringClient +POLLING_INTERVAL_DEFAULT = 5 + def _authentication_policy(credential): authentication_policy = None @@ -62,6 +64,7 @@ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, TokenCre endpoint=endpoint, credential=credential, # type: ignore authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential)), + polling_interval=kwargs.pop("polling_interval", POLLING_INTERVAL_DEFAULT), **kwargs ) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_patch.py index e12796035e03..4f34faf05c35 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_patch.py @@ -11,6 +11,7 @@ from azure.core.credentials_async import AsyncTokenCredential from azure.core.pipeline.policies import AzureKeyCredentialPolicy from ._client import ConversationAuthoringClient as GeneratedConversationAuthoringClient +from .._patch import POLLING_INTERVAL_DEFAULT def _authentication_policy(credential): @@ -65,6 +66,7 @@ def __init__( endpoint=endpoint, credential=credential, # type: ignore authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential)), + polling_interval=kwargs.pop("polling_interval", POLLING_INTERVAL_DEFAULT), **kwargs ) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_authoring.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_authoring.py index 70f8d0e6617c..8c3fd4b6ae21 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_authoring.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_authoring.py @@ -3,12 +3,21 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ +from azure.core.credentials import AzureKeyCredential from azure.ai.language.conversations.authoring import ConversationAuthoringClient from devtools_testutils import AzureRecordedTestCase class TestConversationAuthoring(AzureRecordedTestCase): + def test_polling_interval(self, conversation_creds): + # test default + client = ConversationAuthoringClient(conversation_creds["endpoint"], AzureKeyCredential(conversation_creds["key"])) + assert client._config.polling_interval == 5 + # test override + client = ConversationAuthoringClient(conversation_creds["endpoint"], AzureKeyCredential(conversation_creds["key"]), polling_interval=1) + assert client._config.polling_interval == 1 + def test_authoring_aad(self, recorded_test, conversation_creds): token = self.get_credential(ConversationAuthoringClient) client = ConversationAuthoringClient(conversation_creds["endpoint"], token, api_version="2022-05-01") diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_authoring_async.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_authoring_async.py index 35ca0873af82..0b1a2be92497 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_authoring_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_authoring_async.py @@ -4,13 +4,21 @@ # Licensed under the MIT License. # ------------------------------------ import pytest - +from azure.core.credentials import AzureKeyCredential from azure.ai.language.conversations.authoring.aio import ConversationAuthoringClient from devtools_testutils import AzureRecordedTestCase class TestConversationAuthoringAsync(AzureRecordedTestCase): + def test_polling_interval(self, conversation_creds): + # test default + client = ConversationAuthoringClient(conversation_creds["endpoint"], AzureKeyCredential(conversation_creds["key"])) + assert client._config.polling_interval == 5 + # test override + client = ConversationAuthoringClient(conversation_creds["endpoint"], AzureKeyCredential(conversation_creds["key"]), polling_interval=1) + assert client._config.polling_interval == 1 + @pytest.mark.asyncio async def test_authoring_aad(self, recorded_test, conversation_creds): token = self.get_credential(ConversationAuthoringClient, is_async=True) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_summarization.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_summarization.py index a953bbc71f5b..c0cee5c7f3de 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_summarization.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_summarization.py @@ -10,6 +10,14 @@ class TestConversationalSummarization(AzureRecordedTestCase): + def test_polling_interval(self, conversation_creds): + # test default + client = ConversationAnalysisClient(conversation_creds["endpoint"], AzureKeyCredential(conversation_creds["key"])) + assert client._config.polling_interval == 5 + # test override + client = ConversationAnalysisClient(conversation_creds["endpoint"], AzureKeyCredential(conversation_creds["key"]), polling_interval=1) + assert client._config.polling_interval == 1 + def test_conversational_summarization(self, recorded_test, conversation_creds): # analyze query client = ConversationAnalysisClient( diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_summarization_async.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_summarization_async.py index 924dac7db09e..ffb7e28bc9dc 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_summarization_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_summarization_async.py @@ -12,6 +12,14 @@ class TestConversationalSummarizationAsync(AzureRecordedTestCase): + def test_polling_interval(self, conversation_creds): + # test default + client = ConversationAnalysisClient(conversation_creds["endpoint"], AzureKeyCredential(conversation_creds["key"])) + assert client._config.polling_interval == 5 + # test override + client = ConversationAnalysisClient(conversation_creds["endpoint"], AzureKeyCredential(conversation_creds["key"]), polling_interval=1) + assert client._config.polling_interval == 1 + @pytest.mark.asyncio async def test_conversational_summarization(self, recorded_test, conversation_creds): # analyze query diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/authoring/_patch.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/authoring/_patch.py index 74cc6dd438d3..0f576d85fa19 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/authoring/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/authoring/_patch.py @@ -11,6 +11,8 @@ from azure.core.pipeline.policies import AzureKeyCredentialPolicy, BearerTokenCredentialPolicy from ._client import QuestionAnsweringAuthoringClient as QuestionAnsweringAuthoringClientGenerated +POLLING_INTERVAL_DEFAULT = 5 + def _authentication_policy(credential, **kwargs): if credential is None: @@ -61,6 +63,7 @@ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, TokenCre endpoint=endpoint, credential=credential, # type: ignore authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential, **kwargs)), + polling_interval=kwargs.pop("polling_interval", POLLING_INTERVAL_DEFAULT), **kwargs ) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/authoring/aio/_patch.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/authoring/aio/_patch.py index ea5e72f7df1a..0bf8a9ca0f8e 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/authoring/aio/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/authoring/aio/_patch.py @@ -11,6 +11,7 @@ from azure.core.credentials_async import AsyncTokenCredential from azure.core.pipeline.policies import AzureKeyCredentialPolicy, AsyncBearerTokenCredentialPolicy from ._client import QuestionAnsweringAuthoringClient as QuestionAnsweringAuthoringClientGenerated +from .._patch import POLLING_INTERVAL_DEFAULT def _authentication_policy(credential, **kwargs): @@ -64,6 +65,7 @@ def __init__( endpoint=endpoint, credential=credential, # type: ignore authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential, **kwargs)), + polling_interval=kwargs.pop("polling_interval", POLLING_INTERVAL_DEFAULT), **kwargs ) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_create_and_deploy_project.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_create_and_deploy_project.py index 271ab8b5a455..7c914394159b 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_create_and_deploy_project.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_create_and_deploy_project.py @@ -14,6 +14,14 @@ class TestCreateAndDeploy(QuestionAnsweringTestCase): + def test_polling_interval(self, qna_creds): + # test default + client = QuestionAnsweringAuthoringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"])) + assert client._config.polling_interval == 5 + # test override + client = QuestionAnsweringAuthoringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"]), polling_interval=1) + assert client._config.polling_interval == 1 + def test_create_project_aad(self, recorded_test, qna_creds): token = self.get_credential(QuestionAnsweringAuthoringClient) client = QuestionAnsweringAuthoringClient(qna_creds["qna_endpoint"], token) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_create_and_deploy_project_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_create_and_deploy_project_async.py index 7c552ad3c94e..76b4dab9ee67 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_create_and_deploy_project_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_create_and_deploy_project_async.py @@ -14,6 +14,14 @@ class TestCreateAndDeployAsync(QuestionAnsweringTestCase): + def test_polling_interval(self, qna_creds): + # test default + client = QuestionAnsweringAuthoringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"])) + assert client._config.polling_interval == 5 + # test override + client = QuestionAnsweringAuthoringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"]), polling_interval=1) + assert client._config.polling_interval == 1 + @pytest.mark.asyncio async def test_create_project_aad(self, recorded_test, qna_creds): token = self.get_credential(QuestionAnsweringAuthoringClient, is_async=True)