Skip to content
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

[text analytics] regen TA with GA autorest #14215

Merged
merged 5 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
**Breaking changes**
- Removed property `length` from `CategorizedEntity`, `SentenceSentiment`, `LinkedEntityMatch`, `AspectSentiment`, `OpinionSentiment`, and `PiiEntity`.
To get the length of the text in these models, just call `len()` on the `text` property.
- When a parameter or endpoint is not compatible with the API version you specify, we will now return a `ValueError` instead of a `NotImplementedError`.
iscai-msft marked this conversation as resolved.
Show resolved Hide resolved
- Client side validation of input is now disabled by default. This means there will be no `ValidationError`s thrown by the client SDK in the case of malformed input, the service will throw an error instead in an `HttpResponseError`

## 5.1.0b1 (2020-09-17)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import TYPE_CHECKING
import warnings

from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpRequest, HttpResponse

Expand Down Expand Up @@ -52,16 +52,15 @@ 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.1':
iscai-msft marked this conversation as resolved.
Show resolved Hide resolved
from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'entities_linking'".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_linking(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -95,16 +94,15 @@ 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.1':
from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'entities_recognition_general'".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_general(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -145,16 +143,15 @@ def entities_recognition_pii(
:raises: ~azure.core.exceptions.HttpResponseError
"""
api_version = self._get_api_version('entities_recognition_pii')
if api_version == 'v3.1-preview.1':
from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
if api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
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 @@ -187,16 +184,15 @@ 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.1':
from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'key_phrases'".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.key_phrases(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -230,16 +226,15 @@ 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.1':
from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'languages'".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.languages(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -273,15 +268,14 @@ 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.1':
from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'sentiment'".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.sentiment(documents, model_version, show_stats, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ def __init__(
):
if api_version == 'v3.0':
base_url = '{Endpoint}/text/analytics/v3.0'
elif api_version == 'v3.1-preview.1':
base_url = '{Endpoint}/text/analytics/v3.1-preview.1'
elif api_version == 'v3.1-preview.2':
base_url = '{Endpoint}/text/analytics/v3.1-preview.2'
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))
self._config = TextAnalyticsClientConfiguration(credential, endpoint, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
super(TextAnalyticsClient, self).__init__(
Expand All @@ -85,19 +83,15 @@ 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.1: :mod:`v3_1_preview_1.models<azure.ai.textanalytics.v3_1_preview_1.models>`
* v3.1-preview.2: :mod:`v3_1_preview_2.models<azure.ai.textanalytics.v3_1_preview_2.models>`
"""
if api_version == 'v3.0':
from .v3_0 import models
return models
elif api_version == 'v3.1-preview.1':
from .v3_1_preview_1 import models
return models
elif api_version == 'v3.1-preview.2':
from .v3_1_preview_2 import models
return models
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))

def close(self):
self._client.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union
import warnings

from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest

Expand Down Expand Up @@ -48,16 +48,15 @@ async def entities_linking(
api_version = self._get_api_version('entities_linking')
if api_version == 'v3.0':
from ..v3_0.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.1':
from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'entities_linking'".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 await mixin_instance.entities_linking(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -91,16 +90,15 @@ async def entities_recognition_general(
api_version = self._get_api_version('entities_recognition_general')
if api_version == 'v3.0':
from ..v3_0.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.1':
from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'entities_recognition_general'".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 await mixin_instance.entities_recognition_general(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -141,16 +139,15 @@ async def entities_recognition_pii(
:raises: ~azure.core.exceptions.HttpResponseError
"""
api_version = self._get_api_version('entities_recognition_pii')
if api_version == 'v3.1-preview.1':
from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
if api_version == 'v3.1-preview.2':
from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
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 await mixin_instance.entities_recognition_pii(documents, model_version, show_stats, domain, string_index_type, **kwargs)

Expand Down Expand Up @@ -183,16 +180,15 @@ async def key_phrases(
api_version = self._get_api_version('key_phrases')
if api_version == 'v3.0':
from ..v3_0.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.1':
from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'key_phrases'".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 await mixin_instance.key_phrases(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -226,16 +222,15 @@ async def languages(
api_version = self._get_api_version('languages')
if api_version == 'v3.0':
from ..v3_0.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.1':
from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'languages'".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 await mixin_instance.languages(documents, model_version, show_stats, **kwargs)

Expand Down Expand Up @@ -269,15 +264,14 @@ async def sentiment(
api_version = self._get_api_version('sentiment')
if api_version == 'v3.0':
from ..v3_0.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.1':
from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
elif api_version == 'v3.1-preview.2':
from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} does not have operation 'sentiment'".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 await mixin_instance.sentiment(documents, model_version, show_stats, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ def __init__(
) -> None:
if api_version == 'v3.0':
base_url = '{Endpoint}/text/analytics/v3.0'
elif api_version == 'v3.1-preview.1':
base_url = '{Endpoint}/text/analytics/v3.1-preview.1'
elif api_version == 'v3.1-preview.2':
base_url = '{Endpoint}/text/analytics/v3.1-preview.2'
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))
self._config = TextAnalyticsClientConfiguration(credential, endpoint, **kwargs)
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)
super(TextAnalyticsClient, self).__init__(
Expand All @@ -85,19 +83,15 @@ 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.1: :mod:`v3_1_preview_1.models<azure.ai.textanalytics.v3_1_preview_1.models>`
* v3.1-preview.2: :mod:`v3_1_preview_2.models<azure.ai.textanalytics.v3_1_preview_2.models>`
"""
if api_version == 'v3.0':
from ..v3_0 import models
return models
elif api_version == 'v3.1-preview.1':
from ..v3_1_preview_1 import models
return models
elif api_version == 'v3.1-preview.2':
from ..v3_1_preview_2 import models
return models
raise NotImplementedError("APIVersion {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))

async def close(self):
await self._client.close()
Expand Down
Loading