-
Notifications
You must be signed in to change notification settings - Fork 177
/
Copy pathcustom_validation_config.proto
153 lines (145 loc) · 5.27 KB
/
custom_validation_config.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================
syntax = "proto2";
package tensorflow.data_validation;
import "tensorflow_metadata/proto/v0/anomalies.proto";
import "tensorflow_metadata/proto/v0/path.proto";
// Use this proto to configure custom validations in TFDV.
// Example usages follow.
// -----------------------------------------------------------------------------
// Example Single-Feature Validation
// Statistics
// datasets {
// name: "All Examples"
// num_examples: 10
// features {
// path { step: 'test_feature' }
// type: INT
// num_stats { num_zeros: 5 max: 25 }
// }
// }
// CustomValidationConfig
// feature_validations {
// feature_path { step: 'test_feature' }
// validations {
// sql_expression: 'feature.num_stats.num_zeros < 3'
// severity: ERROR
// description: 'Feature has too many zeros.'
// }
// validations {
// sql_expression: 'feature.num_stats.max > 10'
// severity: ERROR
// description: 'Maximum value is too low.'
// }
// }
// Anomalies
// anomaly_info {
// key: 'test_feature'
// value: {
// path { step: 'test_feature' }
// severity: ERROR
// reason {
// type: CUSTOM_VALIDATION
// short_description: 'Feature has too many zeros.'
// description: 'Custom validation triggered anomaly. Query: feature.num_stats.num_zeros < 3 Test dataset: default slice'
// }
// }
// }
// -----------------------------------------------------------------------------
// Example Feature Pair Validation
// Statistics
// Test statistics
// datasets {
// name: "slice_1"
// num_examples: 10
// features {
// path { step: 'test_feature' }
// type: INT
// num_stats { num_zeros: 5 max: 25 }
// }
// }
// Base statistics
// datasets {
// name: "slice_2"
// num_examples: 10
// features {
// path { step: 'test_feature' }
// type: INT
// num_stats { num_zeros: 1 max: 1 }
// }
// }
// CustomValidationConfig
// feature_pair_validations {
// dataset_name: 'slice_1'
// feature_test_path { step: 'test_feature' }
// base_dataset_name: 'slice_2'
// feature_base_path { step: 'test_feature' }
// validations {
// sql_expression: 'feature_test.num_stats.num_zeros < feature_base.num_stats.num_zeros'
// severity: ERROR
// description: 'Test feature has too many zeros.'
// }
// }
// Anomalies
// anomaly_info {
// key: 'test_feature'
// value: {
// path { step: 'test_feature' }
// severity: ERROR
// reason {
// type: CUSTOM_VALIDATION
// short_description: 'Test feature has too many zeros.'
// description: 'Custom validation triggered anomaly. Query: feature_test.num_stats.num_zeros < feature_base.num_stats.num_zeros Test dataset: slice_1 Base dataset: slice_2 Base path: test_feature'
// }
// }
// }
// =============================================================================
message Validation {
// Expression to evaluate. If the expression returns false, the anomaly is
// returned.
// For single feature validations, the feature statistics are bound to
// `feature`. For feature pair validations, the test feature statistics are
// bound to `feature_test` and the base feature statistics are bound to
// `feature_base`.
optional string sql_expression = 1;
optional tensorflow.metadata.v0.AnomalyInfo.Severity severity = 2;
optional string description = 3;
// Use this to limit the data on which the validation runs to only the
// specified environments. If this field is not specified, the validation
// will always run.
repeated string in_environment = 4;
}
message FeatureValidation {
// The name of the dataset (i.e., slice) to validate. You do not need to
// specify this if using the default slice, provided there is no empty-named
// slice in the input statistics.
optional string dataset_name = 1;
optional tensorflow.metadata.v0.Path feature_path = 2;
repeated Validation validations = 3;
}
message FeaturePairValidation {
// The name of the dataset (i.e., slice) to validate. You do not need to
// specify this if using the default slice, provided there is no empty-named
// slice in the input statistics.
optional string dataset_name = 1;
optional string base_dataset_name = 2;
optional tensorflow.metadata.v0.Path feature_test_path = 3;
optional tensorflow.metadata.v0.Path feature_base_path = 4;
repeated Validation validations = 5;
}
message CustomValidationConfig {
repeated FeatureValidation feature_validations = 1;
repeated FeaturePairValidation feature_pair_validations = 2;
}