-
Notifications
You must be signed in to change notification settings - Fork 154
Added support for anomaly check config #45
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
base: master
Are you sure you want to change the base?
Changes from all commits
c28bb9c
a3945ca
6d009bc
1201899
8a89e32
b24ca4d
71a3110
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,7 +181,8 @@ def OnlineNormalStrategy( | |
| print(df.collect()) | ||
| return df.select("check_status").collect() | ||
|
|
||
| def SimpleThresholdStrategy(self, df_prev, df_curr, analyzer_func, lowerBound, upperBound): | ||
| def SimpleThresholdStrategy(self, df_prev, df_curr, analyzer_func, lowerBound, upperBound, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DESIGN: Only the
|
||
| anomalyCheckConfig: AnomalyCheckConfig = None): | ||
| metricsRepository = InMemoryMetricsRepository(self.spark) | ||
| previousKey = ResultKey(self.spark, ResultKey.current_milli_time() - 24 * 60 * 1000 * 60) | ||
|
|
||
|
|
@@ -196,7 +197,7 @@ def SimpleThresholdStrategy(self, df_prev, df_curr, analyzer_func, lowerBound, u | |
| .onData(df_curr) | ||
| .useRepository(metricsRepository) | ||
| .saveOrAppendResult(currKey) | ||
| .addAnomalyCheck(SimpleThresholdStrategy(lowerBound, upperBound), analyzer_func) | ||
| .addAnomalyCheck(SimpleThresholdStrategy(lowerBound, upperBound), analyzer_func, anomalyCheckConfig) | ||
| .run() | ||
| ) | ||
|
|
||
|
|
@@ -486,6 +487,20 @@ def get_anomalyDetector(self, anomaly): | |
| def test_anomalyDetector(self): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MISSING_TEST: The new tests only cover
|
||
| self.get_anomalyDetector(SimpleThresholdStrategy(1.0, 3.0)) | ||
|
|
||
| def test_SimpleThresholdStrategy_Error(self): | ||
| config = AnomalyCheckConfig(description='test error case', level=CheckLevel.Error) | ||
| # Lower bound is 1 upper bound is 6 (Range: 1-6 rows) | ||
| self.assertEqual( | ||
| self.SimpleThresholdStrategy(self.df_1, self.df_2, Size(), 1.0, 4.0, config), [Row(check_status="Error")] | ||
| ) | ||
|
|
||
| def test_SimpleThresholdStrategy_Warning(self): | ||
| config = AnomalyCheckConfig(description='test error case', level=CheckLevel.Warning) | ||
| # Lower bound is 1 upper bound is 6 (Range: 1-6 rows) | ||
| self.assertEqual( | ||
| self.SimpleThresholdStrategy(self.df_1, self.df_2, Size(), 1.0, 4.0, config), [Row(check_status="Warning")] | ||
| ) | ||
|
|
||
| # | ||
| # def test_RelativeRateOfChangeStrategy(self): | ||
| # metricsRepository = InMemoryMetricsRepository(self.spark) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MISSING_TEST: The
AnomalyCheckConfigclass has no dedicated unit test for its_get_java_objectmethod. If the Deequ JVM classcom.amazon.deequ.AnomalyCheckConfigdoesn't exist or has a different constructor signature (e.g., different number of default arguments), this will fail at runtime with no clear error message.