зеркало из
1
0
Форкнуть 0

[Cognitive Services] vision post-deprecation (#38304)

* [Cognitive Services] vision post-deprecation

* black on active cs packages
This commit is contained in:
swathipil 2024-11-05 01:00:36 -06:00 коммит произвёл GitHub
Родитель 37edc7b936
Коммит a8ce88a244
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
32 изменённых файлов: 246 добавлений и 240 удалений

Просмотреть файл

@ -12,7 +12,6 @@
from .personalizer_client import PersonalizerClient
from .version import VERSION
__all__ = ['PersonalizerClient']
__all__ = ["PersonalizerClient"]
__version__ = VERSION

Просмотреть файл

@ -32,13 +32,14 @@ from .personalizer_client_enums import (
)
__all__ = [
'InternalError',
'PersonalizerError',
'ErrorResponse', 'ErrorResponseException',
'RewardRequest',
'RankableAction',
'RankRequest',
'RankedAction',
'RankResponse',
'ErrorCode',
"InternalError",
"PersonalizerError",
"ErrorResponse",
"ErrorResponseException",
"RewardRequest",
"RankableAction",
"RankRequest",
"RankedAction",
"RankResponse",
"ErrorCode",
]

Просмотреть файл

@ -24,16 +24,16 @@ class ErrorResponse(Model):
"""
_validation = {
'error': {'required': True},
"error": {"required": True},
}
_attribute_map = {
'error': {'key': 'error', 'type': 'PersonalizerError'},
"error": {"key": "error", "type": "PersonalizerError"},
}
def __init__(self, **kwargs):
super(ErrorResponse, self).__init__(**kwargs)
self.error = kwargs.get('error', None)
self.error = kwargs.get("error", None)
class ErrorResponseException(HttpOperationError):
@ -45,4 +45,4 @@ class ErrorResponseException(HttpOperationError):
def __init__(self, deserialize, response, *args):
super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args)
super(ErrorResponseException, self).__init__(deserialize, response, "ErrorResponse", *args)

Просмотреть файл

@ -24,11 +24,11 @@ class ErrorResponse(Model):
"""
_validation = {
'error': {'required': True},
"error": {"required": True},
}
_attribute_map = {
'error': {'key': 'error', 'type': 'PersonalizerError'},
"error": {"key": "error", "type": "PersonalizerError"},
}
def __init__(self, *, error, **kwargs) -> None:
@ -45,4 +45,4 @@ class ErrorResponseException(HttpOperationError):
def __init__(self, deserialize, response, *args):
super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args)
super(ErrorResponseException, self).__init__(deserialize, response, "ErrorResponse", *args)

Просмотреть файл

@ -24,11 +24,11 @@ class InternalError(Model):
"""
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'innererror': {'key': 'innererror', 'type': 'InternalError'},
"code": {"key": "code", "type": "str"},
"innererror": {"key": "innererror", "type": "InternalError"},
}
def __init__(self, **kwargs):
super(InternalError, self).__init__(**kwargs)
self.code = kwargs.get('code', None)
self.innererror = kwargs.get('innererror', None)
self.code = kwargs.get("code", None)
self.innererror = kwargs.get("innererror", None)

Просмотреть файл

@ -24,11 +24,11 @@ class InternalError(Model):
"""
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'innererror': {'key': 'innererror', 'type': 'InternalError'},
"code": {"key": "code", "type": "str"},
"innererror": {"key": "innererror", "type": "InternalError"},
}
def __init__(self, *, code: str=None, innererror=None, **kwargs) -> None:
def __init__(self, *, code: str = None, innererror=None, **kwargs) -> None:
super(InternalError, self).__init__(**kwargs)
self.code = code
self.innererror = innererror

Просмотреть файл

