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

revert creation takes full object change #14957

Merged
merged 4 commits into from
Nov 3, 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
18 changes: 15 additions & 3 deletions sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

**Breaking Changes**

- `create_data_feed` now takes as input a `DataFeed` object
- `create_metric_anomaly_detection_configuration` now takes as input an `AnomalyDetectionConfiguration` object
- `create_anomaly_detection_configuration` now takes as input an `AnomalyAlertConfiguration` object
- `create_hook` now takes as input an `EmailHook` or `WebHook`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `create_hook` now takes as input an `EmailHook` or `WebHook`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually will we make the change to create_hook as well? It used to take the name parameter separate from the object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me the difference is
to take name+hook object -> to hook object only.

I don't think we should revert back to name+object.

- `Anomaly` has been renamed to `DataPointAnomaly`
- `Incident` has been renamed to `AnomalyIncident`
Expand All @@ -25,6 +22,21 @@
- `timestamp_list` has been renamed to `timestamps` on `MetricSeriesData`
- `value_list` has been renamed to `values` on `MetricSeriesData`
- `SeriesResult` has been renamed to `MetricEnrichedSeriesData`
- `create_anomaly_alert_configuration` has been renamed to `create_alert_configuration`
- `get_anomaly_alert_configuration` has been renamed to `get_alert_configuration`
- `delete_anomaly_alert_configuration` has been renamed to `delete_alert_configuration`
- `update_anomaly_alert_configuration` has been renamed to `update_alert_configuration`
- `list_anomaly_alert_configurations` has been renamed to `list_alert_configurations`
- `create_metric_anomaly_detection_configuration` has been renamed to `create_detection_configuration`
- `get_metric_anomaly_detection_configuration` has been renamed to `get_detection_configuration`
- `delete_metric_anomaly_detection_configuration` has been renamed to `delete_detection_configuration`
- `update_metric_anomaly_detection_configuration` has been renamed to `update_detection_configuration`
- `list_metric_anomaly_detection_configurations` has been renamed to `list_detection_configurations`
- `list_feedbacks` has been renamed to `list_feedback`
- `list_alerts_for_alert_configuration` has been renamed to `list_alerts`
- `list_anomalies_for_alert` & `list_anomalies_for_detection_configuration` have been grouped into `list_anomalies`
- `list_dimension_values_for_detection_configuration` has been renamed to `list_dimension_values`
- `list_incidents_for_alert` & `list_incidents_for_detection_configuration` have been grouped into `list_incidents`

**New Features**

Expand Down
26 changes: 6 additions & 20 deletions sdk/metricsadvisor/azure-ai-metricsadvisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ from azure.ai.metricsadvisor.models import (
DataFeedDimension,
DataFeedOptions,
DataFeedRollupSettings,
DataFeedMissingDataPointFillSettings,
DataFeedGranularity,
DataFeed
)

service_endpoint = os.getenv("ENDPOINT")
Expand All @@ -140,13 +137,13 @@ client = MetricsAdvisorAdministrationClient(
MetricsAdvisorKeyCredential(subscription_key, api_key)
)

data_feed = DataFeed(
data_feed = client.create_data_feed(
name="My data feed",
source=SQLServerDataFeed(
connection_string=sql_server_connection_string,
query=query,
),
granularity=DataFeedGranularity("Daily"),
granularity="Daily",
schema=DataFeedSchema(
metrics=[
DataFeedMetric(name="cost", display_name="Cost"),
Expand All @@ -158,9 +155,7 @@ data_feed = DataFeed(
],
timestamp_column="Timestamp"
),
ingestion_settings=DataFeedIngestionSettings(
ingestion_begin_time=datetime.datetime(2019, 10, 1)
),
ingestion_settings=datetime.datetime(2019, 10, 1),
options=DataFeedOptions(
data_feed_description="cost/revenue data feed",
rollup_settings=DataFeedRollupSettings(
Expand All @@ -175,9 +170,7 @@ data_feed = DataFeed(
)
)

my_sql_data_feed = client.create_data_feed(data_feed)

return my_sql_data_feed
return data_feed
```

### Check ingestion status
Expand Down Expand Up @@ -220,7 +213,6 @@ from azure.ai.metricsadvisor.models import (
SmartDetectionCondition,
SuppressCondition,
MetricDetectionCondition,
AnomalyDetectionConfiguration
)

service_endpoint = os.getenv("ENDPOINT")
Expand Down Expand Up @@ -260,7 +252,7 @@ smart_detection_condition = SmartDetectionCondition(
)
)

anomaly_detection_config = AnomalyDetectionConfiguration(
detection_config = client.create_detection_configuration(
name="my_detection_config",
metric_id=metric_id,
description="anomaly detection config for metric",
Expand All @@ -271,9 +263,6 @@ anomaly_detection_config = AnomalyDetectionConfiguration(
smart_detection_condition=smart_detection_condition
)
)

detection_config = client.create_detection_configuration(anomaly_detection_config)

return detection_config
```

Expand All @@ -291,7 +280,6 @@ from azure.ai.metricsadvisor.models import (
SeverityCondition,
MetricBoundaryCondition,
MetricAnomalyAlertSnoozeCondition,
AnomalyAlertConfiguration
)
service_endpoint = os.getenv("ENDPOINT")
subscription_key = os.getenv("SUBSCRIPTION_KEY")
Expand All @@ -304,7 +292,7 @@ client = MetricsAdvisorAdministrationClient(
MetricsAdvisorKeyCredential(subscription_key, api_key)
)

anomaly_alert_configuration = AnomalyAlertConfiguration(
alert_config = client.create_alert_configuration(
name="my alert config",
description="alert config description",
cross_metrics_operator="AND",
Expand Down Expand Up @@ -347,8 +335,6 @@ anomaly_alert_configuration = AnomalyAlertConfiguration(
hook_ids=[hook_id]
)

alert_config = client.create_anomaly_alert_configuration(anomaly_alert_configuration)

return alert_config
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
from msrest import Serializer
from azure.core.exceptions import HttpResponseError
from .models import (
DataFeedGranularityType,
DataFeedGranularity,
DataFeedSchema,
DataFeedMetric,
DataFeedIngestionSettings,
AnomalyFeedback,
ChangePointFeedback,
CommentFeedback,
Expand Down Expand Up @@ -125,6 +130,21 @@ def convert_to_generated_data_feed_type(
:return: The generated model for the data source type
"""

if isinstance(granularity, (DataFeedGranularityType, six.string_types)):
granularity = DataFeedGranularity(
granularity_type=granularity,
)

if isinstance(schema, list):
schema = DataFeedSchema(
metrics=[DataFeedMetric(name=metric_name) for metric_name in schema]
)

if isinstance(ingestion_settings, (datetime.datetime, six.string_types)):
ingestion_settings = DataFeedIngestionSettings(
ingestion_begin_time=ingestion_settings
)

return generated_feed_type(
data_source_parameter=source.__dict__,
data_feed_name=name,
Expand Down
Loading