Skip to content

Commit

Permalink
[text analytics] make default v3.1-preview.3 and remove v3.1-preview.2 (
Browse files Browse the repository at this point in the history
#16370)

fixes #16119
  • Loading branch information
iscai-msft authored Jan 27, 2021
1 parent d3e00df commit cbeb616
Show file tree
Hide file tree
Showing 628 changed files with 16,363 additions and 18,690 deletions.
5 changes: 4 additions & 1 deletion sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 5.1.0b5 (Unreleased)

**New Features**
- No longer need to specify `api_version=TextAnalyticsApiVersion.V3_1_PREVIEW_3` when calling `begin_analyze` and `begin_analyze_healthcare`. `begin_analyze_healthcare` is still in gated preview though.


## 5.1.0b4 (2021-01-12)

Expand Down Expand Up @@ -59,7 +62,7 @@ used in conjunction with the Bing Entity Search API to fetch additional relevant
- Removed `grapheme_offset` and `grapheme_length` from `CategorizedEntity`, `SentenceSentiment`, and `LinkedEntityMatch`
- `TextDocumentStatistics` attribute `grapheme_count` has been renamed to `character_count`

## 1.0.0b5
## 1.0.0b5

- This was a broken release

Expand Down
4 changes: 2 additions & 2 deletions sdk/textanalytics/azure-ai-textanalytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ from azure.ai.textanalytics import TextAnalyticsClient
credential = AzureKeyCredential("<api_key>")
endpoint="https://<region>.api.cognitive.microsoft.com/"

text_analytics_client = TextAnalyticsClient(endpoint, credential, api_version="v3.1-preview.3")
text_analytics_client = TextAnalyticsClient(endpoint, credential)

documents = ["Subject is taking 100mg of ibuprofen twice daily"]

Expand Down Expand Up @@ -478,7 +478,7 @@ from azure.ai.textanalytics import (
credential = AzureKeyCredential("<api_key>")
endpoint="https://<region>.api.cognitive.microsoft.com/"

text_analytics_client = TextAnalyticsClient(endpoint, credential, api_version="v3.1-preview.3")
text_analytics_client = TextAnalyticsClient(endpoint, credential)

documents = ["Microsoft was founded by Bill Gates and Paul Allen."]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
class TextAnalyticsApiVersion(str, Enum):
"""Text Analytics API versions supported by this package"""

V3_1_PREVIEW_3 = "v3.1-preview.3"

#: this is the default version
V3_1_PREVIEW = "v3.1-preview.2"
V3_1_PREVIEW = "v3.1-preview.3"
V3_0 = "v3.0"

def _authentication_policy(credential):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from typing import Any
from typing import TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.credentials import TokenCredential

class TextAnalyticsClientConfiguration(Configuration):
"""Configuration for TextAnalyticsClient.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def analyze_status(
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.analyze_status(job_id, show_stats, top, skip, **kwargs)

Expand All @@ -81,8 +82,8 @@ def begin_analyze(
:type body: ~azure.ai.textanalytics.v3_1_preview_3.models.AnalyzeBatchInput
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
False for no polling, or your own initialized polling object for a personal polling strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
Expand All @@ -98,6 +99,7 @@ def begin_analyze(
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.begin_analyze(body, **kwargs)

Expand All @@ -114,8 +116,8 @@ def begin_cancel_health_job(
:type job_id: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
False for no polling, or your own initialized polling object for a personal polling strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
Expand All @@ -131,6 +133,7 @@ def begin_cancel_health_job(
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.begin_cancel_health_job(job_id, **kwargs)

Expand All @@ -157,8 +160,8 @@ def begin_health(
:type string_index_type: str or ~azure.ai.textanalytics.v3_1_preview_3.models.StringIndexType
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
False for no polling, or your own initialized polling object for a personal polling strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
Expand All @@ -174,6 +177,7 @@ def begin_health(
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.begin_health(documents, model_version, string_index_type, **kwargs)

Expand Down Expand Up @@ -206,8 +210,6 @@ def entities_linking(
api_version = self._get_api_version('entities_linking')
if api_version == 'v3.0':
from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.3':
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
Expand All @@ -216,6 +218,7 @@ def entities_linking(
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.entities_linking(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -249,8 +252,6 @@ def entities_recognition_general(
api_version = self._get_api_version('entities_recognition_general')
if api_version == 'v3.0':
from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.3':
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
Expand All @@ -259,6 +260,7 @@ def entities_recognition_general(
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.entities_recognition_general(documents, model_version, show_stats, **kwargs)

Expand All @@ -280,35 +282,35 @@ def entities_recognition_pii(
list of enabled languages.
:param documents: The set of documents to process as part of this batch.
:type documents: list[~azure.ai.textanalytics.v3_1_preview_2.models.MultiLanguageInput]
:type documents: list[~azure.ai.textanalytics.v3_1_preview_3.models.MultiLanguageInput]
:param model_version: (Optional) This value indicates which model will be used for scoring. If
a model-version is not specified, the API should default to the latest, non-preview version.
:type model_version: str
:param show_stats: (Optional) if set to true, response will contain request and document level
statistics.
:type show_stats: bool
:param domain: (Optional) if set to 'PHI', response will contain only PHI entities.
:param domain: (Optional) if specified, will set the PII domain to include only a subset of the
entity categories. Possible values include: 'PHI', 'none'.
:type domain: str
:param string_index_type: (Optional) Specifies the method used to interpret string offsets.
Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information
see https://aka.ms/text-analytics-offsets.
:type string_index_type: str or ~azure.ai.textanalytics.v3_1_preview_2.models.StringIndexType
:type string_index_type: str or ~azure.ai.textanalytics.v3_1_preview_3.models.StringIndexType
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PiiEntitiesResult, or the result of cls(response)
:rtype: ~azure.ai.textanalytics.v3_1_preview_2.models.PiiEntitiesResult
:return: PiiResult, or the result of cls(response)
:rtype: ~azure.ai.textanalytics.v3_1_preview_3.models.PiiResult
:raises: ~azure.core.exceptions.HttpResponseError
"""
api_version = self._get_api_version('entities_recognition_pii')
if api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.3':
if api_version == 'v3.1-preview.3':
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise ValueError("API version {} does not have operation 'entities_recognition_pii'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.entities_recognition_pii(documents, model_version, show_stats, domain, string_index_type, **kwargs)

Expand Down Expand Up @@ -349,6 +351,7 @@ def health_status(
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.health_status(job_id, top, skip, show_stats, **kwargs)

Expand Down Expand Up @@ -381,8 +384,6 @@ def key_phrases(
api_version = self._get_api_version('key_phrases')
if api_version == 'v3.0':
from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.3':
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
Expand All @@ -391,6 +392,7 @@ def key_phrases(
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.key_phrases(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -424,8 +426,6 @@ def languages(
api_version = self._get_api_version('languages')
if api_version == 'v3.0':
from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.3':
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
Expand All @@ -434,6 +434,7 @@ def languages(
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.languages(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -467,8 +468,6 @@ def sentiment(
api_version = self._get_api_version('sentiment')
if api_version == 'v3.0':
from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.3':
from .v3_1_preview_3.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
Expand All @@ -477,5 +476,6 @@ def sentiment(
mixin_instance._client = self._client
mixin_instance._config = self._config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._serialize.client_side_validation = False
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.sentiment(documents, model_version, show_stats, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@
# regenerated.
# --------------------------------------------------------------------------

from azure.core import PipelineClient
from msrest import Serializer, Deserializer
from typing import TYPE_CHECKING

from azure.core import PipelineClient
from azure.profiles import KnownProfiles, ProfileDefinition
from azure.profiles.multiapiclient import MultiApiClientMixin
from msrest import Deserializer, Serializer

from ._configuration import TextAnalyticsClientConfiguration
from ._operations_mixin import TextAnalyticsClientOperationsMixin

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional

from azure.core.credentials import TokenCredential

class _SDKClient(object):
def __init__(self, *args, **kwargs):
"""This is a fake class to support current implemetation of MultiApiClientMixin."
Expand All @@ -38,8 +47,8 @@ class TextAnalyticsClient(TextAnalyticsClientOperationsMixin, MultiApiClientMixi
:type credential: ~azure.core.credentials.TokenCredential
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).
:type endpoint: str
:param str api_version: API version to use if no profile is provided, or if
missing in profile.
:param api_version: API version to use if no profile is provided, or if missing in profile.
:type api_version: str
:param profile: A profile definition, from KnownProfiles to dict.
:type profile: azure.profiles.KnownProfiles
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
Expand All @@ -58,14 +67,12 @@ def __init__(
self,
credential, # type: "TokenCredential"
endpoint, # type: str
api_version=None,
profile=KnownProfiles.default,
api_version=None, # type: Optional[str]
profile=KnownProfiles.default, # type: KnownProfiles
**kwargs # type: Any
):
if api_version == 'v3.0':
base_url = '{Endpoint}/text/analytics/v3.0'
elif api_version == 'v3.1-preview.2':
base_url = '{Endpoint}/text/analytics/v3.1-preview.2'
elif api_version == 'v3.1-preview.3':
base_url = '{Endpoint}/text/analytics/v3.1-preview.3'
else:
Expand All @@ -86,15 +93,11 @@ def models(cls, api_version=DEFAULT_API_VERSION):
"""Module depends on the API version:
* v3.0: :mod:`v3_0.models<azure.ai.textanalytics.v3_0.models>`
* v3.1-preview.2: :mod:`v3_1_preview_2.models<azure.ai.textanalytics.v3_1_preview_2.models>`
* v3.1-preview.3: :mod:`v3_1_preview_3.models<azure.ai.textanalytics.v3_1_preview_3.models>`
"""
if api_version == 'v3.0':
from .v3_0 import models
return models
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2 import models
return models
elif api_version == 'v3.1-preview.3':
from .v3_1_preview_3 import models
return models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from typing import Any
from typing import Any, TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from .._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential

class TextAnalyticsClientConfiguration(Configuration):
"""Configuration for TextAnalyticsClient.
Expand All @@ -30,8 +33,8 @@ class TextAnalyticsClientConfiguration(Configuration):

def __init__(
self,
credential, # type: "AsyncTokenCredential"
endpoint, # type: str
credential: "AsyncTokenCredential",
endpoint: str,
**kwargs # type: Any
) -> None:
if credential is None:
Expand Down
Loading

0 comments on commit cbeb616

Please sign in to comment.