azure-ai-textanalytics 5.3.0b2__py3-none-any.whl → 6.0.0b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of azure-ai-textanalytics might be problematic. Click here for more details.
- azure/ai/textanalytics/__init__.py +26 -193
- azure/ai/textanalytics/_client.py +111 -0
- azure/ai/textanalytics/_configuration.py +73 -0
- azure/ai/textanalytics/{_generated/v2022_05_01/operations → _operations}/__init__.py +13 -8
- azure/ai/textanalytics/_operations/_operations.py +716 -0
- azure/ai/textanalytics/{_generated/v2022_05_01/models → _operations}/_patch.py +8 -6
- azure/ai/textanalytics/_patch.py +350 -0
- azure/ai/textanalytics/{_generated/aio → _utils}/__init__.py +1 -5
- azure/ai/textanalytics/_utils/model_base.py +1237 -0
- azure/ai/textanalytics/{_generated/_serialization.py → _utils/serialization.py} +640 -616
- azure/ai/textanalytics/{_generated/v2022_05_01/aio/_vendor.py → _utils/utils.py} +10 -12
- azure/ai/textanalytics/_version.py +8 -7
- azure/ai/textanalytics/aio/__init__.py +25 -14
- azure/ai/textanalytics/aio/_client.py +115 -0
- azure/ai/textanalytics/aio/_configuration.py +75 -0
- azure/ai/textanalytics/{_generated/v2022_10_01_preview/aio/operations → aio/_operations}/__init__.py +13 -8
- azure/ai/textanalytics/aio/_operations/_operations.py +623 -0
- azure/ai/textanalytics/{_generated/v2022_05_01 → aio/_operations}/_patch.py +8 -6
- azure/ai/textanalytics/aio/_patch.py +344 -0
- azure/ai/textanalytics/models/__init__.py +402 -0
- azure/ai/textanalytics/models/_enums.py +1979 -0
- azure/ai/textanalytics/models/_models.py +6641 -0
- azure/ai/textanalytics/{_generated/v2022_05_01/aio → models}/_patch.py +8 -6
- azure/ai/textanalytics/py.typed +1 -0
- {azure_ai_textanalytics-5.3.0b2.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/METADATA +668 -403
- azure_ai_textanalytics-6.0.0b1.dist-info/RECORD +29 -0
- {azure_ai_textanalytics-5.3.0b2.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/WHEEL +1 -1
- azure/ai/textanalytics/_base_client.py +0 -113
- azure/ai/textanalytics/_check.py +0 -22
- azure/ai/textanalytics/_dict_mixin.py +0 -57
- azure/ai/textanalytics/_generated/__init__.py +0 -16
- azure/ai/textanalytics/_generated/_configuration.py +0 -70
- azure/ai/textanalytics/_generated/_operations_mixin.py +0 -795
- azure/ai/textanalytics/_generated/_text_analytics_client.py +0 -126
- azure/ai/textanalytics/_generated/_version.py +0 -8
- azure/ai/textanalytics/_generated/aio/_configuration.py +0 -66
- azure/ai/textanalytics/_generated/aio/_operations_mixin.py +0 -776
- azure/ai/textanalytics/_generated/aio/_text_analytics_client.py +0 -124
- azure/ai/textanalytics/_generated/models.py +0 -8
- azure/ai/textanalytics/_generated/v2022_05_01/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v2022_05_01/_configuration.py +0 -72
- azure/ai/textanalytics/_generated/v2022_05_01/_text_analytics_client.py +0 -100
- azure/ai/textanalytics/_generated/v2022_05_01/_vendor.py +0 -45
- azure/ai/textanalytics/_generated/v2022_05_01/aio/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v2022_05_01/aio/_configuration.py +0 -71
- azure/ai/textanalytics/_generated/v2022_05_01/aio/_text_analytics_client.py +0 -97
- azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/_patch.py +0 -121
- azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/_text_analytics_client_operations.py +0 -603
- azure/ai/textanalytics/_generated/v2022_05_01/models/__init__.py +0 -281
- azure/ai/textanalytics/_generated/v2022_05_01/models/_models_py3.py +0 -5722
- azure/ai/textanalytics/_generated/v2022_05_01/models/_text_analytics_client_enums.py +0 -439
- azure/ai/textanalytics/_generated/v2022_05_01/operations/_patch.py +0 -120
- azure/ai/textanalytics/_generated/v2022_05_01/operations/_text_analytics_client_operations.py +0 -744
- azure/ai/textanalytics/_generated/v2022_10_01_preview/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v2022_10_01_preview/_configuration.py +0 -72
- azure/ai/textanalytics/_generated/v2022_10_01_preview/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v2022_10_01_preview/_text_analytics_client.py +0 -100
- azure/ai/textanalytics/_generated/v2022_10_01_preview/_vendor.py +0 -45
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_configuration.py +0 -71
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_text_analytics_client.py +0 -97
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_vendor.py +0 -27
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/operations/_patch.py +0 -121
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/operations/_text_analytics_client_operations.py +0 -603
- azure/ai/textanalytics/_generated/v2022_10_01_preview/models/__init__.py +0 -405
- azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_models_py3.py +0 -8420
- azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_patch.py +0 -486
- azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_text_analytics_client_enums.py +0 -729
- azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/_patch.py +0 -120
- azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/_text_analytics_client_operations.py +0 -744
- azure/ai/textanalytics/_generated/v3_0/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v3_0/_configuration.py +0 -66
- azure/ai/textanalytics/_generated/v3_0/_patch.py +0 -31
- azure/ai/textanalytics/_generated/v3_0/_text_analytics_client.py +0 -96
- azure/ai/textanalytics/_generated/v3_0/_vendor.py +0 -33
- azure/ai/textanalytics/_generated/v3_0/aio/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v3_0/aio/_configuration.py +0 -65
- azure/ai/textanalytics/_generated/v3_0/aio/_patch.py +0 -31
- azure/ai/textanalytics/_generated/v3_0/aio/_text_analytics_client.py +0 -93
- azure/ai/textanalytics/_generated/v3_0/aio/_vendor.py +0 -27
- azure/ai/textanalytics/_generated/v3_0/aio/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v3_0/aio/operations/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_0/aio/operations/_text_analytics_client_operations.py +0 -428
- azure/ai/textanalytics/_generated/v3_0/models/__init__.py +0 -81
- azure/ai/textanalytics/_generated/v3_0/models/_models_py3.py +0 -1467
- azure/ai/textanalytics/_generated/v3_0/models/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_0/models/_text_analytics_client_enums.py +0 -58
- azure/ai/textanalytics/_generated/v3_0/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v3_0/operations/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_0/operations/_text_analytics_client_operations.py +0 -604
- azure/ai/textanalytics/_generated/v3_1/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v3_1/_configuration.py +0 -66
- azure/ai/textanalytics/_generated/v3_1/_patch.py +0 -31
- azure/ai/textanalytics/_generated/v3_1/_text_analytics_client.py +0 -98
- azure/ai/textanalytics/_generated/v3_1/_vendor.py +0 -45
- azure/ai/textanalytics/_generated/v3_1/aio/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v3_1/aio/_configuration.py +0 -65
- azure/ai/textanalytics/_generated/v3_1/aio/_patch.py +0 -31
- azure/ai/textanalytics/_generated/v3_1/aio/_text_analytics_client.py +0 -95
- azure/ai/textanalytics/_generated/v3_1/aio/_vendor.py +0 -27
- azure/ai/textanalytics/_generated/v3_1/aio/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v3_1/aio/operations/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_1/aio/operations/_text_analytics_client_operations.py +0 -1291
- azure/ai/textanalytics/_generated/v3_1/models/__init__.py +0 -205
- azure/ai/textanalytics/_generated/v3_1/models/_models_py3.py +0 -3976
- azure/ai/textanalytics/_generated/v3_1/models/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_1/models/_text_analytics_client_enums.py +0 -367
- azure/ai/textanalytics/_generated/v3_1/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v3_1/operations/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_1/operations/_text_analytics_client_operations.py +0 -1709
- azure/ai/textanalytics/_lro.py +0 -553
- azure/ai/textanalytics/_models.py +0 -3158
- azure/ai/textanalytics/_policies.py +0 -66
- azure/ai/textanalytics/_request_handlers.py +0 -104
- azure/ai/textanalytics/_response_handlers.py +0 -583
- azure/ai/textanalytics/_text_analytics_client.py +0 -2081
- azure/ai/textanalytics/_user_agent.py +0 -8
- azure/ai/textanalytics/_validate.py +0 -113
- azure/ai/textanalytics/aio/_base_client_async.py +0 -98
- azure/ai/textanalytics/aio/_lro_async.py +0 -503
- azure/ai/textanalytics/aio/_response_handlers_async.py +0 -94
- azure/ai/textanalytics/aio/_text_analytics_client_async.py +0 -2077
- azure_ai_textanalytics-5.3.0b2.dist-info/RECORD +0 -115
- {azure_ai_textanalytics-5.3.0b2.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info/licenses}/LICENSE +0 -0
- {azure_ai_textanalytics-5.3.0b2.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/top_level.txt +0 -0
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
# ------------------------------------
|
|
2
|
-
# Copyright (c) Microsoft Corporation.
|
|
3
|
-
# Licensed under the MIT License.
|
|
4
|
-
# ------------------------------------
|
|
5
|
-
|
|
6
|
-
import base64
|
|
7
|
-
import functools
|
|
8
|
-
import json
|
|
9
|
-
import datetime
|
|
10
|
-
from typing import Mapping, Any, TypeVar, Generator, Awaitable, cast, Optional
|
|
11
|
-
from typing_extensions import Protocol, runtime_checkable
|
|
12
|
-
from azure.core.exceptions import HttpResponseError
|
|
13
|
-
from azure.core.polling import AsyncLROPoller
|
|
14
|
-
from azure.core.polling.base_polling import OperationFailed, BadStatus
|
|
15
|
-
from azure.core.polling.async_base_polling import AsyncLROBasePolling
|
|
16
|
-
from azure.core.tracing.decorator_async import distributed_trace_async
|
|
17
|
-
from .._lro import TextAnalyticsOperationResourcePolling
|
|
18
|
-
|
|
19
|
-
_FINISHED = frozenset(["succeeded", "cancelled", "failed", "partiallycompleted", "partiallysucceeded"])
|
|
20
|
-
_FAILED = frozenset(["failed"])
|
|
21
|
-
_SUCCEEDED = frozenset(["succeeded", "partiallycompleted", "partiallysucceeded"])
|
|
22
|
-
|
|
23
|
-
PollingReturnType = TypeVar("PollingReturnType")
|
|
24
|
-
PollingReturnType_co = TypeVar("PollingReturnType_co", covariant=True)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@runtime_checkable
|
|
28
|
-
class AsyncTextAnalysisLROPoller(Protocol[PollingReturnType_co], Awaitable):
|
|
29
|
-
"""Implements a protocol which returned poller objects are consistent with.
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
@property
|
|
33
|
-
def details(self) -> Mapping[str, Any]:
|
|
34
|
-
"""Long-running operation metadata.
|
|
35
|
-
|
|
36
|
-
:return: A mapping of details about the long-running operation.
|
|
37
|
-
:rtype: Mapping[str, Any]
|
|
38
|
-
"""
|
|
39
|
-
...
|
|
40
|
-
|
|
41
|
-
def continuation_token(self) -> str: # pylint: disable=no-self-use
|
|
42
|
-
"""Return a continuation token that allows to restart the poller later.
|
|
43
|
-
|
|
44
|
-
:returns: An opaque continuation token
|
|
45
|
-
:rtype: str
|
|
46
|
-
"""
|
|
47
|
-
...
|
|
48
|
-
|
|
49
|
-
def status(self) -> str: # pylint: disable=no-self-use
|
|
50
|
-
"""Returns the current status string.
|
|
51
|
-
|
|
52
|
-
:returns: The current status string
|
|
53
|
-
:rtype: str
|
|
54
|
-
"""
|
|
55
|
-
...
|
|
56
|
-
|
|
57
|
-
async def result(self) -> PollingReturnType_co:
|
|
58
|
-
"""Return the result of the long running operation.
|
|
59
|
-
|
|
60
|
-
:returns: The deserialized resource of the long running operation, if one is available.
|
|
61
|
-
:raises ~azure.core.exceptions.HttpResponseError: Server problem with the query.
|
|
62
|
-
"""
|
|
63
|
-
...
|
|
64
|
-
|
|
65
|
-
async def wait(self) -> None:
|
|
66
|
-
"""Wait on the long running operation.
|
|
67
|
-
|
|
68
|
-
:raises ~azure.core.exceptions.HttpResponseError: Server problem with the query.
|
|
69
|
-
"""
|
|
70
|
-
...
|
|
71
|
-
|
|
72
|
-
def done(self) -> bool: # pylint: disable=no-self-use
|
|
73
|
-
"""Check status of the long running operation.
|
|
74
|
-
|
|
75
|
-
:returns: 'True' if the process has completed, else 'False'.
|
|
76
|
-
:rtype: bool
|
|
77
|
-
"""
|
|
78
|
-
...
|
|
79
|
-
|
|
80
|
-
def __await__(self) -> Generator[Any, None, PollingReturnType_co]:
|
|
81
|
-
...
|
|
82
|
-
|
|
83
|
-
async def cancel(self) -> None: # pylint: disable=no-self-use
|
|
84
|
-
"""Cancel the operation currently being polled.
|
|
85
|
-
|
|
86
|
-
:return: None
|
|
87
|
-
:rtype: None
|
|
88
|
-
:raises ~azure.core.exceptions.HttpResponseError: When the operation has already reached a terminal state.
|
|
89
|
-
"""
|
|
90
|
-
...
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
class TextAnalyticsAsyncLROPollingMethod(AsyncLROBasePolling):
|
|
94
|
-
def finished(self) -> bool:
|
|
95
|
-
"""Is this polling finished?
|
|
96
|
-
:rtype: bool
|
|
97
|
-
"""
|
|
98
|
-
return TextAnalyticsAsyncLROPollingMethod._finished(self.status())
|
|
99
|
-
|
|
100
|
-
@staticmethod
|
|
101
|
-
def _finished(status) -> bool:
|
|
102
|
-
if hasattr(status, "value"):
|
|
103
|
-
status = status.value
|
|
104
|
-
return str(status).lower() in _FINISHED
|
|
105
|
-
|
|
106
|
-
@staticmethod
|
|
107
|
-
def _failed(status) -> bool:
|
|
108
|
-
if hasattr(status, "value"):
|
|
109
|
-
status = status.value
|
|
110
|
-
return str(status).lower() in _FAILED
|
|
111
|
-
|
|
112
|
-
@staticmethod
|
|
113
|
-
def _raise_if_bad_http_status_and_method(response):
|
|
114
|
-
"""Check response status code is valid.
|
|
115
|
-
|
|
116
|
-
Must be 200, 201, 202, or 204.
|
|
117
|
-
|
|
118
|
-
:raises: BadStatus if invalid status.
|
|
119
|
-
"""
|
|
120
|
-
code = response.status_code
|
|
121
|
-
if code in {200, 201, 202, 204}:
|
|
122
|
-
return
|
|
123
|
-
raise BadStatus(
|
|
124
|
-
"Invalid return status {!r} for {!r} operation".format(
|
|
125
|
-
code, response.request.method
|
|
126
|
-
)
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
async def _poll(self): # pylint:disable=invalid-overridden-method
|
|
130
|
-
"""Poll status of operation so long as operation is incomplete and
|
|
131
|
-
we have an endpoint to query.
|
|
132
|
-
|
|
133
|
-
:param callable update_cmd: The function to call to retrieve the
|
|
134
|
-
latest status of the long running operation.
|
|
135
|
-
:raises: OperationFailed if operation status 'Failed' or 'Canceled'.
|
|
136
|
-
:raises: BadStatus if response status invalid.
|
|
137
|
-
:raises: BadResponse if response invalid.
|
|
138
|
-
"""
|
|
139
|
-
|
|
140
|
-
if not self.finished():
|
|
141
|
-
await self.update_status()
|
|
142
|
-
while not self.finished():
|
|
143
|
-
await self._delay()
|
|
144
|
-
await self.update_status()
|
|
145
|
-
|
|
146
|
-
if TextAnalyticsAsyncLROPollingMethod._failed(self.status()):
|
|
147
|
-
try:
|
|
148
|
-
job = json.loads(self._pipeline_response.http_response.text())
|
|
149
|
-
error_message = ""
|
|
150
|
-
for err in job["errors"]:
|
|
151
|
-
error_message += "({}) {}".format(err["code"], err["message"])
|
|
152
|
-
raise HttpResponseError(message=error_message, response=self._pipeline_response.http_response)
|
|
153
|
-
except KeyError as e:
|
|
154
|
-
raise OperationFailed("Operation failed or canceled") from e
|
|
155
|
-
|
|
156
|
-
final_get_url = self._operation.get_final_get_url(self._pipeline_response)
|
|
157
|
-
if final_get_url:
|
|
158
|
-
self._pipeline_response = await self.request_status(final_get_url)
|
|
159
|
-
TextAnalyticsAsyncLROPollingMethod._raise_if_bad_http_status_and_method(
|
|
160
|
-
self._pipeline_response.http_response
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
class AsyncAnalyzeHealthcareEntitiesLROPollingMethod(
|
|
165
|
-
TextAnalyticsAsyncLROPollingMethod
|
|
166
|
-
):
|
|
167
|
-
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
168
|
-
self._text_analytics_client = kwargs.pop("text_analytics_client")
|
|
169
|
-
self._doc_id_order = kwargs.pop("doc_id_order", None)
|
|
170
|
-
self._show_stats = kwargs.pop("show_stats", None)
|
|
171
|
-
super().__init__(
|
|
172
|
-
*args, **kwargs
|
|
173
|
-
)
|
|
174
|
-
|
|
175
|
-
@property
|
|
176
|
-
def _current_body(self):
|
|
177
|
-
from .._generated.models import JobState
|
|
178
|
-
return JobState.deserialize(self._pipeline_response)
|
|
179
|
-
|
|
180
|
-
@property
|
|
181
|
-
def created_on(self) -> Optional[datetime.datetime]:
|
|
182
|
-
if not self._current_body:
|
|
183
|
-
return None
|
|
184
|
-
return self._current_body.created_date_time
|
|
185
|
-
|
|
186
|
-
@property
|
|
187
|
-
def expires_on(self) -> Optional[datetime.datetime]:
|
|
188
|
-
if not self._current_body:
|
|
189
|
-
return None
|
|
190
|
-
return self._current_body.expiration_date_time
|
|
191
|
-
|
|
192
|
-
@property
|
|
193
|
-
def last_modified_on(self) -> Optional[datetime.datetime]:
|
|
194
|
-
if not self._current_body:
|
|
195
|
-
return None
|
|
196
|
-
return self._current_body.last_update_date_time
|
|
197
|
-
|
|
198
|
-
@property
|
|
199
|
-
def id(self) -> str:
|
|
200
|
-
if self._current_body and self._current_body.job_id is not None:
|
|
201
|
-
return self._current_body.job_id
|
|
202
|
-
return self._get_id_from_headers()
|
|
203
|
-
|
|
204
|
-
def _get_id_from_headers(self) -> str:
|
|
205
|
-
return self._initial_response.http_response.headers[
|
|
206
|
-
"Operation-Location"
|
|
207
|
-
].split("/jobs/")[1].split("?")[0]
|
|
208
|
-
|
|
209
|
-
@property
|
|
210
|
-
def display_name(self) -> Optional[str]:
|
|
211
|
-
if not self._current_body:
|
|
212
|
-
return None
|
|
213
|
-
return self._current_body.display_name
|
|
214
|
-
|
|
215
|
-
def get_continuation_token(self) -> str:
|
|
216
|
-
import pickle
|
|
217
|
-
self._initial_response.context.options["doc_id_order"] = self._doc_id_order
|
|
218
|
-
self._initial_response.context.options["show_stats"] = self._show_stats
|
|
219
|
-
return base64.b64encode(pickle.dumps(self._initial_response)).decode('ascii')
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
class AsyncAnalyzeHealthcareEntitiesLROPoller(AsyncLROPoller[PollingReturnType]):
|
|
223
|
-
def polling_method(self) -> AsyncAnalyzeHealthcareEntitiesLROPollingMethod: # type: ignore
|
|
224
|
-
"""Return the polling method associated to this poller.
|
|
225
|
-
|
|
226
|
-
:return: AsyncAnalyzeHealthcareEntitiesLROPollingMethod
|
|
227
|
-
:rtype: AsyncAnalyzeHealthcareEntitiesLROPollingMethod
|
|
228
|
-
"""
|
|
229
|
-
return self._polling_method # type: ignore
|
|
230
|
-
|
|
231
|
-
@property
|
|
232
|
-
def details(self) -> Mapping[str, Any]:
|
|
233
|
-
"""Long-running operation metadata.
|
|
234
|
-
|
|
235
|
-
:return: A mapping of details about the long-running operation.
|
|
236
|
-
:rtype: Mapping[str, Any]
|
|
237
|
-
"""
|
|
238
|
-
return {
|
|
239
|
-
"id": self.polling_method().id,
|
|
240
|
-
"created_on": self.polling_method().created_on,
|
|
241
|
-
"expires_on": self.polling_method().expires_on,
|
|
242
|
-
"display_name": self.polling_method().display_name,
|
|
243
|
-
"last_modified_on": self.polling_method().last_modified_on,
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
def __getattr__(self, item: str) -> Any:
|
|
247
|
-
attrs = [
|
|
248
|
-
"created_on",
|
|
249
|
-
"expires_on",
|
|
250
|
-
"display_name",
|
|
251
|
-
"last_modified_on",
|
|
252
|
-
"id"
|
|
253
|
-
]
|
|
254
|
-
if item in attrs:
|
|
255
|
-
return self.details[item]
|
|
256
|
-
return self.__getattribute__(item)
|
|
257
|
-
|
|
258
|
-
@classmethod
|
|
259
|
-
def from_continuation_token( # type: ignore
|
|
260
|
-
cls,
|
|
261
|
-
polling_method: AsyncAnalyzeHealthcareEntitiesLROPollingMethod,
|
|
262
|
-
continuation_token: str,
|
|
263
|
-
**kwargs: Any
|
|
264
|
-
) -> "AsyncAnalyzeHealthcareEntitiesLROPoller":
|
|
265
|
-
"""Internal use only.
|
|
266
|
-
|
|
267
|
-
:param polling_method: Polling method to use.
|
|
268
|
-
:type polling_method: AsyncAnalyzeHealthcareEntitiesLROPollingMethod
|
|
269
|
-
:param str continuation_token: Opaque token.
|
|
270
|
-
:return: AsyncAnalyzeHealthcareEntitiesLROPoller
|
|
271
|
-
:rtype: AsyncAnalyzeHealthcareEntitiesLROPoller
|
|
272
|
-
|
|
273
|
-
:meta private:
|
|
274
|
-
"""
|
|
275
|
-
client, initial_response, deserialization_callback = polling_method.from_continuation_token(
|
|
276
|
-
continuation_token, **kwargs
|
|
277
|
-
)
|
|
278
|
-
polling_method._lro_algorithms = [ # pylint: disable=protected-access
|
|
279
|
-
TextAnalyticsOperationResourcePolling(
|
|
280
|
-
show_stats=initial_response.context.options["show_stats"]
|
|
281
|
-
)
|
|
282
|
-
]
|
|
283
|
-
return cls(
|
|
284
|
-
client,
|
|
285
|
-
initial_response,
|
|
286
|
-
functools.partial(deserialization_callback, initial_response),
|
|
287
|
-
polling_method # type: ignore
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
@distributed_trace_async
|
|
291
|
-
async def cancel(self, **kwargs: Any) -> "AsyncLROPoller[None]": # type: ignore
|
|
292
|
-
"""Cancel the operation currently being polled.
|
|
293
|
-
|
|
294
|
-
:keyword int polling_interval: The polling interval to use to poll the cancellation status.
|
|
295
|
-
The default value is 5 seconds.
|
|
296
|
-
:return: Returns an instance of an AsyncLROPoller that returns None.
|
|
297
|
-
:rtype: ~azure.core.polling.AsyncLROPoller[None]
|
|
298
|
-
:raises ~azure.core.exceptions.HttpResponseError: When the operation has already reached a terminal state.
|
|
299
|
-
|
|
300
|
-
.. admonition:: Example:
|
|
301
|
-
|
|
302
|
-
.. literalinclude:: ../samples/async_samples/sample_analyze_healthcare_entities_with_cancellation_async.py
|
|
303
|
-
:start-after: [START analyze_healthcare_entities_with_cancellation_async]
|
|
304
|
-
:end-before: [END analyze_healthcare_entities_with_cancellation_async]
|
|
305
|
-
:language: python
|
|
306
|
-
:dedent: 4
|
|
307
|
-
:caption: Cancel an existing health operation.
|
|
308
|
-
"""
|
|
309
|
-
polling_interval = kwargs.pop("polling_interval", 5)
|
|
310
|
-
|
|
311
|
-
try:
|
|
312
|
-
client = getattr(
|
|
313
|
-
self._polling_method, "_text_analytics_client"
|
|
314
|
-
)
|
|
315
|
-
try:
|
|
316
|
-
return await client.begin_cancel_health_job(
|
|
317
|
-
self.id, polling=TextAnalyticsAsyncLROPollingMethod(timeout=polling_interval)
|
|
318
|
-
)
|
|
319
|
-
except ValueError: # language API compat
|
|
320
|
-
return await client.begin_analyze_text_cancel_job(
|
|
321
|
-
self.id, polling=TextAnalyticsAsyncLROPollingMethod(timeout=polling_interval)
|
|
322
|
-
)
|
|
323
|
-
except HttpResponseError as error:
|
|
324
|
-
from .._response_handlers import process_http_response_error
|
|
325
|
-
|
|
326
|
-
process_http_response_error(error)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
class AsyncAnalyzeActionsLROPollingMethod(TextAnalyticsAsyncLROPollingMethod):
|
|
330
|
-
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
331
|
-
self._doc_id_order = kwargs.pop("doc_id_order", None)
|
|
332
|
-
self._task_id_order = kwargs.pop("task_id_order", None)
|
|
333
|
-
self._show_stats = kwargs.pop("show_stats", None)
|
|
334
|
-
self._text_analytics_client = kwargs.pop("text_analytics_client")
|
|
335
|
-
super().__init__(*args, **kwargs)
|
|
336
|
-
|
|
337
|
-
@property
|
|
338
|
-
def _current_body(self):
|
|
339
|
-
from .._generated.models import JobState
|
|
340
|
-
return JobState.deserialize(self._pipeline_response)
|
|
341
|
-
|
|
342
|
-
@property
|
|
343
|
-
def created_on(self) -> Optional[datetime.datetime]:
|
|
344
|
-
if not self._current_body:
|
|
345
|
-
return None
|
|
346
|
-
return self._current_body.created_date_time
|
|
347
|
-
|
|
348
|
-
@property
|
|
349
|
-
def display_name(self) -> Optional[str]:
|
|
350
|
-
if not self._current_body:
|
|
351
|
-
return None
|
|
352
|
-
return self._current_body.display_name
|
|
353
|
-
|
|
354
|
-
@property
|
|
355
|
-
def expires_on(self) -> Optional[datetime.datetime]:
|
|
356
|
-
if not self._current_body:
|
|
357
|
-
return None
|
|
358
|
-
return self._current_body.expiration_date_time
|
|
359
|
-
|
|
360
|
-
@property
|
|
361
|
-
def actions_failed_count(self) -> Optional[int]:
|
|
362
|
-
if not self._current_body:
|
|
363
|
-
return None
|
|
364
|
-
return self._current_body.additional_properties.get("tasks", {}).get("failed", None)
|
|
365
|
-
|
|
366
|
-
@property
|
|
367
|
-
def actions_in_progress_count(self) -> Optional[int]:
|
|
368
|
-
if not self._current_body:
|
|
369
|
-
return None
|
|
370
|
-
return self._current_body.additional_properties.get("tasks", {}).get("inProgress", None)
|
|
371
|
-
|
|
372
|
-
@property
|
|
373
|
-
def actions_succeeded_count(self) -> Optional[int]:
|
|
374
|
-
if not self._current_body:
|
|
375
|
-
return None
|
|
376
|
-
return self._current_body.additional_properties.get("tasks", {}).get("completed", None)
|
|
377
|
-
|
|
378
|
-
@property
|
|
379
|
-
def last_modified_on(self) -> Optional[datetime.datetime]:
|
|
380
|
-
if not self._current_body:
|
|
381
|
-
return None
|
|
382
|
-
return self._current_body.last_update_date_time
|
|
383
|
-
|
|
384
|
-
@property
|
|
385
|
-
def total_actions_count(self) -> Optional[int]:
|
|
386
|
-
if not self._current_body:
|
|
387
|
-
return None
|
|
388
|
-
return self._current_body.additional_properties.get("tasks", {}).get("total", None)
|
|
389
|
-
|
|
390
|
-
@property
|
|
391
|
-
def id(self) -> str:
|
|
392
|
-
if self._current_body and self._current_body.job_id is not None:
|
|
393
|
-
return self._current_body.job_id
|
|
394
|
-
return self._get_id_from_headers()
|
|
395
|
-
|
|
396
|
-
def _get_id_from_headers(self) -> str:
|
|
397
|
-
return self._initial_response.http_response.headers[
|
|
398
|
-
"Operation-Location"
|
|
399
|
-
].split("/jobs/")[1].split("?")[0]
|
|
400
|
-
|
|
401
|
-
def get_continuation_token(self) -> str:
|
|
402
|
-
import pickle
|
|
403
|
-
self._initial_response.context.options["doc_id_order"] = self._doc_id_order
|
|
404
|
-
self._initial_response.context.options["task_id_order"] = self._task_id_order
|
|
405
|
-
self._initial_response.context.options["show_stats"] = self._show_stats
|
|
406
|
-
return base64.b64encode(pickle.dumps(self._initial_response)).decode('ascii')
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
class AsyncAnalyzeActionsLROPoller(AsyncLROPoller[PollingReturnType]):
|
|
410
|
-
def polling_method(self) -> AsyncAnalyzeActionsLROPollingMethod: # type: ignore
|
|
411
|
-
"""Return the polling method associated to this poller.
|
|
412
|
-
|
|
413
|
-
:return: AsyncAnalyzeActionsLROPollingMethod
|
|
414
|
-
:rtype: AsyncAnalyzeActionsLROPollingMethod
|
|
415
|
-
"""
|
|
416
|
-
return self._polling_method # type: ignore
|
|
417
|
-
|
|
418
|
-
@property
|
|
419
|
-
def details(self) -> Mapping[str, Any]:
|
|
420
|
-
"""Long-running operation metadata.
|
|
421
|
-
|
|
422
|
-
:return: A mapping of details about the long-running operation.
|
|
423
|
-
:rtype: Mapping[str, Any]
|
|
424
|
-
"""
|
|
425
|
-
return {
|
|
426
|
-
"id": self.polling_method().id,
|
|
427
|
-
"created_on": self.polling_method().created_on,
|
|
428
|
-
"expires_on": self.polling_method().expires_on,
|
|
429
|
-
"display_name": self.polling_method().display_name,
|
|
430
|
-
"last_modified_on": self.polling_method().last_modified_on,
|
|
431
|
-
"actions_failed_count": self.polling_method().actions_failed_count,
|
|
432
|
-
"actions_in_progress_count": self.polling_method().actions_in_progress_count,
|
|
433
|
-
"actions_succeeded_count": self.polling_method().actions_succeeded_count,
|
|
434
|
-
"total_actions_count": self.polling_method().total_actions_count,
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
def __getattr__(self, item: str) -> Any:
|
|
438
|
-
attrs = [
|
|
439
|
-
"created_on",
|
|
440
|
-
"expires_on",
|
|
441
|
-
"display_name",
|
|
442
|
-
"actions_failed_count",
|
|
443
|
-
"actions_in_progress_count",
|
|
444
|
-
"actions_succeeded_count",
|
|
445
|
-
"total_actions_count",
|
|
446
|
-
"last_modified_on",
|
|
447
|
-
"id"
|
|
448
|
-
]
|
|
449
|
-
if item in attrs:
|
|
450
|
-
return self.details[item]
|
|
451
|
-
return self.__getattribute__(item)
|
|
452
|
-
|
|
453
|
-
@classmethod
|
|
454
|
-
def from_continuation_token( # type: ignore
|
|
455
|
-
cls,
|
|
456
|
-
polling_method: AsyncAnalyzeActionsLROPollingMethod,
|
|
457
|
-
continuation_token: str,
|
|
458
|
-
**kwargs: Any
|
|
459
|
-
) -> "AsyncAnalyzeActionsLROPoller": # type: ignore
|
|
460
|
-
"""Internal use only.
|
|
461
|
-
|
|
462
|
-
:param polling_method: Polling method to use.
|
|
463
|
-
:type polling_method: AsyncAnalyzeActionsLROPollingMethod
|
|
464
|
-
:param str continuation_token: Opaque token.
|
|
465
|
-
:return: AsyncAnalyzeActionsLROPoller
|
|
466
|
-
:rtype: AsyncAnalyzeActionsLROPoller
|
|
467
|
-
|
|
468
|
-
:meta private:
|
|
469
|
-
"""
|
|
470
|
-
client, initial_response, deserialization_callback = polling_method.from_continuation_token(
|
|
471
|
-
continuation_token, **kwargs
|
|
472
|
-
)
|
|
473
|
-
polling_method._lro_algorithms = [ # pylint: disable=protected-access
|
|
474
|
-
TextAnalyticsOperationResourcePolling(
|
|
475
|
-
show_stats=initial_response.context.options["show_stats"]
|
|
476
|
-
)
|
|
477
|
-
]
|
|
478
|
-
return cls(
|
|
479
|
-
client,
|
|
480
|
-
initial_response,
|
|
481
|
-
functools.partial(deserialization_callback, initial_response),
|
|
482
|
-
polling_method # type: ignore
|
|
483
|
-
)
|
|
484
|
-
|
|
485
|
-
@distributed_trace_async
|
|
486
|
-
async def cancel(self) -> None:
|
|
487
|
-
"""Cancel the operation currently being polled.
|
|
488
|
-
|
|
489
|
-
:return: None
|
|
490
|
-
:rtype: None
|
|
491
|
-
:raises ~azure.core.exceptions.HttpResponseError: When the operation has already reached a terminal state.
|
|
492
|
-
"""
|
|
493
|
-
|
|
494
|
-
cast(AsyncAnalyzeActionsLROPollingMethod, self.polling_method)
|
|
495
|
-
client = self.polling_method()._text_analytics_client # pylint: disable=protected-access
|
|
496
|
-
|
|
497
|
-
try:
|
|
498
|
-
await client.begin_analyze_text_cancel_job(self.id, polling=False)
|
|
499
|
-
except ValueError:
|
|
500
|
-
raise ValueError("Cancellation not supported by API versions v3.0, v3.1.")
|
|
501
|
-
except HttpResponseError as error:
|
|
502
|
-
from .._response_handlers import process_http_response_error
|
|
503
|
-
process_http_response_error(error)
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# ------------------------------------
|
|
2
|
-
# Copyright (c) Microsoft Corporation.
|
|
3
|
-
# Licensed under the MIT License.
|
|
4
|
-
# ------------------------------------
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import functools
|
|
8
|
-
from urllib.parse import urlparse, parse_qsl
|
|
9
|
-
|
|
10
|
-
from azure.core.async_paging import AsyncList, AsyncItemPaged
|
|
11
|
-
from .._response_handlers import healthcare_result, get_iter_items
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
async def healthcare_extract_page_data_async(
|
|
15
|
-
doc_id_order, obj, health_job_state
|
|
16
|
-
): # pylint: disable=unused-argument
|
|
17
|
-
return (
|
|
18
|
-
health_job_state.next_link,
|
|
19
|
-
healthcare_result(
|
|
20
|
-
doc_id_order,
|
|
21
|
-
health_job_state.results
|
|
22
|
-
if hasattr(health_job_state, "results")
|
|
23
|
-
else health_job_state.tasks.items[0].results,
|
|
24
|
-
{},
|
|
25
|
-
lro=True
|
|
26
|
-
),
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
async def lro_get_next_page_async(
|
|
31
|
-
lro_status_callback, first_page, continuation_token, show_stats=False
|
|
32
|
-
):
|
|
33
|
-
if continuation_token is None:
|
|
34
|
-
return first_page
|
|
35
|
-
|
|
36
|
-
try:
|
|
37
|
-
continuation_token = continuation_token.decode("utf-8")
|
|
38
|
-
|
|
39
|
-
except AttributeError:
|
|
40
|
-
pass
|
|
41
|
-
|
|
42
|
-
parsed_url = urlparse(continuation_token)
|
|
43
|
-
job_id = parsed_url.path.split("/")[-1]
|
|
44
|
-
query_params = dict(parse_qsl(parsed_url.query.replace("$", "")))
|
|
45
|
-
if "showStats" in query_params:
|
|
46
|
-
query_params.pop("showStats")
|
|
47
|
-
if "api-version" in query_params: # language api compat
|
|
48
|
-
query_params.pop("api-version")
|
|
49
|
-
query_params["show_stats"] = show_stats
|
|
50
|
-
|
|
51
|
-
return await lro_status_callback(job_id, **query_params)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def healthcare_paged_result(
|
|
55
|
-
doc_id_order,
|
|
56
|
-
health_status_callback,
|
|
57
|
-
_,
|
|
58
|
-
obj,
|
|
59
|
-
show_stats=False,
|
|
60
|
-
):
|
|
61
|
-
return AsyncItemPaged(
|
|
62
|
-
functools.partial(
|
|
63
|
-
lro_get_next_page_async, health_status_callback, obj, show_stats=show_stats
|
|
64
|
-
),
|
|
65
|
-
functools.partial(
|
|
66
|
-
healthcare_extract_page_data_async, doc_id_order, obj
|
|
67
|
-
),
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
async def analyze_extract_page_data_async(
|
|
72
|
-
doc_id_order, task_order, bespoke, analyze_job_state
|
|
73
|
-
):
|
|
74
|
-
iter_items = get_iter_items(
|
|
75
|
-
doc_id_order, task_order, bespoke, analyze_job_state
|
|
76
|
-
)
|
|
77
|
-
return analyze_job_state.next_link, AsyncList(iter_items)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def analyze_paged_result(
|
|
81
|
-
doc_id_order,
|
|
82
|
-
task_order,
|
|
83
|
-
analyze_status_callback,
|
|
84
|
-
_,
|
|
85
|
-
obj,
|
|
86
|
-
show_stats=False,
|
|
87
|
-
bespoke=False
|
|
88
|
-
):
|
|
89
|
-
return AsyncItemPaged(
|
|
90
|
-
functools.partial(lro_get_next_page_async, analyze_status_callback, obj, show_stats=show_stats),
|
|
91
|
-
functools.partial(
|
|
92
|
-
analyze_extract_page_data_async, doc_id_order, task_order, bespoke
|
|
93
|
-
),
|
|
94
|
-
)
|