22
22
from tensorflow_data_validation .anomalies .proto import custom_validation_config_pb2
23
23
from tfx .components .distribution_validator import executor
24
24
from tfx .dsl .io import fileio
25
- from tfx .orchestration .experimental .core import component_generated_alert_pb2
26
- from tfx .orchestration .experimental .core import constants
27
25
from tfx .proto import distribution_validator_pb2
28
26
from tfx .types import artifact_utils
29
27
from tfx .types import standard_artifacts
@@ -215,23 +213,6 @@ def testSplitPairs(self, split_pairs, expected_split_pair_names,
215
213
}
216
214
""" ,
217
215
'anomalies_blessed_value' : 0 ,
218
- 'expected_alerts' : (
219
- component_generated_alert_pb2 .ComponentGeneratedAlertList (
220
- component_generated_alert_list = [
221
- component_generated_alert_pb2 .ComponentGeneratedAlertInfo (
222
- alert_name = (
223
- '[train_eval][span 2] Feature-level anomalies '
224
- 'present'
225
- ),
226
- alert_body = (
227
- '[train_eval][span 2] Feature(s) company, '
228
- 'dropoff_census_tract contain(s) anomalies. See '
229
- 'Anomalies artifact for more details.'
230
- ),
231
- ),
232
- ]
233
- )
234
- )
235
216
},
236
217
{
237
218
'testcase_name' : 'dataset_constraint' ,
@@ -255,24 +236,6 @@ def testSplitPairs(self, split_pairs, expected_split_pair_names,
255
236
}
256
237
}""" ,
257
238
'anomalies_blessed_value' : 0 ,
258
- 'expected_alerts' : (
259
- component_generated_alert_pb2 .ComponentGeneratedAlertList (
260
- component_generated_alert_list = [
261
- component_generated_alert_pb2 .ComponentGeneratedAlertInfo (
262
- alert_name = (
263
- '[train_eval][span 2] High num examples in '
264
- 'current dataset versus the previous span.'
265
- ),
266
- alert_body = (
267
- '[train_eval][span 2] The ratio of num examples '
268
- 'in the current dataset versus the previous span '
269
- 'is 2.02094 (up to six significant digits), '
270
- 'which is above the threshold 1.'
271
- ),
272
- ),
273
- ]
274
- )
275
- )
276
239
},
277
240
{
278
241
'testcase_name' : 'no_anomalies' ,
@@ -305,9 +268,6 @@ def testSplitPairs(self, split_pairs, expected_split_pair_names,
305
268
}
306
269
""" ,
307
270
'anomalies_blessed_value' : 1 ,
308
- 'expected_alerts' : (
309
- component_generated_alert_pb2 .ComponentGeneratedAlertList ()
310
- ),
311
271
},
312
272
{
313
273
'testcase_name' : 'custom_anomalies' ,
@@ -367,23 +327,6 @@ def testSplitPairs(self, split_pairs, expected_split_pair_names,
367
327
}
368
328
""" ,
369
329
'anomalies_blessed_value' : 0 ,
370
- 'expected_alerts' : (
371
- component_generated_alert_pb2 .ComponentGeneratedAlertList (
372
- component_generated_alert_list = [
373
- component_generated_alert_pb2 .ComponentGeneratedAlertInfo (
374
- alert_name = (
375
- '[train_eval][span 2] Feature-level anomalies '
376
- 'present'
377
- ),
378
- alert_body = (
379
- '[train_eval][span 2] Feature(s) company '
380
- 'contain(s) anomalies. See Anomalies artifact '
381
- 'for more details.'
382
- ),
383
- )
384
- ]
385
- )
386
- )
387
330
},
388
331
)
389
332
def testAnomaliesGenerated (
@@ -392,7 +335,6 @@ def testAnomaliesGenerated(
392
335
custom_validation_config ,
393
336
expected_anomalies ,
394
337
anomalies_blessed_value ,
395
- expected_alerts ,
396
338
):
397
339
source_data_dir = os .path .join (
398
340
os .path .dirname (os .path .dirname (__file__ )), 'testdata' )
@@ -438,7 +380,7 @@ def testAnomaliesGenerated(
438
380
}
439
381
440
382
distribution_validator_executor = executor .Executor ()
441
- executor_output = distribution_validator_executor .Do (
383
+ distribution_validator_executor .Do (
442
384
input_dict , output_dict , exec_properties
443
385
)
444
386
@@ -465,27 +407,6 @@ def testAnomaliesGenerated(
465
407
),
466
408
{'train_eval' : anomalies_blessed_value },
467
409
)
468
- actual_alerts = (
469
- component_generated_alert_pb2 .ComponentGeneratedAlertList ()
470
- )
471
- executor_output .execution_properties [
472
- constants .COMPONENT_GENERATED_ALERTS_KEY
473
- ].proto_value .Unpack (actual_alerts )
474
- for alert in expected_alerts .component_generated_alert_list :
475
- self .assertEqual (
476
- alert .alert_name ,
477
- actual_alerts .component_generated_alert_list [0 ].alert_name
478
- )
479
- if 'Feature-level anomalies present' in alert .alert_name :
480
- self .assertIn (
481
- 'See Anomalies artifact for more details.' ,
482
- actual_alerts .component_generated_alert_list [0 ].alert_body ,
483
- )
484
- else :
485
- self .assertEqual (
486
- alert .alert_body ,
487
- actual_alerts .component_generated_alert_list [0 ].alert_body
488
- )
489
410
490
411
def testMissBaselineStats (self ):
491
412
@@ -682,19 +603,6 @@ def testStructData(self):
682
603
}
683
604
}""" , anomalies_pb2 .Anomalies ())
684
605
685
- expected_alerts = component_generated_alert_pb2 .ComponentGeneratedAlertList (
686
- component_generated_alert_list = [
687
- component_generated_alert_pb2 .ComponentGeneratedAlertInfo (
688
- alert_name = (
689
- '[train_eval][span 3] Feature-level anomalies present' ),
690
- alert_body = (
691
- '[train_eval][span 3] Feature(s) '
692
- 'parent_feature.value_feature contain(s) anomalies. See '
693
- 'Anomalies artifact for more details.' ),
694
- )
695
- ],
696
- )
697
-
698
606
# Create stats artifacts with a struct feature.
699
607
for split_dir in ['Split-eval' , 'Split-train' ]:
700
608
full_split_dir = os .path .join (stats_artifact .uri , split_dir )
@@ -733,7 +641,7 @@ def testStructData(self):
733
641
}
734
642
735
643
distribution_validator_executor = executor .Executor ()
736
- executor_output = distribution_validator_executor .Do (
644
+ distribution_validator_executor .Do (
737
645
input_dict , output_dict , exec_properties
738
646
)
739
647
@@ -752,14 +660,6 @@ def testStructData(self):
752
660
distribution_anomalies .ParseFromString (distribution_anomalies_bytes )
753
661
self .assertEqualExceptBaseline (expected_anomalies , distribution_anomalies )
754
662
755
- actual_alerts = (
756
- component_generated_alert_pb2 .ComponentGeneratedAlertList ()
757
- )
758
- executor_output .execution_properties [
759
- constants .COMPONENT_GENERATED_ALERTS_KEY
760
- ].proto_value .Unpack (actual_alerts )
761
- self .assertEqual (actual_alerts , expected_alerts )
762
-
763
663
@parameterized .named_parameters (
764
664
{
765
665
'testcase_name' :
@@ -1076,7 +976,7 @@ def testEmptyData(self, stats_train, stats_eval, expected_anomalies):
1076
976
}
1077
977
1078
978
distribution_validator_executor = executor .Executor ()
1079
- executor_output = distribution_validator_executor .Do (
979
+ distribution_validator_executor .Do (
1080
980
input_dict , output_dict , exec_properties
1081
981
)
1082
982
@@ -1099,26 +999,6 @@ def testEmptyData(self, stats_train, stats_eval, expected_anomalies):
1099
999
distribution_anomalies .ParseFromString (distribution_anomalies_bytes )
1100
1000
self .assertEqualExceptBaseline (expected_anomalies , distribution_anomalies )
1101
1001
1102
- expected_alerts = component_generated_alert_pb2 .ComponentGeneratedAlertList (
1103
- component_generated_alert_list = [
1104
- component_generated_alert_pb2 .ComponentGeneratedAlertInfo (
1105
- alert_name = (
1106
- '[train_eval][span 4] Feature-level anomalies present'
1107
- ),
1108
- alert_body = (
1109
- '[train_eval][span 4] Feature(s) first_feature contain(s) '
1110
- 'anomalies. See Anomalies artifact for more details.'
1111
- ),
1112
- ),
1113
- ]
1114
- )
1115
- actual_alerts = (
1116
- component_generated_alert_pb2 .ComponentGeneratedAlertList ()
1117
- )
1118
- executor_output .execution_properties [
1119
- constants .COMPONENT_GENERATED_ALERTS_KEY
1120
- ].proto_value .Unpack (actual_alerts )
1121
- self .assertEqual (actual_alerts , expected_alerts )
1122
1002
1123
1003
def testAddOutput (self ):
1124
1004
source_data_dir = os .path .join (
@@ -1184,7 +1064,7 @@ def testAddOutput(self):
1184
1064
}
1185
1065
1186
1066
distribution_validator_executor = executor .Executor ()
1187
- executor_output = distribution_validator_executor .Do (
1067
+ distribution_validator_executor .Do (
1188
1068
input_dict , output_dict , exec_properties
1189
1069
)
1190
1070
@@ -1193,27 +1073,6 @@ def testAddOutput(self):
1193
1073
)
1194
1074
self .assertTrue (fileio .exists (distribution_anomalies_path ))
1195
1075
1196
- expected_alerts = component_generated_alert_pb2 .ComponentGeneratedAlertList (
1197
- component_generated_alert_list = [
1198
- component_generated_alert_pb2 .ComponentGeneratedAlertInfo (
1199
- alert_name = (
1200
- '[train_eval][span 5] Feature-level anomalies present'
1201
- ),
1202
- alert_body = (
1203
- '[train_eval][span 5] Feature(s) '
1204
- 'parent_feature.value_feature contain(s) anomalies. See '
1205
- 'Anomalies artifact for more details.'
1206
- ),
1207
- ),
1208
- ]
1209
- )
1210
- actual_alerts = (
1211
- component_generated_alert_pb2 .ComponentGeneratedAlertList ()
1212
- )
1213
- executor_output .execution_properties [
1214
- constants .COMPONENT_GENERATED_ALERTS_KEY
1215
- ].proto_value .Unpack (actual_alerts )
1216
- self .assertEqual (actual_alerts , expected_alerts )
1217
1076
1218
1077
def testUseArtifactDVConfig (self ):
1219
1078
source_data_dir = os .path .join (
0 commit comments