Skip to content

Commit

Permalink
[xingyuyue/multi_ad_sample] add multivariate anomaly detetor sample f… (
Browse files Browse the repository at this point in the history
Azure#26783)

* [xingyuyue/multi_ad_sample] add multivariate anomaly detetor sample for v1.1

* [xingyuyue/multi_ad_sample] fix anomaly detetor sample for v1.1-preview

* [xingyuyue/multi_ad_sample] fix comments

* Fix aio client

* Fix APIView

* Update anomalydetector sdk

* [xingyuyue/multi_ad_sample] update SDK code

* [xingyuyue/multi_ad_sample] remove azure-ai-anomalydetector-new

* Update change log

* Update changelog

* Update changelog

* Update changelog

* Add anomalydetector to cspell

* Override dependencies for anomalydetector to resolve ci errors

* Update ci yaml for anomalydetector

* Update anomalydetector python sdk

* [xingyuyue/multi_ad_sample] update sdk code

* [xingyuyue/multi_ad_sample] fix sample get error code and message

* Update dependencies for anomalydetector

* Update dependencies for anomalydetector

* Update dependencies for anomalydetector

* Fix typo

* Fix type-extensions troubles

* [xingyuyue/multi_ad_sample] fix ci, readme and shared requirements

* Update sdk

* [xingyuyue/multi_ad_sample] update sdk sample

* Update change log

* [xingyuyue/multi_ad_sample] update sdk code and sample

* [xingyuyue/multi_ad_sample] update sdk async api

* Add Python 3.11 classifier

* update changelog.md to add release date

* [xingyuyue/multi_ad_sample] remove api version in client and update readme

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

Co-authored-by: Laurent Mazuel <[email protected]>
Co-authored-by: Chunlei Wang <[email protected]>
Co-authored-by: Laurent Mazuel <[email protected]>
Co-authored-by: jr-MS <[email protected]>
  • Loading branch information
5 people authored Nov 15, 2022
1 parent 3b1c811 commit 099878e
Show file tree
Hide file tree
Showing 40 changed files with 12,097 additions and 5,488 deletions.
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"**/*requirement*.txt",
"**/assets.json",

"sdk/anomalydetector/**",
"sdk/applicationinsights/azure-applicationinsights/**",
"sdk/appconfiguration/azure-appconfiguration/**",
"sdk/batch/azure-batch/**",
Expand Down
26 changes: 16 additions & 10 deletions sdk/anomalydetector/azure-ai-anomalydetector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# Release History

## 3.0.0b6 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
## 3.0.0b6 (2022-12-01)
**Features**
- Added `OneTable` and `MultiTable` two data schemas.
- Added `topContributorCount` in `detect_multivariate_last_anomaly` and `detect_multivariate_batch_anomaly`.

- Python 2.7 is no longer supported. Please use Python version 3.6 or later.
**Breaking Changes**
- Renamed `detect_entire_series` to `detect_univariate_entire_series`.
- Renamed `detect_last_point` to `detect_univariate_last_point`.
- Renamed `detect_change_point` to `detect_univariate_change_point`.
- Renamed `train_multivariate_model` to `create_and_train_multivariate_model`.
- Renamed `list_multivariate_model` to `list_multivariate_models`.
- Renamed `detect_anomaly` to `detect_multivariate_batch_anomaly`.
- Renamed `get_detection_result` to `get_multivariate_batch_detection_result`.
- Renamed `last_detect_anomaly` to `detect_multivariate_last_anomaly`.
- Removed `detecting_points` in `detect_multivariate_last_anomaly`.
- Removed `changed_values` in detection result.
- Removed `export_model`.

## 3.0.0b5 (2022-01-23)

Expand Down
8 changes: 4 additions & 4 deletions sdk/anomalydetector/azure-ai-anomalydetector/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
recursive-include tests *.py *.yaml
recursive-include samples *.py *.md
include *.md
include LICENSE
include azure/__init__.py
include azure/ai/__init__.py
include azure/ai/anomalydetector/py.typed
recursive-include tests *.py
recursive-include samples *.py *.md
include azure/__init__.py
include azure/ai/__init__.py
250 changes: 203 additions & 47 deletions sdk/anomalydetector/azure-ai-anomalydetector/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__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__)
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._anomaly_detector_client import AnomalyDetectorClient
from ._client import AnomalyDetectorClient
from ._version import VERSION

__version__ = VERSION
__all__ = ['AnomalyDetectorClient']

# `._patch.py` 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
from ._patch import patch_sdk
patch_sdk()
try:
from ._patch import __all__ as _patch_all
from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"AnomalyDetectorClient",
]
__all__.extend([p for p in _patch_all if p not in __all__])

_patch_sdk()

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# 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 copy import deepcopy
import sys
from typing import Any

from azure.core import PipelineClient
from azure.core.credentials import AzureKeyCredential
from azure.core.rest import HttpRequest, HttpResponse

from ._configuration import AnomalyDetectorClientConfiguration
from ._operations import AnomalyDetectorClientOperationsMixin
from ._serialization import Deserializer, Serializer

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


class AnomalyDetectorClient(AnomalyDetectorClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
"""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 endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
https://westus2.api.cognitive.microsoft.com). Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential
:keyword api_version: Api Version. Default value is "v1.1". Note that overriding this default
value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, endpoint: str, credential: AzureKeyCredential, **kwargs: Any) -> None:
_endpoint = "{Endpoint}/anomalydetector/{ApiVersion}"
self._config = AnomalyDetectorClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)

self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False

def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""

request_copy = deepcopy(request)
path_format_arguments = {
"Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
"ApiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"),
}

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

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
Expand Up @@ -6,68 +6,66 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import TYPE_CHECKING
import sys
from typing import Any

from azure.core.configuration import Configuration
from azure.core.credentials import AzureKeyCredential
from azure.core.pipeline import policies

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports

from azure.core.credentials import AzureKeyCredential


class AnomalyDetectorClientConfiguration(Configuration):
class AnomalyDetectorClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""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).
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
https://westus2.api.cognitive.microsoft.com). Required.
:type endpoint: str
:keyword api_version: Anomaly Detector API version (for example, v1.0). The default value is "v1.1-preview.1". Note that overriding this default value may result in unsupported behavior.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential
:keyword api_version: Api Version. Default value is "v1.1". Note that overriding this default
value may result in unsupported behavior.
:paramtype api_version: str
"""

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

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")

self.credential = credential
self.endpoint = endpoint
self.credential = credential
self.api_version = api_version
kwargs.setdefault('sdk_moniker', 'ai-anomalydetector/{}'.format(VERSION))
kwargs.setdefault("sdk_moniker", "ai-anomalydetector/{}".format(VERSION))
self._configure(**kwargs)

def _configure(
self,
**kwargs # type: Any
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')
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)
self.authentication_policy = policies.AzureKeyCredentialPolicy(
self.credential, "Ocp-Apim-Subscription-Key", **kwargs
)
Loading

0 comments on commit 099878e

Please sign in to comment.