Skip to content

Commit

Permalink
[translation] fix poller.details (#20392)
Browse files Browse the repository at this point in the history
* fixing docstring types for async client

* populate poller.details.id immediately

* pylint

* add bug fix to changelog
  • Loading branch information
kristapratico authored Aug 24, 2021
1 parent 47108e9 commit 82e2b54
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions sdk/translation/azure-ai-translation-document/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Breaking Changes

### Bugs Fixed
- The operation `id` under `details` of the poller object now populates correctly.

### Other Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ 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
)
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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ 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
)
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access

@classmethod
def from_continuation_token(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 82e2b54

Please sign in to comment.