From 08c9e9c44fd8caa9fabab28c573a81628aaabf9c Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Mon, 23 Aug 2021 18:03:29 -0700 Subject: [PATCH 1/4] fixing docstring types for async client --- .../azure/ai/translation/document/aio/_client_async.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 591f0885e076..c8463bda0272 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 @@ -271,7 +271,7 @@ def list_all_translation_statuses(self, **kwargs): format: ["param1 asc/desc", "param2 asc/desc", ...] (ex: 'created_on asc', 'created_on desc'). :return: A pageable of TranslationStatus. - :rtype: ~azure.core.paging.ItemPaged[TranslationStatus] + :rtype: ~azure.core.async_paging.AsyncItemPaged[TranslationStatus] :raises ~azure.core.exceptions.HttpResponseError: .. admonition:: Example: @@ -336,7 +336,7 @@ def list_all_document_statuses(self, translation_id, **kwargs): format: ["param1 asc/desc", "param2 asc/desc", ...] (ex: 'created_on asc', 'created_on desc'). :return: A pageable of DocumentStatus. - :rtype: ~azure.core.paging.ItemPaged[DocumentStatus] + :rtype: ~azure.core.async_paging.AsyncItemPaged[DocumentStatus] :raises ~azure.core.exceptions.HttpResponseError: .. admonition:: Example: From 406bd369363f56953e5daebb6a7187034fa9eb2a Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Mon, 23 Aug 2021 18:19:12 -0700 Subject: [PATCH 2/4] populate poller.details.id immediately --- .../azure/ai/translation/document/_polling.py | 9 ++++++--- .../azure/ai/translation/document/aio/_async_polling.py | 9 ++++++--- .../azure-ai-translation-document/tests/asynctestcase.py | 1 + .../azure-ai-translation-document/tests/testcase.py | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_polling.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_polling.py index e614d09e7c3b..c5a27ef310ee 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_polling.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_polling.py @@ -63,9 +63,12 @@ def details(self): :rtype: ~azure.ai.translation.document.TranslationStatus """ - return TranslationStatus._from_generated( # pylint: disable=protected-access - self._polling_method._current_body # pylint: disable=protected-access - ) + if self._polling_method._current_body: # pylint: disable=protected-access + return TranslationStatus._from_generated( # pylint: disable=protected-access + self._polling_method._current_body # pylint: disable=protected-access + ) + else: + return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access @classmethod def from_continuation_token(cls, polling_method, continuation_token, **kwargs): diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_async_polling.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_async_polling.py index 379751ec66bc..da40dbb2ccb6 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_async_polling.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_async_polling.py @@ -43,9 +43,12 @@ def details(self) -> TranslationStatus: :rtype: ~azure.ai.translation.document.TranslationStatus """ - return TranslationStatus._from_generated( # pylint: disable=protected-access - self._polling_method._current_body # pylint: disable=protected-access - ) + if self._polling_method._current_body: # pylint: disable=protected-access + return TranslationStatus._from_generated( # pylint: disable=protected-access + self._polling_method._current_body # pylint: disable=protected-access + ) + else: + return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access @classmethod def from_continuation_token( diff --git a/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py b/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py index b1c7a3b9c681..a7fe4612cac8 100644 --- a/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py +++ b/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py @@ -26,6 +26,7 @@ async def _begin_and_validate_translation_async(self, async_client, translation_ # submit operation poller = await async_client.begin_translation(translation_inputs) self.assertIsNotNone(poller.id) + self.assertIsNotNone(poller.details.id) # wait for result doc_statuses = await poller.result() # validate diff --git a/sdk/translation/azure-ai-translation-document/tests/testcase.py b/sdk/translation/azure-ai-translation-document/tests/testcase.py index 733618adbe57..1c16c23a2db2 100644 --- a/sdk/translation/azure-ai-translation-document/tests/testcase.py +++ b/sdk/translation/azure-ai-translation-document/tests/testcase.py @@ -236,6 +236,7 @@ def _begin_and_validate_translation(self, client, translation_inputs, total_docs # submit job poller = client.begin_translation(translation_inputs) self.assertIsNotNone(poller.id) + self.assertIsNotNone(poller.details.id) # wait for result result = poller.result() # validate From 60fd969580926d7de838655174acda5e20fb9416 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Mon, 23 Aug 2021 19:43:14 -0700 Subject: [PATCH 3/4] pylint --- .../azure/ai/translation/document/_polling.py | 3 +-- .../azure/ai/translation/document/aio/_async_polling.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_polling.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_polling.py index c5a27ef310ee..ad194c453228 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_polling.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_polling.py @@ -67,8 +67,7 @@ def details(self): return TranslationStatus._from_generated( # pylint: disable=protected-access self._polling_method._current_body # pylint: disable=protected-access ) - else: - return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access + return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access @classmethod def from_continuation_token(cls, polling_method, continuation_token, **kwargs): diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_async_polling.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_async_polling.py index da40dbb2ccb6..79efe2f85c82 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_async_polling.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_async_polling.py @@ -47,8 +47,7 @@ def details(self) -> TranslationStatus: return TranslationStatus._from_generated( # pylint: disable=protected-access self._polling_method._current_body # pylint: disable=protected-access ) - else: - return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access + return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access @classmethod def from_continuation_token( From b06fd9cd957b3df32f2beb07c55a8fb4ef9a45e2 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Tue, 24 Aug 2021 09:59:05 -0700 Subject: [PATCH 4/4] add bug fix to changelog --- sdk/translation/azure-ai-translation-document/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/translation/azure-ai-translation-document/CHANGELOG.md b/sdk/translation/azure-ai-translation-document/CHANGELOG.md index cd7f3e49341c..8f9a925025e8 100644 --- a/sdk/translation/azure-ai-translation-document/CHANGELOG.md +++ b/sdk/translation/azure-ai-translation-document/CHANGELOG.md @@ -7,6 +7,7 @@ ### Breaking Changes ### Bugs Fixed +- The operation `id` under `details` of the poller object now populates correctly. ### Other Changes