Skip to content

Commit

Permalink
run black on personalizer to fix ci (#29066)
Browse files Browse the repository at this point in the history
* run black on personalizer to fix ci

* run validate_formatting on code
  • Loading branch information
kristapratico authored Mar 1, 2023
1 parent 96e518c commit d7a8529
Show file tree
Hide file tree
Showing 33 changed files with 446 additions and 265 deletions.
2 changes: 1 addition & 1 deletion sdk/personalizer/azure-ai-personalizer/azure/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@
# --------------------------------------------------------------------------
import datetime
import sys
from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload
from typing import (
Any,
Callable,
Dict,
IO,
Iterable,
Iterator,
Optional,
TypeVar,
Union,
cast,
overload,
)
import urllib.parse

from azure.core.exceptions import (
Expand Down Expand Up @@ -66,7 +78,9 @@ def build_personalizer_get_service_configuration_request(**kwargs: Any) -> HttpR
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_personalizer_update_service_configuration_request(**kwargs: Any) -> HttpRequest:
def build_personalizer_update_service_configuration_request(
**kwargs: Any,
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

Expand Down Expand Up @@ -163,7 +177,7 @@ def build_personalizer_get_evaluation_request(
end_time: datetime.datetime,
interval_in_minutes: Optional[int] = None,
window: Optional[str] = None,
**kwargs: Any
**kwargs: Any,
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
Expand Down Expand Up @@ -252,7 +266,11 @@ def build_personalizer_create_evaluation_request(evaluation_id: str, **kwargs: A


def build_personalizer_list_evaluations_request(
*, filter_expression: Optional[str] = None, top: Optional[int] = None, skip: int = 0, **kwargs: Any
*,
filter_expression: Optional[str] = None,
top: Optional[int] = None,
skip: int = 0,
**kwargs: Any,
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
Expand Down Expand Up @@ -553,7 +571,14 @@ def build_personalizer_import_model_request(*, content: IO, **kwargs: Any) -> Ht
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, content=content, **kwargs)
return HttpRequest(
method="PUT",
url=_url,
params=_params,
headers=_headers,
content=content,
**kwargs,
)


def build_personalizer_reset_model_request(**kwargs: Any) -> HttpRequest:
Expand Down Expand Up @@ -1412,7 +1437,7 @@ def get_evaluation(
end_time: datetime.datetime,
interval_in_minutes: Optional[int] = None,
window: Optional[str] = None,
**kwargs: Any
**kwargs: Any,
) -> JSON:
"""Offline Evaluation.
Expand Down Expand Up @@ -1601,7 +1626,12 @@ def delete_evaluation( # pylint: disable=inconsistent-return-statements

@overload
def create_evaluation( # pylint: disable=inconsistent-return-statements
self, evaluation_id: str, evaluation: JSON, *, content_type: str = "application/json", **kwargs: Any
self,
evaluation_id: str,
evaluation: JSON,
*,
content_type: str = "application/json",
**kwargs: Any,
) -> None:
"""Create Offline Evaluation.
Expand Down Expand Up @@ -1642,7 +1672,12 @@ def create_evaluation( # pylint: disable=inconsistent-return-statements

@overload
def create_evaluation( # pylint: disable=inconsistent-return-statements
self, evaluation_id: str, evaluation: IO, *, content_type: str = "application/json", **kwargs: Any
self,
evaluation_id: str,
evaluation: IO,
*,
content_type: str = "application/json",
**kwargs: Any,
) -> None:
"""Create Offline Evaluation.
Expand Down Expand Up @@ -1731,7 +1766,12 @@ def create_evaluation( # pylint: disable=inconsistent-return-statements

@distributed_trace
def list_evaluations(
self, *, filter_expression: Optional[str] = None, top: Optional[int] = None, skip: int = 0, **kwargs: Any
self,
*,
filter_expression: Optional[str] = None,
top: Optional[int] = None,
skip: int = 0,
**kwargs: Any,
) -> Iterable[JSON]:
"""All Offline Evaluations.
Expand Down Expand Up @@ -1797,7 +1837,10 @@ def prepare_request(next_link=None):
)
path_format_arguments = {
"Endpoint": self._serialize.url(
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
"self._config.endpoint",
self._config.endpoint,
"str",
skip_quote=True,
),
}
request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore
Expand All @@ -1813,11 +1856,16 @@ def prepare_request(next_link=None):
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
"GET",
urllib.parse.urljoin(next_link, _parsed_next_link.path),
params=_next_request_params,
)
path_format_arguments = {
"Endpoint": self._serialize.url(
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
"self._config.endpoint",
self._config.endpoint,
"str",
skip_quote=True,
),
}
request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore
Expand All @@ -1840,7 +1888,11 @@ def get_next(next_link=None):
response = pipeline_response.http_response

if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
map_error(
status_code=response.status_code,
response=response,
error_map=error_map,
)
raise HttpResponseError(response=response)

return pipeline_response
Expand All @@ -1849,7 +1901,12 @@ def get_next(next_link=None):

@overload
def reward_single_slot_event( # pylint: disable=inconsistent-return-statements
self, event_id: str, reward: JSON, *, content_type: str = "application/json", **kwargs: Any
self,
event_id: str,
reward: JSON,
*,
content_type: str = "application/json",
**kwargs: Any,
) -> None:
"""Reward.
Expand Down Expand Up @@ -1881,7 +1938,12 @@ def reward_single_slot_event( # pylint: disable=inconsistent-return-statements

@overload
def reward_single_slot_event( # pylint: disable=inconsistent-return-statements
self, event_id: str, reward: IO, *, content_type: str = "application/json", **kwargs: Any
self,
event_id: str,
reward: IO,
*,
content_type: str = "application/json",
**kwargs: Any,
) -> None:
"""Reward.
Expand Down Expand Up @@ -2277,7 +2339,7 @@ def create_feature_importance( # pylint: disable=inconsistent-return-statements
feature_importance: JSON,
*,
content_type: str = "application/json",
**kwargs: Any
**kwargs: Any,
) -> None:
"""Create Feature Importance.
Expand Down Expand Up @@ -2314,7 +2376,7 @@ def create_feature_importance( # pylint: disable=inconsistent-return-statements
feature_importance: IO,
*,
content_type: str = "application/json",
**kwargs: Any
**kwargs: Any,
) -> None:
"""Create Feature Importance.
Expand All @@ -2334,7 +2396,10 @@ def create_feature_importance( # pylint: disable=inconsistent-return-statements

@distributed_trace
def create_feature_importance( # pylint: disable=inconsistent-return-statements
self, feature_importance_id: str, feature_importance: Union[JSON, IO], **kwargs: Any
self,
feature_importance_id: str,
feature_importance: Union[JSON, IO],
**kwargs: Any,
) -> None:
"""Create Feature Importance.
Expand Down Expand Up @@ -2457,7 +2522,10 @@ def prepare_request(next_link=None):
)
path_format_arguments = {
"Endpoint": self._serialize.url(
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
"self._config.endpoint",
self._config.endpoint,
"str",
skip_quote=True,
),
}
request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore
Expand All @@ -2473,11 +2541,16 @@ def prepare_request(next_link=None):
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
"GET",
urllib.parse.urljoin(next_link, _parsed_next_link.path),
params=_next_request_params,
)
path_format_arguments = {
"Endpoint": self._serialize.url(
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
"self._config.endpoint",
self._config.endpoint,
"str",
skip_quote=True,
),
}
request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore
Expand All @@ -2500,7 +2573,11 @@ def get_next(next_link=None):
response = pipeline_response.http_response

if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
map_error(
status_code=response.status_code,
response=response,
error_map=error_map,
)
raise HttpResponseError(response=response)

return pipeline_response
Expand Down Expand Up @@ -2836,7 +2913,12 @@ def get_model_properties(self, **kwargs: Any) -> JSON:

@overload
def reward_multi_slot_event( # pylint: disable=inconsistent-return-statements
self, event_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
self,
event_id: str,
body: JSON,
*,
content_type: str = "application/json",
**kwargs: Any,
) -> None:
"""Reward (MultiSlot).
Expand Down Expand Up @@ -2872,7 +2954,12 @@ def reward_multi_slot_event( # pylint: disable=inconsistent-return-statements

@overload
def reward_multi_slot_event( # pylint: disable=inconsistent-return-statements
self, event_id: str, body: IO, *, content_type: str = "application/json", **kwargs: Any
self,
event_id: str,
body: IO,
*,
content_type: str = "application/json",
**kwargs: Any,
) -> None:
"""Reward (MultiSlot).
Expand Down Expand Up @@ -3221,7 +3308,13 @@ def rank_multi_slot(self, body: Union[JSON, IO], **kwargs: Any) -> JSON:
return cast(JSON, deserialized)

@overload
def rank_single_slot(self, rank_request: JSON, *, content_type: str = "application/json", **kwargs: Any) -> JSON:
def rank_single_slot(
self,
rank_request: JSON,
*,
content_type: str = "application/json",
**kwargs: Any,
) -> JSON:
"""Rank.
Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import sys
from typing import List, Union, Any, IO, Iterator, Iterable, Optional
from azure.core.credentials import AzureKeyCredential, TokenCredential
from azure.core.pipeline.policies import AzureKeyCredentialPolicy, BearerTokenCredentialPolicy
from azure.core.pipeline.policies import (
AzureKeyCredentialPolicy,
BearerTokenCredentialPolicy,
)
from azure.core.tracing.decorator import distributed_trace
from azure.core.rest import HttpRequest, HttpResponse

Expand Down Expand Up @@ -47,6 +50,7 @@ def _authentication_policy(credential, **kwargs):
)
return authentication_policy


class PersonalizerAdministrationClient: # pylint: disable=too-many-public-methods
"""This client contains the operations that apply to Azure Personalizer. Operations allowed by the client are
viewing and editing the properties, policy, model, running evaluations.
Expand Down
Loading

0 comments on commit d7a8529

Please sign in to comment.