|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# Copyright 2022 Google LLC |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | +import proto # type: ignore |
| 17 | + |
| 18 | + |
| 19 | +__protobuf__ = proto.module( |
| 20 | + package="google.cloud.aiplatform.v1", manifest={"FeaturestoreMonitoringConfig",}, |
| 21 | +) |
| 22 | + |
| 23 | + |
| 24 | +class FeaturestoreMonitoringConfig(proto.Message): |
| 25 | + r"""Configuration of how features in Featurestore are monitored. |
| 26 | +
|
| 27 | + Attributes: |
| 28 | + snapshot_analysis (google.cloud.aiplatform_v1.types.FeaturestoreMonitoringConfig.SnapshotAnalysis): |
| 29 | + The config for Snapshot Analysis Based |
| 30 | + Feature Monitoring. |
| 31 | + import_features_analysis (google.cloud.aiplatform_v1.types.FeaturestoreMonitoringConfig.ImportFeaturesAnalysis): |
| 32 | + The config for ImportFeatures Analysis Based |
| 33 | + Feature Monitoring. |
| 34 | + numerical_threshold_config (google.cloud.aiplatform_v1.types.FeaturestoreMonitoringConfig.ThresholdConfig): |
| 35 | + Threshold for numerical features of anomaly detection. This |
| 36 | + is shared by all objectives of Featurestore Monitoring for |
| 37 | + numerical features (i.e. Features with type |
| 38 | + ([Feature.ValueType][google.cloud.aiplatform.v1.Feature.ValueType]) |
| 39 | + DOUBLE or INT64). |
| 40 | + categorical_threshold_config (google.cloud.aiplatform_v1.types.FeaturestoreMonitoringConfig.ThresholdConfig): |
| 41 | + Threshold for categorical features of anomaly detection. |
| 42 | + This is shared by all types of Featurestore Monitoring for |
| 43 | + categorical features (i.e. Features with type |
| 44 | + ([Feature.ValueType][google.cloud.aiplatform.v1.Feature.ValueType]) |
| 45 | + BOOL or STRING). |
| 46 | + """ |
| 47 | + |
| 48 | + class SnapshotAnalysis(proto.Message): |
| 49 | + r"""Configuration of the Featurestore's Snapshot Analysis Based |
| 50 | + Monitoring. This type of analysis generates statistics for each |
| 51 | + Feature based on a snapshot of the latest feature value of each |
| 52 | + entities every monitoring_interval. |
| 53 | +
|
| 54 | + Attributes: |
| 55 | + disabled (bool): |
| 56 | + The monitoring schedule for snapshot analysis. For |
| 57 | + EntityType-level config: unset / disabled = true indicates |
| 58 | + disabled by default for Features under it; otherwise by |
| 59 | + default enable snapshot analysis monitoring with |
| 60 | + monitoring_interval for Features under it. Feature-level |
| 61 | + config: disabled = true indicates disabled regardless of the |
| 62 | + EntityType-level config; unset monitoring_interval indicates |
| 63 | + going with EntityType-level config; otherwise run snapshot |
| 64 | + analysis monitoring with monitoring_interval regardless of |
| 65 | + the EntityType-level config. Explicitly Disable the snapshot |
| 66 | + analysis based monitoring. |
| 67 | + monitoring_interval_days (int): |
| 68 | + Configuration of the snapshot analysis based monitoring |
| 69 | + pipeline running interval. The value indicates number of |
| 70 | + days. If both |
| 71 | + [FeaturestoreMonitoringConfig.SnapshotAnalysis.monitoring_interval_days][google.cloud.aiplatform.v1.FeaturestoreMonitoringConfig.SnapshotAnalysis.monitoring_interval_days] |
| 72 | + and |
| 73 | + [FeaturestoreMonitoringConfig.SnapshotAnalysis.monitoring_interval][] |
| 74 | + are set when creating/updating EntityTypes/Features, |
| 75 | + [FeaturestoreMonitoringConfig.SnapshotAnalysis.monitoring_interval_days][google.cloud.aiplatform.v1.FeaturestoreMonitoringConfig.SnapshotAnalysis.monitoring_interval_days] |
| 76 | + will be used. |
| 77 | + staleness_days (int): |
| 78 | + Customized export features time window for |
| 79 | + snapshot analysis. Unit is one day. Default |
| 80 | + value is 3 weeks. Minimum value is 1 day. |
| 81 | + Maximum value is 4000 days. |
| 82 | + """ |
| 83 | + |
| 84 | + disabled = proto.Field(proto.BOOL, number=1,) |
| 85 | + monitoring_interval_days = proto.Field(proto.INT32, number=3,) |
| 86 | + staleness_days = proto.Field(proto.INT32, number=4,) |
| 87 | + |
| 88 | + class ImportFeaturesAnalysis(proto.Message): |
| 89 | + r"""Configuration of the Featurestore's ImportFeature Analysis Based |
| 90 | + Monitoring. This type of analysis generates statistics for values of |
| 91 | + each Feature imported by every [ImportFeatureValues][] operation. |
| 92 | +
|
| 93 | + Attributes: |
| 94 | + state (google.cloud.aiplatform_v1.types.FeaturestoreMonitoringConfig.ImportFeaturesAnalysis.State): |
| 95 | + Whether to enable / disable / inherite |
| 96 | + default hebavior for import features analysis. |
| 97 | + anomaly_detection_baseline (google.cloud.aiplatform_v1.types.FeaturestoreMonitoringConfig.ImportFeaturesAnalysis.Baseline): |
| 98 | + The baseline used to do anomaly detection for |
| 99 | + the statistics generated by import features |
| 100 | + analysis. |
| 101 | + """ |
| 102 | + |
| 103 | + class State(proto.Enum): |
| 104 | + r"""The state defines whether to enable ImportFeature analysis.""" |
| 105 | + STATE_UNSPECIFIED = 0 |
| 106 | + DEFAULT = 1 |
| 107 | + ENABLED = 2 |
| 108 | + DISABLED = 3 |
| 109 | + |
| 110 | + class Baseline(proto.Enum): |
| 111 | + r"""Defines the baseline to do anomaly detection for feature values |
| 112 | + imported by each [ImportFeatureValues][] operation. |
| 113 | + """ |
| 114 | + BASELINE_UNSPECIFIED = 0 |
| 115 | + LATEST_STATS = 1 |
| 116 | + MOST_RECENT_SNAPSHOT_STATS = 2 |
| 117 | + PREVIOUS_IMPORT_FEATURES_STATS = 3 |
| 118 | + |
| 119 | + state = proto.Field( |
| 120 | + proto.ENUM, |
| 121 | + number=1, |
| 122 | + enum="FeaturestoreMonitoringConfig.ImportFeaturesAnalysis.State", |
| 123 | + ) |
| 124 | + anomaly_detection_baseline = proto.Field( |
| 125 | + proto.ENUM, |
| 126 | + number=2, |
| 127 | + enum="FeaturestoreMonitoringConfig.ImportFeaturesAnalysis.Baseline", |
| 128 | + ) |
| 129 | + |
| 130 | + class ThresholdConfig(proto.Message): |
| 131 | + r"""The config for Featurestore Monitoring threshold. |
| 132 | +
|
| 133 | + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields |
| 134 | +
|
| 135 | + Attributes: |
| 136 | + value (float): |
| 137 | + Specify a threshold value that can trigger |
| 138 | + the alert. 1. For categorical feature, the |
| 139 | + distribution distance is calculated by |
| 140 | + L-inifinity norm. |
| 141 | + 2. For numerical feature, the distribution |
| 142 | + distance is calculated by Jensen–Shannon |
| 143 | + divergence. Each feature must have a non-zero |
| 144 | + threshold if they need to be monitored. |
| 145 | + Otherwise no alert will be triggered for that |
| 146 | + feature. |
| 147 | +
|
| 148 | + This field is a member of `oneof`_ ``threshold``. |
| 149 | + """ |
| 150 | + |
| 151 | + value = proto.Field(proto.DOUBLE, number=1, oneof="threshold",) |
| 152 | + |
| 153 | + snapshot_analysis = proto.Field(proto.MESSAGE, number=1, message=SnapshotAnalysis,) |
| 154 | + import_features_analysis = proto.Field( |
| 155 | + proto.MESSAGE, number=2, message=ImportFeaturesAnalysis, |
| 156 | + ) |
| 157 | + numerical_threshold_config = proto.Field( |
| 158 | + proto.MESSAGE, number=3, message=ThresholdConfig, |
| 159 | + ) |
| 160 | + categorical_threshold_config = proto.Field( |
| 161 | + proto.MESSAGE, number=4, message=ThresholdConfig, |
| 162 | + ) |
| 163 | + |
| 164 | + |
| 165 | +__all__ = tuple(sorted(__protobuf__.manifest)) |
0 commit comments