-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[text analytics] Updates to Healthcare design #16247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
iscai-msft
merged 29 commits into
Azure:master
from
abhahn:abhahn/ta-v3.1-preview.4-healthcare-updates
Feb 5, 2021
Merged
Changes from 17 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
c00140c
Renamed healthcare methods
e69151c
Exposing job metadata on the healthcare polling operation
d005b70
Aligning with other similar work for Analyze
ac9faf0
Fixed merge conflicts
078e875
Regenerated with custom pollers; updated tests and a few other files
c2a09ff
Renamed HealthcareEntityLink -> HealthcareEntityDataSource and also r…
fb37651
Fixed missed renames in __init__.py
f827c6b
Updated links and other things in the readme
864b1b2
Updated samples readme
2649001
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
eed2d38
Reverted an unintentional change in analyze_sentiment
429c4ea
Moved cancellation to the poller; fixed some linting issues
ef6c210
Removed an unused model
91ba6a1
PR comments and updated changelog
a78decd
Added related_entities; Fixed merge conflicts
7da7797
Fixed a few issues caused by merge conflicts; made HealthcareEntity h…
0a14704
Fixed a problem with cancellation; updated samples
d952ded
Merge conflicts
82bc4e4
PR comments
03d68a7
PR comments
00c00a5
Fixed bidirectional check; updated/added tests
f2dedef
added a test for async
bae8200
PR comments and fixing test issues
4563059
Fixed a linting issue
f9e5776
PR comments and fixed a test issue
3745666
Fixed cancellation issue
0971671
Another cancellation test fix
7771a70
PR comments
acc58ed
Async syntax issue
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,10 @@ | |
| # Licensed under the MIT License. | ||
| # ------------------------------------ | ||
|
|
||
| from azure.core.exceptions import HttpResponseError | ||
| from azure.core.polling import AsyncLROPoller | ||
| from azure.core.polling.base_polling import OperationFailed, BadStatus | ||
| from azure.core.polling.async_base_polling import AsyncLROBasePolling | ||
| from azure.core.polling import AsyncLROPoller | ||
| from azure.core.polling._async_poller import PollingReturnType | ||
|
|
||
|
|
||
|
|
@@ -76,6 +77,101 @@ async def _poll(self): # pylint:disable=invalid-overridden-method | |
| self._pipeline_response.http_response | ||
| ) | ||
|
|
||
| class AnalyzeHealthcareEntitiesAsyncLROPollingMethod(TextAnalyticsAsyncLROPollingMethod): | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| self._text_analytics_client = kwargs.pop("text_analytics_client") | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| @property | ||
| def _current_body(self): | ||
| from ._generated.v3_1_preview_3.models import JobMetadata | ||
| return JobMetadata.deserialize(self._pipeline_response) | ||
|
|
||
| @property | ||
| def created_on(self): | ||
| if not self._current_body: | ||
| return None | ||
| return self._current_body.created_date_time | ||
|
|
||
| @property | ||
| def expires_on(self): | ||
| if not self._current_body: | ||
| return None | ||
| return self._current_body.expiration_date_time | ||
|
|
||
| @property | ||
| def last_modified_on(self): | ||
| if not self._current_body: | ||
| return None | ||
| return self._current_body.last_update_date_time | ||
|
|
||
| @property | ||
| def id(self): | ||
| if not self._current_body: | ||
| return None | ||
| return self._current_body.job_id | ||
|
|
||
|
|
||
| class AnalyzeHealthcareEntitiesAsyncLROPoller(AsyncLROPoller[PollingReturnType]): | ||
|
|
||
| @property | ||
| def created_on(self): | ||
| return self._polling_method.created_on | ||
|
|
||
| @property | ||
| def expires_on(self): | ||
| return self._polling_method.expires_on | ||
|
|
||
| @property | ||
| def last_modified_on(self): | ||
| return self._polling_method.last_modified_on | ||
|
|
||
| @property | ||
| def id(self): | ||
| return self._polling_method.id | ||
|
|
||
| async def cancel( # type: ignore | ||
| self, | ||
| **kwargs | ||
| ): | ||
| """Cancel the operation currently being polled. | ||
|
|
||
| :keyword int polling_interval: The polling interval to use to poll the cancellation status. | ||
| The default value is 5 seconds. | ||
| :return: Returns an instance of an LROPoller that returns None. | ||
| :rtype: ~azure.core.polling.LROPoller[None] | ||
| :raises: Warning when the operation has already reached a terminal state. | ||
|
|
||
| .. admonition:: Example: | ||
|
|
||
| .. literalinclude:: ../samples/async_samples/sample_analyze_healthcare_entities_with_cancellation_async.py | ||
| :start-after: [START analyze_healthcare_entities_with_cancellation_async] | ||
| :end-before: [END analyze_healthcare_entities_with_cancellation_async] | ||
| :language: python | ||
| :dedent: 8 | ||
| :caption: Cancel an existing health operation. | ||
| """ | ||
| polling_interval = kwargs.pop("polling_interval", 5) | ||
|
|
||
| terminal_states = ["cancelled", "cancelling", "failed", "succeeded", "partiallyCompleted", "rejected"] | ||
| await self._polling_method.update_status() | ||
|
|
||
| if self._polling_method.status() in terminal_states: | ||
| raise Warning("Operation with ID '%s' is already in a terminal state and cannot be cancelled." \ | ||
|
||
| % self.id) | ||
|
|
||
| try: | ||
| return await getattr(self._polling_method, "_text_analytics_client").begin_cancel_health_job( | ||
| self.id, | ||
| polling=TextAnalyticsAsyncLROPollingMethod(timeout=polling_interval) | ||
| ) | ||
|
|
||
| except HttpResponseError as error: | ||
| from ._response_handlers import process_http_response_error | ||
| process_http_response_error(error) | ||
|
|
||
|
|
||
| class AsyncAnalyzeBatchActionsLROPollingMethod(TextAnalyticsAsyncLROPollingMethod): | ||
|
|
||
| @property | ||
|
|
@@ -137,6 +233,7 @@ def id(self): | |
| return None | ||
| return self._current_body.job_id | ||
|
|
||
|
|
||
| class AsyncAnalyzeBatchActionsLROPoller(AsyncLROPoller[PollingReturnType]): | ||
|
|
||
| @property | ||
|
|
@@ -166,10 +263,12 @@ def actions_succeeded_count(self): | |
| @property | ||
| def last_modified_on(self): | ||
| return self._polling_method.last_modified_on | ||
|
|
||
| @property | ||
| def total_actions_count(self): | ||
| return self._polling_method.total_actions_count | ||
|
|
||
| @property | ||
| def id(self): | ||
| return self._polling_method.id | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be
[Healthcare Entities Analysis](#healthcare-entities-analysis "Healthcare Entities Analysis")or the link won't workThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!