@ -35,22 +35,22 @@ class PersonalizerError(Model):
"""
_validation = {
'code': {'required': True},
'message': {'required': True},
"code": {"required": True},
"message": {"required": True},
}
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[PersonalizerError]'},
'inner_error': {'key': 'innerError', 'type': 'InternalError'},
"code": {"key": "code", "type": "str"},
"message": {"key": "message", "type": "str"},
"target": {"key": "target", "type": "str"},
"details": {"key": "details", "type": "[PersonalizerError]"},
"inner_error": {"key": "innerError", "type": "InternalError"},
}
def __init__(self, **kwargs):
super(PersonalizerError, self).__init__(**kwargs)
self.code = kwargs.get('code', None)
self.message = kwargs.get('message', None)
self.target = kwargs.get('target', None)
self.details = kwargs.get('details', None)
self.inner_error = kwargs.get('inner_error', None)
self.code = kwargs.get("code", None)
self.message = kwargs.get("message", None)
self.target = kwargs.get("target", None)
self.details = kwargs.get("details", None)
self.inner_error = kwargs.get("inner_error", None)

Просмотреть файл

@ -35,19 +35,19 @@ class PersonalizerError(Model):
"""
_validation = {
'code': {'required': True},
'message': {'required': True},
"code": {"required": True},
"message": {"required": True},
}
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[PersonalizerError]'},
'inner_error': {'key': 'innerError', 'type': 'InternalError'},
"code": {"key": "code", "type": "str"},
"message": {"key": "message", "type": "str"},
"target": {"key": "target", "type": "str"},
"details": {"key": "details", "type": "[PersonalizerError]"},
"inner_error": {"key": "innerError", "type": "InternalError"},
}
def __init__(self, *, code, message: str, target: str=None, details=None, inner_error=None, **kwargs) -> None:
def __init__(self, *, code, message: str, target: str = None, details=None, inner_error=None, **kwargs) -> None:
super(PersonalizerError, self).__init__(**kwargs)
self.code = code
self.message = message

Просмотреть файл

@ -53,22 +53,22 @@ class RankRequest(Model):
"""
_validation = {
'actions': {'required': True},
'event_id': {'max_length': 256},
"actions": {"required": True},
"event_id": {"max_length": 256},
}
_attribute_map = {
'context_features': {'key': 'contextFeatures', 'type': '[object]'},
'actions': {'key': 'actions', 'type': '[RankableAction]'},
'excluded_actions': {'key': 'excludedActions', 'type': '[str]'},
'event_id': {'key': 'eventId', 'type': 'str'},
'defer_activation': {'key': 'deferActivation', 'type': 'bool'},
"context_features": {"key": "contextFeatures", "type": "[object]"},
"actions": {"key": "actions", "type": "[RankableAction]"},
"excluded_actions": {"key": "excludedActions", "type": "[str]"},
"event_id": {"key": "eventId", "type": "str"},
"defer_activation": {"key": "deferActivation", "type": "bool"},
}
def __init__(self, **kwargs):
super(RankRequest, self).__init__(**kwargs)
self.context_features = kwargs.get('context_features', None)
self.actions = kwargs.get('actions', None)
self.excluded_actions = kwargs.get('excluded_actions', None)
self.event_id = kwargs.get('event_id', None)
self.defer_activation = kwargs.get('defer_activation', False)
self.context_features = kwargs.get("context_features", None)
self.actions = kwargs.get("actions", None)
self.excluded_actions = kwargs.get("excluded_actions", None)
self.event_id = kwargs.get("event_id", None)
self.defer_activation = kwargs.get("defer_activation", False)

Просмотреть файл

@ -53,19 +53,28 @@ class RankRequest(Model):
"""
_validation = {
'actions': {'required': True},
'event_id': {'max_length': 256},
"actions": {"required": True},
"event_id": {"max_length": 256},
}
_attribute_map = {
'context_features': {'key': 'contextFeatures', 'type': '[object]'},
'actions': {'key': 'actions', 'type': '[RankableAction]'},
'excluded_actions': {'key': 'excludedActions', 'type': '[str]'},
'event_id': {'key': 'eventId', 'type': 'str'},
'defer_activation': {'key': 'deferActivation', 'type': 'bool'},
"context_features": {"key": "contextFeatures", "type": "[object]"},
"actions": {"key": "actions", "type": "[RankableAction]"},
"excluded_actions": {"key": "excludedActions", "type": "[str]"},
"event_id": {"key": "eventId", "type": "str"},
"defer_activation": {"key": "deferActivation", "type": "bool"},
}
def __init__(self, *, actions, context_features=None, excluded_actions=None, event_id: str=None, defer_activation: bool=False, **kwargs) -> None:
def __init__(
self,
*,
actions,
context_features=None,
excluded_actions=None,
event_id: str = None,
defer_activation: bool = False,
**kwargs
) -> None:
super(RankRequest, self).__init__(**kwargs)
self.context_features = context_features
self.actions = actions

