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

Extending model monitoring config #43

Merged
merged 1 commit into from
Jan 11, 2024
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
8 changes: 7 additions & 1 deletion components/src/components/model_batch_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def model_batch_predict(
max_replica_count: int = 1,
monitoring_training_dataset: dict = None,
monitoring_alert_email_addresses: List[str] = None,
notification_channels: List[str] = [],
monitoring_skew_config: dict = None,
instance_config: dict = None,
):
Expand All @@ -62,6 +63,9 @@ def model_batch_predict(
https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1beta1.types.ModelMonitoringObjectiveConfig.TrainingPredictionSkewDetectionConfig
monitoring_alert_email_addresses (List[str]):
Email addresses to send alerts to (optional).
notification_channels (List[str]):
Notification channels to send alerts to (optional).
Format: projects/<project>/notificationChannels/<notification_channel>
monitoring_training_dataset (dict): Metadata of training dataset. See:
https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1beta1.types.ModelMonitoringObjectiveConfig.TrainingDataset
instance_config (dict): Configuration defining how to transform batch prediction
Expand Down Expand Up @@ -152,7 +156,9 @@ def is_job_successful(job_state: JobState) -> bool:

message["modelMonitoringConfig"] = {
"alertConfig": {
"emailAlertConfig": {"userEmails": monitoring_alert_email_addresses}
"emailAlertConfig": {"userEmails": monitoring_alert_email_addresses},
"notificationChannels": notification_channels,
"enableLogging": True,
},
"objectiveConfigs": [
{
Expand Down
2 changes: 2 additions & 0 deletions pipelines/src/pipelines/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
RESOURCE_SUFFIX = env.get("RESOURCE_SUFFIX", "default")
# set training-serving skew thresholds and emails to receive alerts:
ALERT_EMAILS = []
NOTIFICATION_CHANNELS = []
SKEW_THRESHOLDS = {"defaultSkewThreshold": {"value": 0.001}}
# or set different thresholds per feature:
# SKEW_THRESHOLDS = {"skewThresholds": {"payment_type": {"value": 0.001}}, ... }
Expand Down Expand Up @@ -109,6 +110,7 @@ def pipeline(
max_replica_count=max_replicas,
monitoring_training_dataset=lookup_op.outputs["training_dataset"],
monitoring_alert_email_addresses=ALERT_EMAILS,
notification_channels=NOTIFICATION_CHANNELS,
monitoring_skew_config=SKEW_THRESHOLDS,
)
.after(prep_op)
Expand Down