-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Anomaly Detector V1, track2 generator (#12931)
* Anomaly Detector V1, track2 generator
- Loading branch information
Showing
26 changed files
with
1,810 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Release History | ||
|
||
## 3.0.0b1 (2020-08-17) | ||
|
||
- Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
recursive-include tests *.py *.yaml | ||
include *.md | ||
include azure/__init__.py | ||
include azure/ai/__init__.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Microsoft Azure SDK for Python | ||
|
||
This is the Microsoft Azure Cognitive Services Anomaly Detector Client Library. | ||
This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. | ||
|
||
For a more complete set of Azure libraries, see the | ||
[azure sdk python release](https://aka.ms/azsdk/python/all). | ||
|
||
# Usage | ||
|
||
For code examples, see [Cognitive Services Anomaly Detector](https://docs.microsoft.com/python/api/overview/azure/cognitive-services) | ||
on docs.microsoft.com. | ||
|
||
|
||
# Provide Feedback | ||
|
||
If you encounter any bugs or have suggestions, please file an issue in the | ||
[Issues](https://github.com/Azure/azure-sdk-for-python/issues) | ||
section of the project. | ||
|
||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__path__ = __import__('pkgutil').extend_path(__path__, __name__) |
1 change: 1 addition & 0 deletions
1
sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__path__ = __import__('pkgutil').extend_path(__path__, __name__) |
19 changes: 19 additions & 0 deletions
19
sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# 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. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from ._anomaly_detector_client import AnomalyDetectorClient | ||
from ._version import VERSION | ||
|
||
__version__ = VERSION | ||
__all__ = ['AnomalyDetectorClient'] | ||
|
||
try: | ||
from ._patch import patch_sdk # type: ignore | ||
patch_sdk() | ||
except ImportError: | ||
pass |
61 changes: 61 additions & 0 deletions
61
...alydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_anomaly_detector_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# 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. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from azure.core import PipelineClient | ||
from msrest import Deserializer, Serializer | ||
|
||
if TYPE_CHECKING: | ||
# pylint: disable=unused-import,ungrouped-imports | ||
from typing import Any | ||
|
||
from azure.core.credentials import AzureKeyCredential | ||
|
||
from ._configuration import AnomalyDetectorClientConfiguration | ||
from .operations import AnomalyDetectorClientOperationsMixin | ||
from . import models | ||
|
||
|
||
class AnomalyDetectorClient(AnomalyDetectorClientOperationsMixin): | ||
"""The Anomaly Detector API detects anomalies automatically in time series data. It supports two kinds of mode, one is for stateless using, another is for stateful using. In stateless mode, there are three functionalities. Entire Detect is for detecting the whole series with model trained by the time series, Last Detect is detecting last point with model trained by points before. ChangePoint Detect is for detecting trend changes in time series. In stateful mode, user can store time series, the stored time series will be used for detection anomalies. Under this mode, user can still use the above three functionalities by only giving a time range without preparing time series in client side. Besides the above three functionalities, stateful model also provide group based detection and labeling service. By leveraging labeling service user can provide labels for each detection result, these labels will be used for retuning or regenerating detection models. Inconsistency detection is a kind of group based detection, this detection will find inconsistency ones in a set of time series. By using anomaly detector service, business customers can discover incidents and establish a logic flow for root cause analysis. | ||
:param credential: Credential needed for the client to connect to Azure. | ||
:type credential: ~azure.core.credentials.AzureKeyCredential | ||
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com). | ||
:type endpoint: str | ||
""" | ||
|
||
def __init__( | ||
self, | ||
credential, # type: AzureKeyCredential | ||
endpoint, # type: str | ||
**kwargs # type: Any | ||
): | ||
# type: (...) -> None | ||
base_url = '{Endpoint}/anomalydetector/v1.0' | ||
self._config = AnomalyDetectorClientConfiguration(credential, endpoint, **kwargs) | ||
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) | ||
|
||
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} | ||
self._serialize = Serializer(client_models) | ||
self._deserialize = Deserializer(client_models) | ||
|
||
|
||
def close(self): | ||
# type: () -> None | ||
self._client.close() | ||
|
||
def __enter__(self): | ||
# type: () -> AnomalyDetectorClient | ||
self._client.__enter__() | ||
return self | ||
|
||
def __exit__(self, *exc_details): | ||
# type: (Any) -> None | ||
self._client.__exit__(*exc_details) |
68 changes: 68 additions & 0 deletions
68
sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_configuration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# 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. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
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 AzureKeyCredential | ||
|
||
|
||
class AnomalyDetectorClientConfiguration(Configuration): | ||
"""Configuration for AnomalyDetectorClient. | ||
Note that all parameters used to create this instance are saved as instance | ||
attributes. | ||
:param credential: Credential needed for the client to connect to Azure. | ||
:type credential: ~azure.core.credentials.AzureKeyCredential | ||
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com). | ||
:type endpoint: str | ||
""" | ||
|
||
def __init__( | ||
self, | ||
credential, # type: AzureKeyCredential | ||
endpoint, # type: str | ||
**kwargs # type: Any | ||
): | ||
# type: (...) -> None | ||
if credential is None: | ||
raise ValueError("Parameter 'credential' must not be None.") | ||
if endpoint is None: | ||
raise ValueError("Parameter 'endpoint' must not be None.") | ||
super(AnomalyDetectorClientConfiguration, self).__init__(**kwargs) | ||
|
||
self.credential = credential | ||
self.endpoint = endpoint | ||
kwargs.setdefault('sdk_moniker', 'ai-anomalydetector/{}'.format(VERSION)) | ||
self._configure(**kwargs) | ||
|
||
def _configure( | ||
self, | ||
**kwargs # type: Any | ||
): | ||
# type: (...) -> None | ||
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) | ||
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) | ||
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) | ||
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) | ||
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) | ||
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) | ||
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) | ||
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) | ||
self.authentication_policy = kwargs.get('authentication_policy') | ||
if self.credential and not self.authentication_policy: | ||
self.authentication_policy = policies.AzureKeyCredentialPolicy(self.credential, 'Ocp-Apim-Subscription-Key', **kwargs) |
95 changes: 95 additions & 0 deletions
95
sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"chosen_version": "1.0", | ||
"total_api_version_list": ["1.0"], | ||
"client": { | ||
"name": "AnomalyDetectorClient", | ||
"filename": "_anomaly_detector_client", | ||
"description": "The Anomaly Detector API detects anomalies automatically in time series data. It supports two kinds of mode, one is for stateless using, another is for stateful using. In stateless mode, there are three functionalities. Entire Detect is for detecting the whole series with model trained by the time series, Last Detect is detecting last point with model trained by points before. ChangePoint Detect is for detecting trend changes in time series. In stateful mode, user can store time series, the stored time series will be used for detection anomalies. Under this mode, user can still use the above three functionalities by only giving a time range without preparing time series in client side. Besides the above three functionalities, stateful model also provide group based detection and labeling service. By leveraging labeling service user can provide labels for each detection result, these labels will be used for retuning or regenerating detection models. Inconsistency detection is a kind of group based detection, this detection will find inconsistency ones in a set of time series. By using anomaly detector service, business customers can discover incidents and establish a logic flow for root cause analysis.", | ||
"base_url": null, | ||
"custom_base_url": "\u0027{Endpoint}/anomalydetector/v1.0\u0027", | ||
"azure_arm": false, | ||
"has_lro_operations": false | ||
}, | ||
"global_parameters": { | ||
"sync_method": { | ||
"credential": { | ||
"method_signature": "credential, # type: AzureKeyCredential", | ||
"description": "Credential needed for the client to connect to Azure.", | ||
"docstring_type": "~azure.core.credentials.AzureKeyCredential", | ||
"required": true | ||
}, | ||
"endpoint": { | ||
"method_signature": "endpoint, # type: str", | ||
"description": "Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).", | ||
"docstring_type": "str", | ||
"required": true | ||
} | ||
}, | ||
"async_method": { | ||
"credential": { | ||
"method_signature": "credential, # type: AzureKeyCredential", | ||
"description": "Credential needed for the client to connect to Azure.", | ||
"docstring_type": "~azure.core.credentials.AzureKeyCredential", | ||
"required": true | ||
}, | ||
"endpoint": { | ||
"method_signature": "endpoint, # type: str", | ||
"description": "Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).", | ||
"docstring_type": "str", | ||
"required": true | ||
} | ||
}, | ||
"constant": { | ||
}, | ||
"call": "credential, endpoint" | ||
}, | ||
"config": { | ||
"credential": true, | ||
"credential_scopes": null, | ||
"credential_default_policy_type": "AzureKeyCredentialPolicy", | ||
"credential_default_policy_type_has_async_version": false, | ||
"credential_key_header_name": "Ocp-Apim-Subscription-Key" | ||
}, | ||
"operation_groups": { | ||
}, | ||
"operation_mixins": { | ||
"entire_detect" : { | ||
"sync": { | ||
"signature": "def entire_detect(\n self,\n body, # type: \"models.Request\"\n **kwargs # type: Any\n):\n", | ||
"doc": "\"\"\"Detect anomalies for the entire series in batch.\n\nThis operation generates a model using an entire series, each point is detected with the same\nmodel. With this method, points before and after a certain point are used to determine whether\nit is an anomaly. The entire detection can give user an overall status of the time series.\n\n:param body: Time series points and period if needed. Advanced model parameters can also be set\n in the request.\n:type body: ~azure.ai.anomalydetector.models.Request\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: EntireDetectResponse, or the result of cls(response)\n:rtype: ~azure.ai.anomalydetector.models.EntireDetectResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" | ||
}, | ||
"async": { | ||
"coroutine": true, | ||
"signature": "async def entire_detect(\n self,\n body: \"models.Request\",\n **kwargs\n) -\u003e \"models.EntireDetectResponse\":\n", | ||
"doc": "\"\"\"Detect anomalies for the entire series in batch.\n\nThis operation generates a model using an entire series, each point is detected with the same\nmodel. With this method, points before and after a certain point are used to determine whether\nit is an anomaly. The entire detection can give user an overall status of the time series.\n\n:param body: Time series points and period if needed. Advanced model parameters can also be set\n in the request.\n:type body: ~azure.ai.anomalydetector.models.Request\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: EntireDetectResponse, or the result of cls(response)\n:rtype: ~azure.ai.anomalydetector.models.EntireDetectResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" | ||
}, | ||
"call": "body" | ||
}, | ||
"last_detect" : { | ||
"sync": { | ||
"signature": "def last_detect(\n self,\n body, # type: \"models.Request\"\n **kwargs # type: Any\n):\n", | ||
"doc": "\"\"\"Detect anomaly status of the latest point in time series.\n\nThis operation generates a model using points before the latest one. With this method, only\nhistorical points are used to determine whether the target point is an anomaly. The latest\npoint detecting operation matches the scenario of real-time monitoring of business metrics.\n\n:param body: Time series points and period if needed. Advanced model parameters can also be set\n in the request.\n:type body: ~azure.ai.anomalydetector.models.Request\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: LastDetectResponse, or the result of cls(response)\n:rtype: ~azure.ai.anomalydetector.models.LastDetectResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" | ||
}, | ||
"async": { | ||
"coroutine": true, | ||
"signature": "async def last_detect(\n self,\n body: \"models.Request\",\n **kwargs\n) -\u003e \"models.LastDetectResponse\":\n", | ||
"doc": "\"\"\"Detect anomaly status of the latest point in time series.\n\nThis operation generates a model using points before the latest one. With this method, only\nhistorical points are used to determine whether the target point is an anomaly. The latest\npoint detecting operation matches the scenario of real-time monitoring of business metrics.\n\n:param body: Time series points and period if needed. Advanced model parameters can also be set\n in the request.\n:type body: ~azure.ai.anomalydetector.models.Request\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: LastDetectResponse, or the result of cls(response)\n:rtype: ~azure.ai.anomalydetector.models.LastDetectResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" | ||
}, | ||
"call": "body" | ||
}, | ||
"change_point_detect" : { | ||
"sync": { | ||
"signature": "def change_point_detect(\n self,\n body, # type: \"models.ChangePointDetectRequest\"\n **kwargs # type: Any\n):\n", | ||
"doc": "\"\"\"Detect change point for the entire series.\n\nEvaluate change point score of every series point.\n\n:param body: Time series points and granularity is needed. Advanced model parameters can also\n be set in the request if needed.\n:type body: ~azure.ai.anomalydetector.models.ChangePointDetectRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ChangePointDetectResponse, or the result of cls(response)\n:rtype: ~azure.ai.anomalydetector.models.ChangePointDetectResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" | ||
}, | ||
"async": { | ||
"coroutine": true, | ||
"signature": "async def change_point_detect(\n self,\n body: \"models.ChangePointDetectRequest\",\n **kwargs\n) -\u003e \"models.ChangePointDetectResponse\":\n", | ||
"doc": "\"\"\"Detect change point for the entire series.\n\nEvaluate change point score of every series point.\n\n:param body: Time series points and granularity is needed. Advanced model parameters can also\n be set in the request if needed.\n:type body: ~azure.ai.anomalydetector.models.ChangePointDetectRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ChangePointDetectResponse, or the result of cls(response)\n:rtype: ~azure.ai.anomalydetector.models.ChangePointDetectResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" | ||
}, | ||
"call": "body" | ||
} | ||
}, | ||
"sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", | ||
"async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}" | ||
} |
9 changes: 9 additions & 0 deletions
9
sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# 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. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
VERSION = "3.0.0b1" |
10 changes: 10 additions & 0 deletions
10
sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/aio/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from ._anomaly_detector_client_async import AnomalyDetectorClient | ||
__all__ = ['AnomalyDetectorClient'] |
Oops, something went wrong.