Просмотреть файл

@ -31,15 +31,15 @@ class RankResponse(Model):
"""
_validation = {
'ranking': {'readonly': True},
'event_id': {'readonly': True, 'max_length': 256},
'reward_action_id': {'readonly': True, 'max_length': 256},
"ranking": {"readonly": True},
"event_id": {"readonly": True, "max_length": 256},
"reward_action_id": {"readonly": True, "max_length": 256},
}
_attribute_map = {
'ranking': {'key': 'ranking', 'type': '[RankedAction]'},
'event_id': {'key': 'eventId', 'type': 'str'},
'reward_action_id': {'key': 'rewardActionId', 'type': 'str'},
"ranking": {"key": "ranking", "type": "[RankedAction]"},
"event_id": {"key": "eventId", "type": "str"},
"reward_action_id": {"key": "rewardActionId", "type": "str"},
}
def __init__(self, **kwargs):

Просмотреть файл

@ -31,15 +31,15 @@ class RankResponse(Model):
"""
_validation = {
'ranking': {'readonly': True},
'event_id': {'readonly': True, 'max_length': 256},
'reward_action_id': {'readonly': True, 'max_length': 256},
"ranking": {"readonly": True},
"event_id": {"readonly": True, "max_length": 256},
"reward_action_id": {"readonly": True, "max_length": 256},
}
_attribute_map = {
'ranking': {'key': 'ranking', 'type': '[RankedAction]'},
'event_id': {'key': 'eventId', 'type': 'str'},
'reward_action_id': {'key': 'rewardActionId', 'type': 'str'},
"ranking": {"key": "ranking", "type": "[RankedAction]"},
"event_id": {"key": "eventId", "type": "str"},
"reward_action_id": {"key": "rewardActionId", "type": "str"},
}
def __init__(self, **kwargs) -> None:

Просмотреть файл

@ -24,16 +24,16 @@ class RankableAction(Model):
"""
_validation = {
'id': {'required': True, 'max_length': 256},
'features': {'required': True},
"id": {"required": True, "max_length": 256},
"features": {"required": True},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'features': {'key': 'features', 'type': '[object]'},
"id": {"key": "id", "type": "str"},
"features": {"key": "features", "type": "[object]"},
}
def __init__(self, **kwargs):
super(RankableAction, self).__init__(**kwargs)
self.id = kwargs.get('id', None)
self.features = kwargs.get('features', None)
self.id = kwargs.get("id", None)
self.features = kwargs.get("features", None)

Просмотреть файл

@ -24,13 +24,13 @@ class RankableAction(Model):
"""
_validation = {
'id': {'required': True, 'max_length': 256},
'features': {'required': True},
"id": {"required": True, "max_length": 256},
"features": {"required": True},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'features': {'key': 'features', 'type': '[object]'},
"id": {"key": "id", "type": "str"},
"features": {"key": "features", "type": "[object]"},
}
def __init__(self, *, id: str, features, **kwargs) -> None:

Просмотреть файл

@ -25,13 +25,13 @@ class RankedAction(Model):
"""
_validation = {
'id': {'readonly': True, 'max_length': 256},
'probability': {'readonly': True, 'maximum': 1, 'minimum': 0},
"id": {"readonly": True, "max_length": 256},
"probability": {"readonly": True, "maximum": 1, "minimum": 0},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'probability': {'key': 'probability', 'type': 'float'},
"id": {"key": "id", "type": "str"},
"probability": {"key": "probability", "type": "float"},
}
def __init__(self, **kwargs):

Просмотреть файл

@ -25,13 +25,13 @@ class RankedAction(Model):
"""
_validation = {
'id': {'readonly': True, 'max_length': 256},
'probability': {'readonly': True, 'maximum': 1, 'minimum': 0},
"id": {"readonly": True, "max_length": 256},
"probability": {"readonly": True, "maximum": 1, "minimum": 0},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'probability': {'key': 'probability', 'type': 'float'},
"id": {"key": "id", "type": "str"},
"probability": {"key": "probability", "type": "float"},
}
def __init__(self, **kwargs) -> None:

