Skip to content

Commit b12fed6

Browse files
author
Abigail Hahn
committed
Merge branch 'abhahn/textanalytics-5.1b3-readme' of https://github.com/Azure/azure-sdk-for-python into abhahn/textanalytics-5.1b3-readme
2 parents 3ba96f8 + bff458f commit b12fed6

File tree

640 files changed

+76472
-3082
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

640 files changed

+76472
-3082
lines changed

sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
**New Features**
66
- We have added method `begin_analyze`, which supports long-running batch process of Named Entity Recognition, Personally identifiable Information, and Key Phrase Extraction. To use, you must specify `api_version=TextAnalyticsApiVersion.V3_1_PREVIEW_3` when creating your client.
7-
- We have added method `begin_analyze_healthcare`, which supports the service's Health API. Since the Health API is currently only available in a gated preview, you need to have your subscription on the service's allow list, and you must specify `api_version=TextAnalyticsApiVersion.V3_1_PREVIEW_3` when creating your client.
7+
- We have added method `begin_analyze_healthcare`, which supports the service's Health API. Since the Health API is currently only available in a gated preview, you need to have your subscription on the service's allow list, and you must specify `api_version=TextAnalyticsApiVersion.V3_1_PREVIEW_3` when creating your client. Note that since this is a gated preview, AAD is not supported. More information [here](https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-for-health?tabs=ner#request-access-to-the-public-preview).
88

99

1010
## 5.1.0b2 (2020-10-06)

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,17 @@
3232
RecognizePiiEntitiesResult,
3333
PiiEntity,
3434
PiiEntityDomainType,
35+
AnalyzeHealthcareResultItem,
36+
HealthcareEntity,
37+
HealthcareRelation,
38+
HealthcareEntityLink,
39+
EntitiesRecognitionTask,
40+
PiiEntitiesRecognitionTask,
41+
KeyPhraseExtractionTask,
42+
TextAnalysisResult,
43+
RequestStatistics
3544
)
45+
from._paging import AnalyzeHealthcareResult
3646

3747
__all__ = [
3848
'TextAnalyticsApiVersion',
@@ -61,6 +71,16 @@
6171
'RecognizePiiEntitiesResult',
6272
'PiiEntity',
6373
'PiiEntityDomainType',
74+
'AnalyzeHealthcareResultItem',
75+
'AnalyzeHealthcareResult',
76+
'HealthcareEntity',
77+
'HealthcareRelation',
78+
'HealthcareEntityLink',
79+
'EntitiesRecognitionTask',
80+
'PiiEntitiesRecognitionTask',
81+
'KeyPhraseExtractionTask',
82+
'TextAnalysisResult',
83+
'RequestStatistics'
6484
]
6585

6686
__version__ = VERSION
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# coding=utf-8
2+
# ------------------------------------
3+
# Copyright (c) Microsoft Corporation.
4+
# Licensed under the MIT License.
5+
# ------------------------------------
6+
7+
from azure.core.polling.base_polling import OperationFailed, BadStatus
8+
from azure.core.polling.async_base_polling import AsyncLROBasePolling
9+
10+
11+
_FINISHED = frozenset(["succeeded", "cancelled", "failed", "partiallysucceeded"])
12+
_FAILED = frozenset(["failed"])
13+
_SUCCEEDED = frozenset(["succeeded", "partiallysucceeded"])
14+
15+
16+
class TextAnalyticsAsyncLROPollingMethod(AsyncLROBasePolling):
17+
18+
def finished(self):
19+
"""Is this polling finished?
20+
:rtype: bool
21+
"""
22+
return TextAnalyticsAsyncLROPollingMethod._finished(self.status())
23+
24+
@staticmethod
25+
def _finished(status):
26+
if hasattr(status, "value"):
27+
status = status.value
28+
return str(status).lower() in _FINISHED
29+
30+
@staticmethod
31+
def _failed(status):
32+
if hasattr(status, "value"):
33+
status = status.value
34+
return str(status).lower() in _FAILED
35+
36+
@staticmethod
37+
def _raise_if_bad_http_status_and_method(response):
38+
"""Check response status code is valid.
39+
40+
Must be 200, 201, 202, or 204.
41+
42+
:raises: BadStatus if invalid status.
43+
"""
44+
code = response.status_code
45+
if code in {200, 201, 202, 204}:
46+
return
47+
raise BadStatus(
48+
"Invalid return status {!r} for {!r} operation".format(
49+
code, response.request.method
50+
)
51+
)
52+
53+
async def _poll(self): # pylint:disable=invalid-overridden-method
54+
"""Poll status of operation so long as operation is incomplete and
55+
we have an endpoint to query.
56+
57+
:param callable update_cmd: The function to call to retrieve the
58+
latest status of the long running operation.
59+
:raises: OperationFailed if operation status 'Failed' or 'Canceled'.
60+
:raises: BadStatus if response status invalid.
61+
:raises: BadResponse if response invalid.
62+
"""
63+
while not self.finished():
64+
await self._delay()
65+
await self.update_status()
66+
67+
if TextAnalyticsAsyncLROPollingMethod._failed(self.status()):
68+
raise OperationFailed("Operation failed or canceled")
69+
70+
final_get_url = self._operation.get_final_get_url(self._pipeline_response)
71+
if final_get_url:
72+
self._pipeline_response = await self.request_status(final_get_url)
73+
TextAnalyticsAsyncLROPollingMethod._raise_if_bad_http_status_and_method(
74+
self._pipeline_response.http_response
75+
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# coding=utf-8
2+
# ------------------------------------
3+
# Copyright (c) Microsoft Corporation.
4+
# Licensed under the MIT License.
5+
# ------------------------------------
6+
7+
from azure.core.async_paging import AsyncItemPaged
8+
9+
10+
class AnalyzeHealthcareResultAsync(AsyncItemPaged):
11+
def __init__(self, *args, **kwargs):
12+
self.model_version = kwargs.pop('model_version')
13+
self.statistics = kwargs.pop('statistics')
14+
super(AnalyzeHealthcareResultAsync, self).__init__(*args, **kwargs)
15+
16+
17+
class AnalyzeResultAsync(AsyncItemPaged):
18+
def __init__(self, *args, **kwargs):
19+
self.statistics = kwargs.pop('statistics')
20+
super(AnalyzeResultAsync, self).__init__(*args, **kwargs)

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_base_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
class TextAnalyticsApiVersion(str, Enum):
1414
"""Text Analytics API versions supported by this package"""
1515

16+
V3_1_PREVIEW_3 = "v3.1-preview.3"
17+
1618
#: this is the default version
1719
V3_1_PREVIEW = "v3.1-preview.2"
1820
V3_0 = "v3.0"

0 commit comments

Comments
 (0)