Skip to content

Commit

Permalink
Add support for disableTargetRollup analyzer option (#48)
Browse files Browse the repository at this point in the history
* Add support for disableTargetRollup analyzer option
* Add profileId to ColumnMatrix model
  • Loading branch information
vsuen committed Sep 22, 2023
1 parent 417715f commit a86a49b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
11 changes: 11 additions & 0 deletions whylabs_toolkit/monitor/manager/monitor_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, monitor_id: str, dataset_id: Optional[str] = None, config: Co
self._exclude_columns: Optional[List[str]] = []
self._monitor_tags: Optional[List[str]] = []
self._analyzer_tags: Optional[List[str]] = []
self._analyzer_disable_target_rollup: Optional[bool] = None
self._data_readiness_duration: Optional[str] = None

self._prefill_properties()
Expand Down Expand Up @@ -92,6 +93,7 @@ def _prefill_properties(self) -> None:
self._target_matrix = self.analyzer.targetMatrix
self._analyzer_config = self.analyzer.config
self._analyzer_tags = self.analyzer.tags
self._analyzer_disable_target_rollup = self.analyzer.disableTargetRollup

@property
def schedule(self) -> Optional[Union[CronSchedule, FixedCadenceSchedule]]:
Expand Down Expand Up @@ -174,6 +176,14 @@ def is_constraint(self, is_constraint: bool) -> None:
tags.discard(TAG_ANALYZER_CONSTRAINT)
self._analyzer_tags = list(tags)

@property
def disable_target_rollup(self) -> Optional[bool]:
return self._analyzer_disable_target_rollup == True

@disable_target_rollup.setter
def disable_target_rollup(self, disable_target_rollup: bool) -> None:
self._analyzer_disable_target_rollup = disable_target_rollup

@property
def data_readiness_duration(self) -> Optional[str]:
return self._data_readiness_duration
Expand Down Expand Up @@ -256,6 +266,7 @@ def __set_analyzer(self) -> None:
self.analyzer = Analyzer(
id=self.credentials.analyzer_id,
displayName=self.credentials.analyzer_id,
disableTargetRollup=self._analyzer_disable_target_rollup,
targetMatrix=self._target_matrix,
dataReadinessDuration=self._data_readiness_duration,
tags=self._analyzer_tags,
Expand Down
7 changes: 7 additions & 0 deletions whylabs_toolkit/monitor/models/analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ class Analyzer(NoExtrasBaseModel):
"This allows user to keep the configuration"
"around without having to delete the analyzer config",
)
disableTargetRollup: Optional[bool] = Field(
None,
description="For customers with individual profile storage enabled on their account (contact us), this "
"allows a user to monitor individual profiles without rolling them up. When enabled, analysis "
"will be timestamped 1:1 with the profile's dataset timestamp rather than being truncated "
"to the dataset granularity. ",
)
targetMatrix: Union[ColumnMatrix, DatasetMatrix] = Field(
description="A matrix for possible locations of the target",
discriminator="type",
Expand Down
5 changes: 5 additions & 0 deletions whylabs_toolkit/monitor/models/analyzer/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@ class ColumnMatrix(_BaseMatrix):
"evaluated AFTER the 'include' field and thus should be used with caution.",
max_items=1000,
)
profileId: Optional[str] = Field(
default=None,
description="The unique profile ID for the reference profile",
max_length=100,
)
32 changes: 24 additions & 8 deletions whylabs_toolkit/monitor/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,12 @@
}
]
}
},
"profileId": {
"title": "ProfileId",
"description": "The unique profile ID for the reference profile",
"maxLength": 100,
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -594,7 +600,8 @@
"classification.precision",
"classification.recall",
"classification.accuracy",
"classification.auc",
"classification.fpr",
"classification.auroc",
"regression.mse",
"regression.mae",
"regression.rmse"
Expand Down Expand Up @@ -649,7 +656,7 @@
},
"ThresholdType": {
"title": "ThresholdType",
"description": "Threshold Type declaring the upper and lower bound.\n\n By default an anomaly will be generated when the target is above or below the baseline\n by the specified threshold.\n\n If its only desirable to alert when the target is above the\n baseline and not the other way around, specify upper for your ThresholdType.\n ",
"description": "Threshold Type declaring the upper and lower bound.\n\nBy default an anomaly will be generated when the target is above or below the baseline\nby the specified threshold.\n\nIf its only desirable to alert when the target is above the\nbaseline and not the other way around, specify upper for your ThresholdType.",
"enum": [
"lower",
"upper"
Expand Down Expand Up @@ -1414,6 +1421,9 @@
"description": "Capping the minimum threshold by this value. This value only becomes effective if the calculated lower threshold from the calculation is lesser than this value",
"type": "number"
},
"thresholdType": {
"$ref": "#/definitions/ThresholdType"
},
"type": {
"title": "Type",
"enum": [
Expand Down Expand Up @@ -1505,9 +1515,9 @@
"default": "hellinger",
"enum": [
"hellinger",
"ks_test",
"jensenshannon",
"kl_divergence",
"variation_distance"
"psi"
],
"type": "string"
},
Expand Down Expand Up @@ -1714,6 +1724,9 @@
"description": "Capping the minimum threshold by this value. This value only becomes effective if the calculated lower threshold from the calculation is lesser than this value",
"type": "number"
},
"thresholdType": {
"$ref": "#/definitions/ThresholdType"
},
"type": {
"title": "Type",
"enum": [
Expand All @@ -1726,9 +1739,7 @@
"description": "The algorithm implementation for seasonal analysis",
"default": "arima",
"enum": [
"arima",
"rego",
"stastforecast"
"arima"
],
"type": "string"
},
Expand Down Expand Up @@ -1840,6 +1851,11 @@
"description": "Whether the analyzer is disabled. This allows user to keep the configurationaround without having to delete the analyzer config",
"type": "boolean"
},
"disableTargetRollup": {
"title": "Disabletargetrollup",
"description": "For customers with individual profile storage enabled on their account (contact us), this allows a user to monitor individual profiles without rolling them up. When enabled, analysis will be timestamped 1:1 with the profile's dataset timestamp rather than being truncated to the dataset granularity. ",
"type": "boolean"
},
"targetMatrix": {
"title": "Targetmatrix",
"description": "A matrix for possible locations of the target",
Expand Down Expand Up @@ -2365,4 +2381,4 @@
},
"$id": "https://gitlab.com/whylabs/core/montor-schema/-/blob/main/schema/schema.json",
"$version": "1.0"
}
}

0 comments on commit a86a49b

Please sign in to comment.