Просмотреть файл

@ -23,13 +23,13 @@ class RewardRequest(Model):
"""
_validation = {
'value': {'required': True},
"value": {"required": True},
}
_attribute_map = {
'value': {'key': 'value', 'type': 'float'},
"value": {"key": "value", "type": "float"},
}
def __init__(self, **kwargs):
super(RewardRequest, self).__init__(**kwargs)
self.value = kwargs.get('value', None)
self.value = kwargs.get("value", None)

Просмотреть файл

@ -23,11 +23,11 @@ class RewardRequest(Model):
"""
_validation = {
'value': {'required': True},
"value": {"required": True},
}
_attribute_map = {
'value': {'key': 'value', 'type': 'float'},
"value": {"key": "value", "type": "float"},
}
def __init__(self, *, value: float, **kwargs) -> None:

Просмотреть файл

@ -12,5 +12,5 @@
from .events_operations import EventsOperations
__all__ = [
'EventsOperations',
"EventsOperations",
]

Просмотреть файл

@ -34,8 +34,7 @@ class EventsOperations(object):
self.config = config
def reward(
self, event_id, value, custom_headers=None, raw=False, **operation_config):
def reward(self, event_id, value, custom_headers=None, raw=False, **operation_config):
"""Report reward to allocate to the top ranked action for the specified
event.
@ -57,10 +56,10 @@ class EventsOperations(object):
reward1 = models.RewardRequest(value=value)
# Construct URL
url = self.reward.metadata['url']
url = self.reward.metadata["url"]
path_format_arguments = {
'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
'eventId': self._serialize.url("event_id", event_id, 'str', max_length=256)
"Endpoint": self._serialize.url("self.config.endpoint", self.config.endpoint, "str", skip_quote=True),
"eventId": self._serialize.url("event_id", event_id, "str", max_length=256),
}
url = self._client.format_url(url, **path_format_arguments)
@ -69,12 +68,12 @@ class EventsOperations(object):
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
header_parameters["Content-Type"] = "application/json; charset=utf-8"
if custom_headers:
header_parameters.update(custom_headers)
# Construct body
body_content = self._serialize.body(reward1, 'RewardRequest')
body_content = self._serialize.body(reward1, "RewardRequest")
# Construct and send request
request = self._client.post(url, query_parameters, header_parameters, body_content)
@ -86,10 +85,10 @@ class EventsOperations(object):
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
reward.metadata = {'url': '/events/{eventId}/reward'}
def activate(
self, event_id, custom_headers=None, raw=False, **operation_config):
reward.metadata = {"url": "/events/{eventId}/reward"}
def activate(self, event_id, custom_headers=None, raw=False, **operation_config):
"""Report that the specified event was actually displayed to the user and
a reward should be expected for it.
@ -106,10 +105,10 @@ class EventsOperations(object):
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
"""
# Construct URL
url = self.activate.metadata['url']
url = self.activate.metadata["url"]
path_format_arguments = {
'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
'eventId': self._serialize.url("event_id", event_id, 'str', max_length=256)
"Endpoint": self._serialize.url("self.config.endpoint", self.config.endpoint, "str", skip_quote=True),
"eventId": self._serialize.url("event_id", event_id, "str", max_length=256),
}
url = self._client.format_url(url, **path_format_arguments)
@ -131,4 +130,5 @@ class EventsOperations(object):
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
activate.metadata = {'url': '/events/{eventId}/activate'}
activate.metadata = {"url": "/events/{eventId}/activate"}

Просмотреть файл

@ -30,18 +30,17 @@ class PersonalizerClientConfiguration(Configuration):
:type credentials: None
"""
def __init__(
self, endpoint, credentials):
def __init__(self, endpoint, credentials):
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
base_url = '{Endpoint}/personalizer/v1.0'
base_url = "{Endpoint}/personalizer/v1.0"
super(PersonalizerClientConfiguration, self).__init__(base_url)
self.add_user_agent('azure-cognitiveservices-personalizer/{}'.format(VERSION))
self.add_user_agent("azure-cognitiveservices-personalizer/{}".format(VERSION))
self.endpoint = endpoint
self.credentials = credentials
@ -63,22 +62,19 @@ class PersonalizerClient(SDKClient):
:type credentials: None
"""
def __init__(
self, endpoint, credentials):
def __init__(self, endpoint, credentials):
self.config = PersonalizerClientConfiguration(endpoint, credentials)
super(PersonalizerClient, self).__init__(self.config.credentials, self.config)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = 'v1.0'
self.api_version = "v1.0"
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self.events = EventsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.events = EventsOperations(self._client, self.config, self._serialize, self._deserialize)
def rank(
self, rank_request, custom_headers=None, raw=False, **operation_config):
def rank(self, rank_request, custom_headers=None, raw=False, **operation_config):
"""A Personalizer rank request.
:param rank_request: A Personalizer request.
@ -96,9 +92,9 @@ class PersonalizerClient(SDKClient):
:class:`ErrorResponseException<azure.cognitiveservices.personalizer.models.ErrorResponseException>`
"""
# Construct URL
url = self.rank.metadata['url']
url = self.rank.metadata["url"]
path_format_arguments = {
'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True)
"Endpoint": self._serialize.url("self.config.endpoint", self.config.endpoint, "str", skip_quote=True)
}
url = self._client.format_url(url, **path_format_arguments)
@ -107,13 +103,13 @@ class PersonalizerClient(SDKClient):
# Construct headers
header_parameters = {}
header_parameters['Accept'] = 'application/json'
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
header_parameters["Accept"] = "application/json"
header_parameters["Content-Type"] = "application/json; charset=utf-8"
if custom_headers:
header_parameters.update(custom_headers)
# Construct body
body_content = self._serialize.body(rank_request, 'RankRequest')
body_content = self._serialize.body(rank_request, "RankRequest")
# Construct and send request
request = self._client.post(url, query_parameters, header_parameters, body_content)
@ -125,11 +121,12 @@ class PersonalizerClient(SDKClient):
deserialized = None
if response.status_code == 201:
deserialized = self._deserialize('RankResponse', response)
deserialized = self._deserialize("RankResponse", response)
if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response
return deserialized
rank.metadata = {'url': '/rank'}
rank.metadata = {"url": "/rank"}

Просмотреть файл

@ -10,4 +10,3 @@
# --------------------------------------------------------------------------
VERSION = "0.1.0"

Просмотреть файл

@ -1,10 +1,10 @@
#!/usr/bin/env python
#-------------------------------------------------------------------------
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------
# --------------------------------------------------------------------------
import re
import os.path
@ -16,19 +16,19 @@ PACKAGE_NAME = "azure-cognitiveservices-personalizer"
PACKAGE_PPRINT_NAME = "Personalizer"
# a-b-c => a/b/c
package_folder_path = PACKAGE_NAME.replace('-', '/')
package_folder_path = PACKAGE_NAME.replace("-", "/")
# a-b-c => a.b.c
namespace_name = PACKAGE_NAME.replace('-', '.')
namespace_name = PACKAGE_NAME.replace("-", ".")
# azure v0.x is not compatible with this package
# azure v0.x used to have a __version__ attribute (newer versions don't)
try:
import azure
try:
ver = azure.__version__
raise Exception(
'This package is incompatible with azure=={}. '.format(ver) +
'Uninstall it with "pip uninstall azure".'
"This package is incompatible with azure=={}. ".format(ver) + 'Uninstall it with "pip uninstall azure".'
)
except AttributeError:
pass
@ -36,61 +36,67 @@ except ImportError:
pass
# Version extraction inspired from 'requests'
with open(os.path.join(package_folder_path, 'version.py')
if os.path.exists(os.path.join(package_folder_path, 'version.py'))
else os.path.join(package_folder_path, '_version.py'), 'r') as fd:
version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]',
fd.read(), re.MULTILINE).group(1)
with open(
(
os.path.join(package_folder_path, "version.py")
if os.path.exists(os.path.join(package_folder_path, "version.py"))
else os.path.join(package_folder_path, "_version.py")
),
"r",
) as fd:
version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1)
if not version:
raise RuntimeError('Cannot find version information')
raise RuntimeError("Cannot find version information")
with open('README.md', encoding='utf-8') as f:
with open("README.md", encoding="utf-8") as f:
readme = f.read()
with open('CHANGELOG.md', encoding='utf-8') as f:
with open("CHANGELOG.md", encoding="utf-8") as f:
changelog = f.read()
setup(
name=PACKAGE_NAME,
version=version,
description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME),
long_description=readme + '\n\n' + changelog,
long_description_content_type='text/markdown',
license='MIT License',
author='Microsoft Corporation',
author_email='azpysdkhelp@microsoft.com',
url='https://github.com/Azure/azure-sdk-for-python',
description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME),
long_description=readme + "\n\n" + changelog,
long_description_content_type="text/markdown",
license="MIT License",
author="Microsoft Corporation",
author_email="azpysdkhelp@microsoft.com",
url="https://github.com/Azure/azure-sdk-for-python",
keywords="azure, azure sdk",
classifiers=[
'Development Status :: 4 - Beta',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'License :: OSI Approved :: MIT License',
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: MIT License",
],
zip_safe=False,
packages=find_packages(exclude=[
'tests',
# Exclude packages that will be covered by PEP420 or nspkg
'azure',
'azure.cognitiveservices',
]),
packages=find_packages(
exclude=[
"tests",
# Exclude packages that will be covered by PEP420 or nspkg
"azure",
"azure.cognitiveservices",
]
),
include_package_data=True,
package_data={
'pytyped': ['py.typed'],
"pytyped": ["py.typed"],
},
install_requires=[
'msrest>=0.6.21',
'azure-common~=1.1',
'azure-mgmt-core>=1.2.0,<2.0.0',
"msrest>=0.6.21",
"azure-common~=1.1",
"azure-mgmt-core>=1.2.0,<2.0.0",
],
extras_require={
":python_version<'3.0'": ['azure-cognitiveservices-nspkg'],
}
":python_version<'3.0'": ["azure-cognitiveservices-nspkg"],
},
)

Просмотреть файл

@ -1,2 +1,3 @@
[tool.azure-sdk-build]
pylint = false
ci_enabled = false

Просмотреть файл

@ -1,2 +1,3 @@
[tool.azure-sdk-build]
pylint = false
ci_enabled = false

Просмотреть файл

@ -1,2 +1,3 @@
[tool.azure-sdk-build]
pylint = false
ci_enabled = false

Просмотреть файл

@ -1,2 +1,3 @@
[tool.azure-sdk-build]
pylint = false
ci_enabled = false

Просмотреть файл

@ -25,6 +25,7 @@
#
# --------------------------------------------------------------------------
# This file is used for handwritten extensions to the generated code. Example:
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
def patch_sdk():

Просмотреть файл

@ -25,6 +25,7 @@
#
# --------------------------------------------------------------------------
# This file is used for handwritten extensions to the generated code. Example:
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
def patch_sdk():

Просмотреть файл

@ -22,9 +22,11 @@ namespace_name = PACKAGE_NAME.replace("-", ".")
# Version extraction inspired from 'requests'
with open(
os.path.join(package_folder_path, "version.py")
if os.path.exists(os.path.join(package_folder_path, "version.py"))
else os.path.join(package_folder_path, "_version.py"),
(
os.path.join(package_folder_path, "version.py")
if os.path.exists(os.path.join(package_folder_path, "version.py"))
else os.path.join(package_folder_path, "_version.py")
),
"r",
) as fd:
version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1)

Просмотреть файл

@ -1,10 +1,10 @@
# coding: utf-8
#-------------------------------------------------------------------------
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------
# --------------------------------------------------------------------------
# TEST SCENARIO COVERAGE
@ -21,17 +21,16 @@ import unittest
import azure.mgmt.cognitiveservices
from devtools_testutils import AzureMgmtTestCase, ResourceGroupPreparer
AZURE_LOCATION = 'eastus'
AZURE_LOCATION = "eastus"
class MgmtCognitiveServicesTest(AzureMgmtTestCase):
def setUp(self):
super(MgmtCognitiveServicesTest, self).setUp()
self.mgmt_client = self.create_mgmt_client(
azure.mgmt.cognitiveservices.CognitiveServicesManagementClient
)
@unittest.skip('hard to test')
self.mgmt_client = self.create_mgmt_client(azure.mgmt.cognitiveservices.CognitiveServicesManagementClient)
@unittest.skip("hard to test")
@ResourceGroupPreparer(location=AZURE_LOCATION)
def test_cognitiveservices(self, resource_group):
@ -42,42 +41,40 @@ class MgmtCognitiveServicesTest(AzureMgmtTestCase):
# /Accounts/put/Create Account Min[put]
BODY = {
"location": "West US",
"kind": "CognitiveServices",
"sku": {
"name": "S0"
},
"identity": {
"type": "SystemAssigned"
}
"location": "West US",
"kind": "CognitiveServices",
"sku": {"name": "S0"},
"identity": {"type": "SystemAssigned"},
}
result = self.mgmt_client.accounts.create(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, account=BODY)
result = self.mgmt_client.accounts.create(
resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, account=BODY
)
# /Accounts/put/Create Account[put]
BODY = {
"location": "West US",
"kind": "Emotion",
"sku": {
"name": "S0"
},
"properties": {
"encryption": {
"key_vault_properties": {
"key_name": "KeyName",
"key_version": "891CF236-D241-4738-9462-D506AF493DFA",
"key_vault_uri": "https://pltfrmscrts-use-pc-dev.vault.azure.net/"
},
"key_source": "Microsoft.KeyVault"
"location": "West US",
"kind": "Emotion",
"sku": {"name": "S0"},
"properties": {
"encryption": {
"key_vault_properties": {
"key_name": "KeyName",
"key_version": "891CF236-D241-4738-9462-D506AF493DFA",
"key_vault_uri": "https://pltfrmscrts-use-pc-dev.vault.azure.net/",
},
"key_source": "Microsoft.KeyVault",
},
"user_owned_storage": [
{
"resource_id": "/subscriptions/"
+ SUBSCRIPTION_ID
+ "/resourceGroups/"
+ RESOURCE_GROUP
+ "/providers/Microsoft.Storage/storageAccountsfelixwatest"
}
],
},
"user_owned_storage": [
{
"resource_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Storage/storageAccountsfelixwatest"
}
]
},
"identity": {
"type": "SystemAssigned"
}
"identity": {"type": "SystemAssigned"},
}
# result = self.mgmt_client.accounts.create(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, account=BODY)
@ -103,29 +100,27 @@ class MgmtCognitiveServicesTest(AzureMgmtTestCase):
result = self.mgmt_client.operations.list()
# /Accounts/post/Regenerate Keys[post]
result = self.mgmt_client.accounts.regenerate_key(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, key_name="Key2")
result = self.mgmt_client.accounts.regenerate_key(
resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, key_name="Key2"
)
# /Accounts/post/List Keys[post]
result = self.mgmt_client.accounts.list_keys(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME)
# /Accounts/patch/Update Account[patch]
BODY = {
"sku": {
"name": "S2"
}
}
BODY = {"sku": {"name": "S2"}}
# result = self.mgmt_client.accounts.update(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, account=BODY)
# //post/Check SKU Availability[post]
SKUS = [
"S0"
]
result = self.mgmt_client.check_sku_availability(location="eastus", skus=SKUS, kind="Face", type="Microsoft.CognitiveServices/accounts")
SKUS = ["S0"]
result = self.mgmt_client.check_sku_availability(
location="eastus", skus=SKUS, kind="Face", type="Microsoft.CognitiveServices/accounts"
)
# /Accounts/delete/Delete Account[delete]
result = self.mgmt_client.accounts.delete(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME)
#------------------------------------------------------------------------------
if __name__ == '__main__':
# ------------------------------------------------------------------------------
if __name__ == "__main__":
unittest.main()

Просмотреть файл

@ -31,13 +31,5 @@ extends:
Artifacts:
- name: azure-cognitiveservices-personalizer
safeName: azurecognitiveservicespersonalizer
- name: azure-cognitiveservices-vision-computervision
safeName: azurecognitiveservicesvisioncomputervision
- name: azure-cognitiveservices-vision-contentmoderator
safeName: azurecognitiveservicesvisioncontentmoderator
- name: azure-cognitiveservices-vision-customvision
safeName: azurecognitiveservicesvisioncustomvision
- name: azure-cognitiveservices-vision-face
safeName: azurecognitiveservicesvisionface
- name: azure-mgmt-cognitiveservices
safeName: azuremgmtcognitiveservices