diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/CHANGELOG.md b/sdk/anomalydetector/azure-ai-anomalydetector/CHANGELOG.md new file mode 100644 index 0000000000000..578ed6acf4796 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/MANIFEST.in b/sdk/anomalydetector/azure-ai-anomalydetector/MANIFEST.in new file mode 100644 index 0000000000000..bde85ca9d6c84 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/MANIFEST.in @@ -0,0 +1,5 @@ +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/ai/__init__.py + diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/README.md b/sdk/anomalydetector/azure-ai-anomalydetector/README.md new file mode 100644 index 0000000000000..4ecf848c6bdbb --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/README.md @@ -0,0 +1,21 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + + +# Usage + +For code examples, see [MyService Management](https://docs.microsoft.com/python/api/overview/azure/) +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-ai-anomalydetector%2FREADME.png) diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/__init__.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/__init__.py new file mode 100644 index 0000000000000..0260537a02bb9 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/__init__.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/__init__.py new file mode 100644 index 0000000000000..0260537a02bb9 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/__init__.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/__init__.py new file mode 100644 index 0000000000000..09815430d0295 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/__init__.py @@ -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 ._configuration import AnomalyDetectorClientConfiguration +from ._anomaly_detector_client import AnomalyDetectorClient +__all__ = ['AnomalyDetectorClient', 'AnomalyDetectorClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_anomaly_detector_client.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_anomaly_detector_client.py new file mode 100644 index 0000000000000..90aa08443be16 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_anomaly_detector_client.py @@ -0,0 +1,44 @@ +# 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 msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import AnomalyDetectorClientConfiguration +from .operations import AnomalyDetectorClientOperationsMixin +from . import models + + +class AnomalyDetectorClient(AnomalyDetectorClientOperationsMixin, SDKClient): + """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. + + :ivar config: Configuration for client. + :vartype config: AnomalyDetectorClientConfiguration + + :param endpoint: Supported Cognitive Services endpoints (protocol and + hostname, for example: https://westus2.api.cognitive.microsoft.com). + :type endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, endpoint, credentials): + + self.config = AnomalyDetectorClientConfiguration(endpoint, credentials) + super(AnomalyDetectorClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '1.0' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_configuration.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_configuration.py new file mode 100644 index 0000000000000..ad4e88db35423 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_configuration.py @@ -0,0 +1,47 @@ +# 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 msrest import Configuration + +from .version import VERSION + + +class AnomalyDetectorClientConfiguration(Configuration): + """Configuration for AnomalyDetectorClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Supported Cognitive Services endpoints (protocol and + hostname, for example: https://westus2.api.cognitive.microsoft.com). + :type endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, endpoint, credentials): + + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + base_url = '{Endpoint}/anomalydetector/v1.0' + + super(AnomalyDetectorClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-ai-anomalydetector/{}'.format(VERSION)) + + self.endpoint = endpoint + self.credentials = credentials diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/__init__.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/__init__.py new file mode 100644 index 0000000000000..b2f52f98af60d --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/__init__.py @@ -0,0 +1,41 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import AnomalyDetectorError, AnomalyDetectorErrorException + from ._models_py3 import ChangePointDetectRequest + from ._models_py3 import ChangePointDetectResponse + from ._models_py3 import DetectRequest + from ._models_py3 import EntireDetectResponse + from ._models_py3 import LastDetectResponse + from ._models_py3 import TimeSeriesPoint +except (SyntaxError, ImportError): + from ._models import AnomalyDetectorError, AnomalyDetectorErrorException + from ._models import ChangePointDetectRequest + from ._models import ChangePointDetectResponse + from ._models import DetectRequest + from ._models import EntireDetectResponse + from ._models import LastDetectResponse + from ._models import TimeSeriesPoint +from ._anomaly_detector_client_enums import ( + TimeGranularity, +) + +__all__ = [ + 'AnomalyDetectorError', 'AnomalyDetectorErrorException', + 'ChangePointDetectRequest', + 'ChangePointDetectResponse', + 'DetectRequest', + 'EntireDetectResponse', + 'LastDetectResponse', + 'TimeSeriesPoint', + 'TimeGranularity', +] diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_anomaly_detector_client_enums.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_anomaly_detector_client_enums.py new file mode 100644 index 0000000000000..b4d4a47884ef7 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_anomaly_detector_client_enums.py @@ -0,0 +1,25 @@ +# 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 enum import Enum + + +class TimeGranularity(str, Enum): + + yearly = "yearly" + monthly = "monthly" + weekly = "weekly" + daily = "daily" + hourly = "hourly" + per_minute = "minutely" + per_second = "secondly" + microsecond = "microsecond" + none = "none" diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models.py new file mode 100644 index 0000000000000..fb5e917c54cf6 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models.py @@ -0,0 +1,362 @@ +# 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 msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class AnomalyDetectorError(Model): + """Error information returned by the API. + + :param code: The error code. + :type code: object + :param message: A message explaining the error reported by the service. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'object'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AnomalyDetectorError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class AnomalyDetectorErrorException(HttpOperationError): + """Server responsed with exception of type: 'AnomalyDetectorError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(AnomalyDetectorErrorException, self).__init__(deserialize, response, 'AnomalyDetectorError', *args) + + +class ChangePointDetectRequest(Model): + """ChangePointDetectRequest. + + All required parameters must be populated in order to send to Azure. + + :param series: Required. Time series data points. Points should be sorted + by timestamp in ascending order to match the change point detection + result. + :type series: list[~azure.ai.anomalydetector.models.TimeSeriesPoint] + :param granularity: Required. Can only be one of yearly, monthly, weekly, + daily, hourly, minutely or secondly. Granularity is used for verify + whether input series is valid. Possible values include: 'yearly', + 'monthly', 'weekly', 'daily', 'hourly', 'perMinute', 'perSecond', + 'microsecond', 'none' + :type granularity: str or ~azure.ai.anomalydetector.models.TimeGranularity + :param custom_interval: Custom Interval is used to set non-standard time + interval, for example, if the series is 5 minutes, request can be set as + {"granularity":"minutely", "customInterval":5}. + :type custom_interval: int + :param period: Optional argument, periodic value of a time series. If the + value is null or does not present, the API will determine the period + automatically. + :type period: int + :param stable_trend_window: Optional argument, advanced model parameter, a + default stableTrendWindow will be used in detection. + :type stable_trend_window: int + :param threshold: Optional argument, advanced model parameter, between + 0.0-1.0, the lower the value is, the larger the trend error will be which + means less change point will be accepted. + :type threshold: float + """ + + _validation = { + 'series': {'required': True}, + 'granularity': {'required': True}, + } + + _attribute_map = { + 'series': {'key': 'series', 'type': '[TimeSeriesPoint]'}, + 'granularity': {'key': 'granularity', 'type': 'TimeGranularity'}, + 'custom_interval': {'key': 'customInterval', 'type': 'int'}, + 'period': {'key': 'period', 'type': 'int'}, + 'stable_trend_window': {'key': 'stableTrendWindow', 'type': 'int'}, + 'threshold': {'key': 'threshold', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(ChangePointDetectRequest, self).__init__(**kwargs) + self.series = kwargs.get('series', None) + self.granularity = kwargs.get('granularity', None) + self.custom_interval = kwargs.get('custom_interval', None) + self.period = kwargs.get('period', None) + self.stable_trend_window = kwargs.get('stable_trend_window', None) + self.threshold = kwargs.get('threshold', None) + + +class ChangePointDetectResponse(Model): + """ChangePointDetectResponse. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar period: Frequency extracted from the series, zero means no recurrent + pattern has been found. + :vartype period: int + :param is_change_point: isChangePoint contains change point properties for + each input point. True means an anomaly either negative or positive has + been detected. The index of the array is consistent with the input series. + :type is_change_point: list[bool] + :param confidence_scores: the change point confidence of each point + :type confidence_scores: list[float] + """ + + _validation = { + 'period': {'readonly': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'is_change_point': {'key': 'isChangePoint', 'type': '[bool]'}, + 'confidence_scores': {'key': 'confidenceScores', 'type': '[float]'}, + } + + def __init__(self, **kwargs): + super(ChangePointDetectResponse, self).__init__(**kwargs) + self.period = None + self.is_change_point = kwargs.get('is_change_point', None) + self.confidence_scores = kwargs.get('confidence_scores', None) + + +class DetectRequest(Model): + """DetectRequest. + + All required parameters must be populated in order to send to Azure. + + :param series: Required. Time series data points. Points should be sorted + by timestamp in ascending order to match the anomaly detection result. If + the data is not sorted correctly or there is duplicated timestamp, the API + will not work. In such case, an error message will be returned. + :type series: list[~azure.ai.anomalydetector.models.TimeSeriesPoint] + :param granularity: Possible values include: 'yearly', 'monthly', + 'weekly', 'daily', 'hourly', 'perMinute', 'perSecond', 'microsecond', + 'none' + :type granularity: str or ~azure.ai.anomalydetector.models.TimeGranularity + :param custom_interval: Custom Interval is used to set non-standard time + interval, for example, if the series is 5 minutes, request can be set as + {"granularity":"minutely", "customInterval":5}. + :type custom_interval: int + :param period: Optional argument, periodic value of a time series. If the + value is null or does not present, the API will determine the period + automatically. + :type period: int + :param max_anomaly_ratio: Optional argument, advanced model parameter, max + anomaly ratio in a time series. + :type max_anomaly_ratio: float + :param sensitivity: Optional argument, advanced model parameter, between + 0-99, the lower the value is, the larger the margin value will be which + means less anomalies will be accepted. + :type sensitivity: int + """ + + _validation = { + 'series': {'required': True}, + } + + _attribute_map = { + 'series': {'key': 'series', 'type': '[TimeSeriesPoint]'}, + 'granularity': {'key': 'granularity', 'type': 'TimeGranularity'}, + 'custom_interval': {'key': 'customInterval', 'type': 'int'}, + 'period': {'key': 'period', 'type': 'int'}, + 'max_anomaly_ratio': {'key': 'maxAnomalyRatio', 'type': 'float'}, + 'sensitivity': {'key': 'sensitivity', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(DetectRequest, self).__init__(**kwargs) + self.series = kwargs.get('series', None) + self.granularity = kwargs.get('granularity', None) + self.custom_interval = kwargs.get('custom_interval', None) + self.period = kwargs.get('period', None) + self.max_anomaly_ratio = kwargs.get('max_anomaly_ratio', None) + self.sensitivity = kwargs.get('sensitivity', None) + + +class EntireDetectResponse(Model): + """EntireDetectResponse. + + All required parameters must be populated in order to send to Azure. + + :param period: Required. Frequency extracted from the series, zero means + no recurrent pattern has been found. + :type period: int + :param expected_values: Required. ExpectedValues contain expected value + for each input point. The index of the array is consistent with the input + series. + :type expected_values: list[float] + :param upper_margins: Required. UpperMargins contain upper margin of each + input point. UpperMargin is used to calculate upperBoundary, which equals + to expectedValue + (100 - marginScale)*upperMargin. Anomalies in response + can be filtered by upperBoundary and lowerBoundary. By adjusting + marginScale value, less significant anomalies can be filtered in client + side. The index of the array is consistent with the input series. + :type upper_margins: list[float] + :param lower_margins: Required. LowerMargins contain lower margin of each + input point. LowerMargin is used to calculate lowerBoundary, which equals + to expectedValue - (100 - marginScale)*lowerMargin. Points between the + boundary can be marked as normal ones in client side. The index of the + array is consistent with the input series. + :type lower_margins: list[float] + :param is_anomaly: Required. IsAnomaly contains anomaly properties for + each input point. True means an anomaly either negative or positive has + been detected. The index of the array is consistent with the input series. + :type is_anomaly: list[bool] + :param is_negative_anomaly: Required. IsNegativeAnomaly contains anomaly + status in negative direction for each input point. True means a negative + anomaly has been detected. A negative anomaly means the point is detected + as an anomaly and its real value is smaller than the expected one. The + index of the array is consistent with the input series. + :type is_negative_anomaly: list[bool] + :param is_positive_anomaly: Required. IsPositiveAnomaly contain anomaly + status in positive direction for each input point. True means a positive + anomaly has been detected. A positive anomaly means the point is detected + as an anomaly and its real value is larger than the expected one. The + index of the array is consistent with the input series. + :type is_positive_anomaly: list[bool] + """ + + _validation = { + 'period': {'required': True}, + 'expected_values': {'required': True}, + 'upper_margins': {'required': True}, + 'lower_margins': {'required': True}, + 'is_anomaly': {'required': True}, + 'is_negative_anomaly': {'required': True}, + 'is_positive_anomaly': {'required': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'expected_values': {'key': 'expectedValues', 'type': '[float]'}, + 'upper_margins': {'key': 'upperMargins', 'type': '[float]'}, + 'lower_margins': {'key': 'lowerMargins', 'type': '[float]'}, + 'is_anomaly': {'key': 'isAnomaly', 'type': '[bool]'}, + 'is_negative_anomaly': {'key': 'isNegativeAnomaly', 'type': '[bool]'}, + 'is_positive_anomaly': {'key': 'isPositiveAnomaly', 'type': '[bool]'}, + } + + def __init__(self, **kwargs): + super(EntireDetectResponse, self).__init__(**kwargs) + self.period = kwargs.get('period', None) + self.expected_values = kwargs.get('expected_values', None) + self.upper_margins = kwargs.get('upper_margins', None) + self.lower_margins = kwargs.get('lower_margins', None) + self.is_anomaly = kwargs.get('is_anomaly', None) + self.is_negative_anomaly = kwargs.get('is_negative_anomaly', None) + self.is_positive_anomaly = kwargs.get('is_positive_anomaly', None) + + +class LastDetectResponse(Model): + """LastDetectResponse. + + All required parameters must be populated in order to send to Azure. + + :param period: Required. Frequency extracted from the series, zero means + no recurrent pattern has been found. + :type period: int + :param suggested_window: Required. Suggested input series points needed + for detecting the latest point. + :type suggested_window: int + :param expected_value: Required. Expected value of the latest point. + :type expected_value: float + :param upper_margin: Required. Upper margin of the latest point. + UpperMargin is used to calculate upperBoundary, which equals to + expectedValue + (100 - marginScale)*upperMargin. If the value of latest + point is between upperBoundary and lowerBoundary, it should be treated as + normal value. By adjusting marginScale value, anomaly status of latest + point can be changed. + :type upper_margin: float + :param lower_margin: Required. Lower margin of the latest point. + LowerMargin is used to calculate lowerBoundary, which equals to + expectedValue - (100 - marginScale)*lowerMargin. + :type lower_margin: float + :param is_anomaly: Required. Anomaly status of the latest point, true + means the latest point is an anomaly either in negative direction or + positive direction. + :type is_anomaly: bool + :param is_negative_anomaly: Required. Anomaly status in negative direction + of the latest point. True means the latest point is an anomaly and its + real value is smaller than the expected one. + :type is_negative_anomaly: bool + :param is_positive_anomaly: Required. Anomaly status in positive direction + of the latest point. True means the latest point is an anomaly and its + real value is larger than the expected one. + :type is_positive_anomaly: bool + """ + + _validation = { + 'period': {'required': True}, + 'suggested_window': {'required': True}, + 'expected_value': {'required': True}, + 'upper_margin': {'required': True}, + 'lower_margin': {'required': True}, + 'is_anomaly': {'required': True}, + 'is_negative_anomaly': {'required': True}, + 'is_positive_anomaly': {'required': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'suggested_window': {'key': 'suggestedWindow', 'type': 'int'}, + 'expected_value': {'key': 'expectedValue', 'type': 'float'}, + 'upper_margin': {'key': 'upperMargin', 'type': 'float'}, + 'lower_margin': {'key': 'lowerMargin', 'type': 'float'}, + 'is_anomaly': {'key': 'isAnomaly', 'type': 'bool'}, + 'is_negative_anomaly': {'key': 'isNegativeAnomaly', 'type': 'bool'}, + 'is_positive_anomaly': {'key': 'isPositiveAnomaly', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(LastDetectResponse, self).__init__(**kwargs) + self.period = kwargs.get('period', None) + self.suggested_window = kwargs.get('suggested_window', None) + self.expected_value = kwargs.get('expected_value', None) + self.upper_margin = kwargs.get('upper_margin', None) + self.lower_margin = kwargs.get('lower_margin', None) + self.is_anomaly = kwargs.get('is_anomaly', None) + self.is_negative_anomaly = kwargs.get('is_negative_anomaly', None) + self.is_positive_anomaly = kwargs.get('is_positive_anomaly', None) + + +class TimeSeriesPoint(Model): + """TimeSeriesPoint. + + All required parameters must be populated in order to send to Azure. + + :param timestamp: Optional argument, timestamp of a data point (ISO8601 + format). + :type timestamp: datetime + :param value: Required. The measurement of that point, should be float. + :type value: float + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(TimeSeriesPoint, self).__init__(**kwargs) + self.timestamp = kwargs.get('timestamp', None) + self.value = kwargs.get('value', None) diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models_py3.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models_py3.py new file mode 100644 index 0000000000000..0401c6658c0fa --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models_py3.py @@ -0,0 +1,362 @@ +# 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 msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class AnomalyDetectorError(Model): + """Error information returned by the API. + + :param code: The error code. + :type code: object + :param message: A message explaining the error reported by the service. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'object'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, code=None, message: str=None, **kwargs) -> None: + super(AnomalyDetectorError, self).__init__(**kwargs) + self.code = code + self.message = message + + +class AnomalyDetectorErrorException(HttpOperationError): + """Server responsed with exception of type: 'AnomalyDetectorError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(AnomalyDetectorErrorException, self).__init__(deserialize, response, 'AnomalyDetectorError', *args) + + +class ChangePointDetectRequest(Model): + """ChangePointDetectRequest. + + All required parameters must be populated in order to send to Azure. + + :param series: Required. Time series data points. Points should be sorted + by timestamp in ascending order to match the change point detection + result. + :type series: list[~azure.ai.anomalydetector.models.TimeSeriesPoint] + :param granularity: Required. Can only be one of yearly, monthly, weekly, + daily, hourly, minutely or secondly. Granularity is used for verify + whether input series is valid. Possible values include: 'yearly', + 'monthly', 'weekly', 'daily', 'hourly', 'perMinute', 'perSecond', + 'microsecond', 'none' + :type granularity: str or ~azure.ai.anomalydetector.models.TimeGranularity + :param custom_interval: Custom Interval is used to set non-standard time + interval, for example, if the series is 5 minutes, request can be set as + {"granularity":"minutely", "customInterval":5}. + :type custom_interval: int + :param period: Optional argument, periodic value of a time series. If the + value is null or does not present, the API will determine the period + automatically. + :type period: int + :param stable_trend_window: Optional argument, advanced model parameter, a + default stableTrendWindow will be used in detection. + :type stable_trend_window: int + :param threshold: Optional argument, advanced model parameter, between + 0.0-1.0, the lower the value is, the larger the trend error will be which + means less change point will be accepted. + :type threshold: float + """ + + _validation = { + 'series': {'required': True}, + 'granularity': {'required': True}, + } + + _attribute_map = { + 'series': {'key': 'series', 'type': '[TimeSeriesPoint]'}, + 'granularity': {'key': 'granularity', 'type': 'TimeGranularity'}, + 'custom_interval': {'key': 'customInterval', 'type': 'int'}, + 'period': {'key': 'period', 'type': 'int'}, + 'stable_trend_window': {'key': 'stableTrendWindow', 'type': 'int'}, + 'threshold': {'key': 'threshold', 'type': 'float'}, + } + + def __init__(self, *, series, granularity, custom_interval: int=None, period: int=None, stable_trend_window: int=None, threshold: float=None, **kwargs) -> None: + super(ChangePointDetectRequest, self).__init__(**kwargs) + self.series = series + self.granularity = granularity + self.custom_interval = custom_interval + self.period = period + self.stable_trend_window = stable_trend_window + self.threshold = threshold + + +class ChangePointDetectResponse(Model): + """ChangePointDetectResponse. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar period: Frequency extracted from the series, zero means no recurrent + pattern has been found. + :vartype period: int + :param is_change_point: isChangePoint contains change point properties for + each input point. True means an anomaly either negative or positive has + been detected. The index of the array is consistent with the input series. + :type is_change_point: list[bool] + :param confidence_scores: the change point confidence of each point + :type confidence_scores: list[float] + """ + + _validation = { + 'period': {'readonly': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'is_change_point': {'key': 'isChangePoint', 'type': '[bool]'}, + 'confidence_scores': {'key': 'confidenceScores', 'type': '[float]'}, + } + + def __init__(self, *, is_change_point=None, confidence_scores=None, **kwargs) -> None: + super(ChangePointDetectResponse, self).__init__(**kwargs) + self.period = None + self.is_change_point = is_change_point + self.confidence_scores = confidence_scores + + +class DetectRequest(Model): + """DetectRequest. + + All required parameters must be populated in order to send to Azure. + + :param series: Required. Time series data points. Points should be sorted + by timestamp in ascending order to match the anomaly detection result. If + the data is not sorted correctly or there is duplicated timestamp, the API + will not work. In such case, an error message will be returned. + :type series: list[~azure.ai.anomalydetector.models.TimeSeriesPoint] + :param granularity: Possible values include: 'yearly', 'monthly', + 'weekly', 'daily', 'hourly', 'perMinute', 'perSecond', 'microsecond', + 'none' + :type granularity: str or ~azure.ai.anomalydetector.models.TimeGranularity + :param custom_interval: Custom Interval is used to set non-standard time + interval, for example, if the series is 5 minutes, request can be set as + {"granularity":"minutely", "customInterval":5}. + :type custom_interval: int + :param period: Optional argument, periodic value of a time series. If the + value is null or does not present, the API will determine the period + automatically. + :type period: int + :param max_anomaly_ratio: Optional argument, advanced model parameter, max + anomaly ratio in a time series. + :type max_anomaly_ratio: float + :param sensitivity: Optional argument, advanced model parameter, between + 0-99, the lower the value is, the larger the margin value will be which + means less anomalies will be accepted. + :type sensitivity: int + """ + + _validation = { + 'series': {'required': True}, + } + + _attribute_map = { + 'series': {'key': 'series', 'type': '[TimeSeriesPoint]'}, + 'granularity': {'key': 'granularity', 'type': 'TimeGranularity'}, + 'custom_interval': {'key': 'customInterval', 'type': 'int'}, + 'period': {'key': 'period', 'type': 'int'}, + 'max_anomaly_ratio': {'key': 'maxAnomalyRatio', 'type': 'float'}, + 'sensitivity': {'key': 'sensitivity', 'type': 'int'}, + } + + def __init__(self, *, series, granularity=None, custom_interval: int=None, period: int=None, max_anomaly_ratio: float=None, sensitivity: int=None, **kwargs) -> None: + super(DetectRequest, self).__init__(**kwargs) + self.series = series + self.granularity = granularity + self.custom_interval = custom_interval + self.period = period + self.max_anomaly_ratio = max_anomaly_ratio + self.sensitivity = sensitivity + + +class EntireDetectResponse(Model): + """EntireDetectResponse. + + All required parameters must be populated in order to send to Azure. + + :param period: Required. Frequency extracted from the series, zero means + no recurrent pattern has been found. + :type period: int + :param expected_values: Required. ExpectedValues contain expected value + for each input point. The index of the array is consistent with the input + series. + :type expected_values: list[float] + :param upper_margins: Required. UpperMargins contain upper margin of each + input point. UpperMargin is used to calculate upperBoundary, which equals + to expectedValue + (100 - marginScale)*upperMargin. Anomalies in response + can be filtered by upperBoundary and lowerBoundary. By adjusting + marginScale value, less significant anomalies can be filtered in client + side. The index of the array is consistent with the input series. + :type upper_margins: list[float] + :param lower_margins: Required. LowerMargins contain lower margin of each + input point. LowerMargin is used to calculate lowerBoundary, which equals + to expectedValue - (100 - marginScale)*lowerMargin. Points between the + boundary can be marked as normal ones in client side. The index of the + array is consistent with the input series. + :type lower_margins: list[float] + :param is_anomaly: Required. IsAnomaly contains anomaly properties for + each input point. True means an anomaly either negative or positive has + been detected. The index of the array is consistent with the input series. + :type is_anomaly: list[bool] + :param is_negative_anomaly: Required. IsNegativeAnomaly contains anomaly + status in negative direction for each input point. True means a negative + anomaly has been detected. A negative anomaly means the point is detected + as an anomaly and its real value is smaller than the expected one. The + index of the array is consistent with the input series. + :type is_negative_anomaly: list[bool] + :param is_positive_anomaly: Required. IsPositiveAnomaly contain anomaly + status in positive direction for each input point. True means a positive + anomaly has been detected. A positive anomaly means the point is detected + as an anomaly and its real value is larger than the expected one. The + index of the array is consistent with the input series. + :type is_positive_anomaly: list[bool] + """ + + _validation = { + 'period': {'required': True}, + 'expected_values': {'required': True}, + 'upper_margins': {'required': True}, + 'lower_margins': {'required': True}, + 'is_anomaly': {'required': True}, + 'is_negative_anomaly': {'required': True}, + 'is_positive_anomaly': {'required': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'expected_values': {'key': 'expectedValues', 'type': '[float]'}, + 'upper_margins': {'key': 'upperMargins', 'type': '[float]'}, + 'lower_margins': {'key': 'lowerMargins', 'type': '[float]'}, + 'is_anomaly': {'key': 'isAnomaly', 'type': '[bool]'}, + 'is_negative_anomaly': {'key': 'isNegativeAnomaly', 'type': '[bool]'}, + 'is_positive_anomaly': {'key': 'isPositiveAnomaly', 'type': '[bool]'}, + } + + def __init__(self, *, period: int, expected_values, upper_margins, lower_margins, is_anomaly, is_negative_anomaly, is_positive_anomaly, **kwargs) -> None: + super(EntireDetectResponse, self).__init__(**kwargs) + self.period = period + self.expected_values = expected_values + self.upper_margins = upper_margins + self.lower_margins = lower_margins + self.is_anomaly = is_anomaly + self.is_negative_anomaly = is_negative_anomaly + self.is_positive_anomaly = is_positive_anomaly + + +class LastDetectResponse(Model): + """LastDetectResponse. + + All required parameters must be populated in order to send to Azure. + + :param period: Required. Frequency extracted from the series, zero means + no recurrent pattern has been found. + :type period: int + :param suggested_window: Required. Suggested input series points needed + for detecting the latest point. + :type suggested_window: int + :param expected_value: Required. Expected value of the latest point. + :type expected_value: float + :param upper_margin: Required. Upper margin of the latest point. + UpperMargin is used to calculate upperBoundary, which equals to + expectedValue + (100 - marginScale)*upperMargin. If the value of latest + point is between upperBoundary and lowerBoundary, it should be treated as + normal value. By adjusting marginScale value, anomaly status of latest + point can be changed. + :type upper_margin: float + :param lower_margin: Required. Lower margin of the latest point. + LowerMargin is used to calculate lowerBoundary, which equals to + expectedValue - (100 - marginScale)*lowerMargin. + :type lower_margin: float + :param is_anomaly: Required. Anomaly status of the latest point, true + means the latest point is an anomaly either in negative direction or + positive direction. + :type is_anomaly: bool + :param is_negative_anomaly: Required. Anomaly status in negative direction + of the latest point. True means the latest point is an anomaly and its + real value is smaller than the expected one. + :type is_negative_anomaly: bool + :param is_positive_anomaly: Required. Anomaly status in positive direction + of the latest point. True means the latest point is an anomaly and its + real value is larger than the expected one. + :type is_positive_anomaly: bool + """ + + _validation = { + 'period': {'required': True}, + 'suggested_window': {'required': True}, + 'expected_value': {'required': True}, + 'upper_margin': {'required': True}, + 'lower_margin': {'required': True}, + 'is_anomaly': {'required': True}, + 'is_negative_anomaly': {'required': True}, + 'is_positive_anomaly': {'required': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'suggested_window': {'key': 'suggestedWindow', 'type': 'int'}, + 'expected_value': {'key': 'expectedValue', 'type': 'float'}, + 'upper_margin': {'key': 'upperMargin', 'type': 'float'}, + 'lower_margin': {'key': 'lowerMargin', 'type': 'float'}, + 'is_anomaly': {'key': 'isAnomaly', 'type': 'bool'}, + 'is_negative_anomaly': {'key': 'isNegativeAnomaly', 'type': 'bool'}, + 'is_positive_anomaly': {'key': 'isPositiveAnomaly', 'type': 'bool'}, + } + + def __init__(self, *, period: int, suggested_window: int, expected_value: float, upper_margin: float, lower_margin: float, is_anomaly: bool, is_negative_anomaly: bool, is_positive_anomaly: bool, **kwargs) -> None: + super(LastDetectResponse, self).__init__(**kwargs) + self.period = period + self.suggested_window = suggested_window + self.expected_value = expected_value + self.upper_margin = upper_margin + self.lower_margin = lower_margin + self.is_anomaly = is_anomaly + self.is_negative_anomaly = is_negative_anomaly + self.is_positive_anomaly = is_positive_anomaly + + +class TimeSeriesPoint(Model): + """TimeSeriesPoint. + + All required parameters must be populated in order to send to Azure. + + :param timestamp: Optional argument, timestamp of a data point (ISO8601 + format). + :type timestamp: datetime + :param value: Required. The measurement of that point, should be float. + :type value: float + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, *, value: float, timestamp=None, **kwargs) -> None: + super(TimeSeriesPoint, self).__init__(**kwargs) + self.timestamp = timestamp + self.value = value diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/__init__.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/__init__.py new file mode 100644 index 0000000000000..ed756e4e57b24 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/__init__.py @@ -0,0 +1,16 @@ +# 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_operations import AnomalyDetectorClientOperationsMixin + +__all__ = [ + 'AnomalyDetectorClientOperationsMixin', +] diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/_anomaly_detector_client_operations.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/_anomaly_detector_client_operations.py new file mode 100644 index 0000000000000..eb305fefc7b64 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/_anomaly_detector_client_operations.py @@ -0,0 +1,196 @@ +# 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 msrest.pipeline import ClientRawResponse +from .. import models + + +class AnomalyDetectorClientOperationsMixin(object): + + def detect_entire_series( + self, body, custom_headers=None, raw=False, **operation_config): + """Detect anomalies for the entire series in batch. + + This operation generates a model using an entire series, each point is + detected with the same model. With this method, points before and after + a certain point are used to determine whether it is an anomaly. The + entire detection can give user an overall status of the time series. + + :param body: Time series points and period if needed. Advanced model + parameters can also be set in the request. + :type body: ~azure.ai.anomalydetector.models.DetectRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: EntireDetectResponse or ClientRawResponse if raw=true + :rtype: ~azure.ai.anomalydetector.models.EntireDetectResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`AnomalyDetectorErrorException` + """ + # Construct URL + url = self.detect_entire_series.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'DetectRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.AnomalyDetectorErrorException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('EntireDetectResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + detect_entire_series.metadata = {'url': '/timeseries/entire/detect'} + + def detect_last_point( + self, body, custom_headers=None, raw=False, **operation_config): + """Detect anomaly status of the latest point in time series. + + This operation generates a model using points before the latest one. + With this method, only historical points are used to determine whether + the target point is an anomaly. The latest point detecting operation + matches the scenario of real-time monitoring of business metrics. + + :param body: Time series points and period if needed. Advanced model + parameters can also be set in the request. + :type body: ~azure.ai.anomalydetector.models.DetectRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LastDetectResponse or ClientRawResponse if raw=true + :rtype: ~azure.ai.anomalydetector.models.LastDetectResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`AnomalyDetectorErrorException` + """ + # Construct URL + url = self.detect_last_point.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'DetectRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.AnomalyDetectorErrorException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('LastDetectResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + detect_last_point.metadata = {'url': '/timeseries/last/detect'} + + def detect_change_point( + self, body, custom_headers=None, raw=False, **operation_config): + """Detect change point for the entire series. + + Evaluate change point score of every series point. + + :param body: Time series points and granularity is needed. Advanced + model parameters can also be set in the request if needed. + :type body: ~azure.ai.anomalydetector.models.ChangePointDetectRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ChangePointDetectResponse or ClientRawResponse if raw=true + :rtype: ~azure.ai.anomalydetector.models.ChangePointDetectResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`AnomalyDetectorErrorException` + """ + # Construct URL + url = self.detect_change_point.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'ChangePointDetectRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.AnomalyDetectorErrorException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ChangePointDetectResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + detect_change_point.metadata = {'url': '/timeseries/changepoint/detect'} diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/version.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/version.py new file mode 100644 index 0000000000000..9bd1dfac7ecb6 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/version.py @@ -0,0 +1,13 @@ +# 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 = "0.2.0" + diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/sdk_packaging.toml b/sdk/anomalydetector/azure-ai-anomalydetector/sdk_packaging.toml new file mode 100644 index 0000000000000..31eb7d17e3d34 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/sdk_packaging.toml @@ -0,0 +1,8 @@ +[packaging] +package_name = "azure-ai-anomalydetector" +package_nspkg = "azure-ai-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = true diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/setup.cfg b/sdk/anomalydetector/azure-ai-anomalydetector/setup.cfg new file mode 100644 index 0000000000000..3c6e79cf31da1 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/setup.py b/sdk/anomalydetector/azure-ai-anomalydetector/setup.py new file mode 100644 index 0000000000000..55d457a28c20a --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/setup.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-ai-anomalydetector" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.ai', + ]), + install_requires=[ + 'msrest>=0.5.0', + 'msrestazure>=0.4.32,<2.0.0', + 'azure-common~=1.1', + ], + extras_require={ + ":python_version<'3.0'": ['azure-ai-nspkg'], + } +) diff --git a/sdk/anomalydetector/ci.yml b/sdk/anomalydetector/ci.yml new file mode 100644 index 0000000000000..add6c3b09c71c --- /dev/null +++ b/sdk/anomalydetector/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - master + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/ai-anomalydetector/ + +pr: + branches: + include: + - master + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/ai-anomalydetector/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: ai-anomalydetector + Artifacts: + - name: azure_mgmt_ai-anomalydetector + safeName: azuremgmtai-anomalydetector \ No newline at end of file