From 03317782cbe0aa13f9ce67c006f5ec41ed53f1ac Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Fri, 4 Jun 2021 15:02:37 -0700 Subject: [PATCH] update polling interval (#19119) --- .../azure/ai/translation/document/_client.py | 11 +++++++++-- .../azure/ai/translation/document/_helpers.py | 1 + .../ai/translation/document/aio/_client_async.py | 10 +++++++++- .../azure-ai-translation-document/tests/preparer.py | 3 --- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_client.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_client.py index f9e7d7657284..1026ea8506dc 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_client.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_client.py @@ -16,7 +16,13 @@ ) from ._user_agent import USER_AGENT from ._polling import TranslationPolling, DocumentTranslationLROPollingMethod -from ._helpers import get_http_logging_policy, convert_datetime, get_authentication_policy, get_translation_input +from ._helpers import ( + get_http_logging_policy, + convert_datetime, + get_authentication_policy, + get_translation_input, + POLLING_INTERVAL +) if TYPE_CHECKING: from azure.core.paging import ItemPaged from azure.core.credentials import TokenCredential, AzureKeyCredential @@ -64,7 +70,7 @@ def __init__(self, endpoint, credential, **kwargs): self._api_version = kwargs.pop('api_version', None) authentication_policy = get_authentication_policy(credential) - + polling_interval = kwargs.pop("polling_interval", POLLING_INTERVAL) self._client = _BatchDocumentTranslationClient( endpoint=endpoint, credential=credential, # type: ignore @@ -72,6 +78,7 @@ def __init__(self, endpoint, credential, **kwargs): sdk_moniker=USER_AGENT, authentication_policy=authentication_policy, http_logging_policy=get_http_logging_policy(), + polling_interval=polling_interval, **kwargs ) diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_helpers.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_helpers.py index 4f094c483832..4299cffd492c 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_helpers.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_helpers.py @@ -17,6 +17,7 @@ ) from ._models import DocumentTranslationInput COGNITIVE_KEY_HEADER = "Ocp-Apim-Subscription-Key" +POLLING_INTERVAL = 1 def get_translation_input(args, kwargs, continuation_token): diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_client_async.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_client_async.py index 80722a42d169..169e6b70b051 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_client_async.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_client_async.py @@ -17,7 +17,13 @@ FileFormat, DocumentStatusResult ) -from .._helpers import get_http_logging_policy, convert_datetime, get_authentication_policy, get_translation_input +from .._helpers import ( + get_http_logging_policy, + convert_datetime, + get_authentication_policy, + get_translation_input, + POLLING_INTERVAL +) from ._async_polling import AsyncDocumentTranslationLROPollingMethod, AsyncDocumentTranslationLROPoller from .._polling import TranslationPolling if TYPE_CHECKING: @@ -67,6 +73,7 @@ def __init__( self._api_version = kwargs.pop('api_version', None) authentication_policy = get_authentication_policy(credential) + polling_interval = kwargs.pop("polling_interval", POLLING_INTERVAL) self._client = _BatchDocumentTranslationClient( endpoint=endpoint, credential=credential, # type: ignore @@ -74,6 +81,7 @@ def __init__( sdk_moniker=USER_AGENT, authentication_policy=authentication_policy, http_logging_policy=get_http_logging_policy(), + polling_interval=polling_interval, **kwargs ) diff --git a/sdk/translation/azure-ai-translation-document/tests/preparer.py b/sdk/translation/azure-ai-translation-document/tests/preparer.py index cab98a9d0444..b173b38ca50d 100644 --- a/sdk/translation/azure-ai-translation-document/tests/preparer.py +++ b/sdk/translation/azure-ai-translation-document/tests/preparer.py @@ -39,9 +39,6 @@ def create_resource(self, name, **kwargs): # set polling interval to 0 for recorded tests if not self.is_live: self.client_kwargs["polling_interval"] = 0 - else: - # default is 30s, but our tests translate very small docs so this helps speed up live testing - self.client_kwargs["polling_interval"] = 5 client = self.client_cls( doctranslation_test_endpoint,