Skip to content

Commit

Permalink
Merge pull request #43 from teamdatatonic/feat/extending-model-monito…
Browse files Browse the repository at this point in the history
…ring-config

Extending model monitoring config
  • Loading branch information
felix-datatonic authored Jan 11, 2024
2 parents a5c6167 + c526bda commit c884b65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit c884b65

Please sign in to comment.