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

Anomaly Detector V1, track2 generator #12931

Merged
merged 13 commits into from
Aug 14, 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
5 changes: 5 additions & 0 deletions sdk/anomalydetector/azure-ai-anomalydetector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release History

## 3.0.0b1 (2020-08-17)

- Initial Release
5 changes: 5 additions & 0 deletions sdk/anomalydetector/azure-ai-anomalydetector/MANIFEST.in
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

22 changes: 22 additions & 0 deletions sdk/anomalydetector/azure-ai-anomalydetector/README.md
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.


![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-cognitiveservices-anomalydetector%2FREADME.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
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
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)
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)
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\"]}}}"
}
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"
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']
Loading