Skip to content

Commit 5a6d2bb

Browse files
catalinaperaltaXingyu-Yuechanglong-liumsyycjr-MS
authored
[AnomalyDetector] Generate Python SDK from CADL spec (Azure#27516)
* add generated code * add skip_quote for operations * import models for _client.py and _configuration.py * update aio _client.py and _configuration.py to import models * update generated code with latest python dpg * [xingyuyue/cadl] update anomaly detector sample code (Azure#27694) * fix * fix by module * [xingyuyue/cadl] update anomaly detector sample code Co-authored-by: Changlong Liu <[email protected]> * black samples/ -l 120 * [xingyuyue/cadl] add test code (Azure#27699) * [xingyuyue/cadl] add test code * [xingyuyue/cadl] black codes * [xingyuyue/cadl] update test records * [xingyuyue/cadl] update test records * Update ci.yml * Update CHANGELOG.md * update changelog * update with latest cadl (Azure#27814) * Xingyuyue/cadl (Azure#27836) * [xingyuyue/cadl] update sdk sample code * [xingyuyue/cadl] update test code and recordings * Update README.md * Update README.md * [xingyuyue/cadl] add multi_ad list model test (Azure#27845) Co-authored-by: The All-Knowing Yue <[email protected]> Co-authored-by: Changlong Liu <[email protected]> Co-authored-by: msyyc <[email protected]> Co-authored-by: Yuchao Yan <[email protected]> Co-authored-by: jr-MS <[email protected]>
1 parent c86892a commit 5a6d2bb

31 files changed

+4590
-3957
lines changed

sdk/anomalydetector/azure-ai-anomalydetector/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release History
22

3-
## 3.0.0b6 (2022-12-01)
3+
## 3.0.0b6 (2022-12-06)
44
**Features**
55
- Added `OneTable` and `MultiTable` two data schemas.
66
- Added `topContributorCount` in `detect_multivariate_last_anomaly` and `detect_multivariate_batch_anomaly`.

sdk/anomalydetector/azure-ai-anomalydetector/README.md

Lines changed: 97 additions & 79 deletions
Large diffs are not rendered by default.

sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# Licensed under the MIT License. See License.txt in the project root for license information.
5-
# Code generated by Microsoft (R) AutoRest Code Generator.
5+
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

@@ -13,7 +13,7 @@
1313

1414
try:
1515
from ._patch import __all__ as _patch_all
16-
from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
16+
from ._patch import * # pylint: disable=unused-wildcard-import
1717
except ImportError:
1818
_patch_all = []
1919
from ._patch import patch_sdk as _patch_sdk

sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_client.py

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# Licensed under the MIT License. See License.txt in the project root for license information.
5-
# Code generated by Microsoft (R) AutoRest Code Generator.
5+
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

99
from copy import deepcopy
10-
import sys
1110
from typing import Any
1211

1312
from azure.core import PipelineClient
@@ -18,27 +17,24 @@
1817
from ._operations import AnomalyDetectorClientOperationsMixin
1918
from ._serialization import Deserializer, Serializer
2019

21-
if sys.version_info >= (3, 8):
22-
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
23-
else:
24-
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
25-
2620

2721
class AnomalyDetectorClient(AnomalyDetectorClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
28-
"""The Anomaly Detector API detects anomalies automatically in time series data. It supports two
29-
kinds of mode, one is for stateless using, another is for stateful using. In stateless mode,
30-
there are three functionalities. Entire Detect is for detecting the whole series with model
31-
trained by the time series, Last Detect is detecting last point with model trained by points
32-
before. ChangePoint Detect is for detecting trend changes in time series. In stateful mode,
33-
user can store time series, the stored time series will be used for detection anomalies. Under
34-
this mode, user can still use the above three functionalities by only giving a time range
35-
without preparing time series in client side. Besides the above three functionalities, stateful
36-
model also provide group based detection and labeling service. By leveraging labeling service
37-
user can provide labels for each detection result, these labels will be used for retuning or
38-
regenerating detection models. Inconsistency detection is a kind of group based detection, this
39-
detection will find inconsistency ones in a set of time series. By using anomaly detector
40-
service, business customers can discover incidents and establish a logic flow for root cause
41-
analysis.
22+
"""The Anomaly Detector API detects anomalies automatically in time series data.
23+
It supports two kinds of mode, one is for stateless using, another is for
24+
stateful using. In stateless mode, there are three functionalities. Entire
25+
Detect is for detecting the whole series with model trained by the time series,
26+
Last Detect is detecting last point with model trained by points before.
27+
ChangePoint Detect is for detecting trend changes in time series. In stateful
28+
mode, user can store time series, the stored time series will be used for
29+
detection anomalies. Under this mode, user can still use the above three
30+
functionalities by only giving a time range without preparing time series in
31+
client side. Besides the above three functionalities, stateful model also
32+
provide group based detection and labeling service. By leveraging labeling
33+
service user can provide labels for each detection result, these labels will be
34+
used for retuning or regenerating detection models. Inconsistency detection is
35+
a kind of group based detection, this detection will find inconsistency ones in
36+
a set of time series. By using anomaly detector service, business customers can
37+
discover incidents and establish a logic flow for root cause analysis.
4238
4339
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
4440
https://westus2.api.cognitive.microsoft.com). Required.
@@ -80,21 +76,20 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
8076
request_copy = deepcopy(request)
8177
path_format_arguments = {
8278
"Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
83-
"ApiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"),
79+
"ApiVersion": self._serialize.url(
80+
"self._config.api_version", self._config.api_version, "str", skip_quote=True
81+
),
8482
}
8583

8684
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
8785
return self._client.send_request(request_copy, **kwargs)
8886

89-
def close(self):
90-
# type: () -> None
87+
def close(self) -> None:
9188
self._client.close()
9289

93-
def __enter__(self):
94-
# type: () -> AnomalyDetectorClient
90+
def __enter__(self) -> "AnomalyDetectorClient":
9591
self._client.__enter__()
9692
return self
9793

98-
def __exit__(self, *exc_details):
99-
# type: (Any) -> None
94+
def __exit__(self, *exc_details) -> None:
10095
self._client.__exit__(*exc_details)

sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_configuration.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# Licensed under the MIT License. See License.txt in the project root for license information.
5-
# Code generated by Microsoft (R) AutoRest Code Generator.
5+
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

@@ -39,7 +39,7 @@ class AnomalyDetectorClientConfiguration(Configuration): # pylint: disable=too-
3939

4040
def __init__(self, endpoint: str, credential: AzureKeyCredential, **kwargs: Any) -> None:
4141
super(AnomalyDetectorClientConfiguration, self).__init__(**kwargs)
42-
api_version = kwargs.pop("api_version", "v1.1") # type: Literal["v1.1"]
42+
api_version: Literal["v1.1"] = kwargs.pop("api_version", "v1.1")
4343

4444
if endpoint is None:
4545
raise ValueError("Parameter 'endpoint' must not be None.")
@@ -52,10 +52,7 @@ def __init__(self, endpoint: str, credential: AzureKeyCredential, **kwargs: Any)
5252
kwargs.setdefault("sdk_moniker", "ai-anomalydetector/{}".format(VERSION))
5353
self._configure(**kwargs)
5454

55-
def _configure(
56-
self, **kwargs # type: Any
57-
):
58-
# type: (...) -> None
55+
def _configure(self, **kwargs: Any) -> None:
5956
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
6057
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
6158
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)

0 commit comments

Comments
 (0)