|
34 | 34 | } |
35 | 35 | OUTPUT_NAME_MAPPINGS: dict[str, str] = {"predict": WILL_DEFAULT} |
36 | 36 |
|
| 37 | +FAIRNESS_METRICS = [TrustyAIServiceMetrics.Fairness.SPD, TrustyAIServiceMetrics.Fairness.DIR] |
| 38 | + |
37 | 39 |
|
38 | 40 | def get_fairness_request_json_data(isvc: InferenceService) -> dict[str, Any]: |
39 | 41 | return { |
@@ -102,51 +104,50 @@ def test_name_mappings_with_pvc_storage( |
102 | 104 | output_mappings=OUTPUT_NAME_MAPPINGS, |
103 | 105 | ) |
104 | 106 |
|
105 | | - def test_fairness_metric_spd_with_pvc_storage( |
106 | | - self, admin_client, current_client_token, trustyai_service_with_pvc_storage, onnx_loan_model |
| 107 | + @pytest.mark.parametrize("metric_name", FAIRNESS_METRICS) |
| 108 | + def test_fairness_metric_with_pvc_storage( |
| 109 | + self, admin_client, current_client_token, trustyai_service_with_pvc_storage, onnx_loan_model, metric_name |
107 | 110 | ): |
108 | 111 | verify_trustyai_service_metric_request( |
109 | 112 | client=admin_client, |
110 | 113 | trustyai_service=trustyai_service_with_pvc_storage, |
111 | 114 | token=current_client_token, |
112 | | - metric_name=TrustyAIServiceMetrics.Fairness.SPD, |
| 115 | + metric_name=metric_name, |
113 | 116 | json_data=get_fairness_request_json_data(isvc=onnx_loan_model), |
114 | 117 | ) |
115 | 118 |
|
116 | | - def test_fairness_metric_schedule_spd_with_pvc_storage( |
117 | | - self, admin_client, current_client_token, trustyai_service_with_pvc_storage, onnx_loan_model |
| 119 | + @pytest.mark.parametrize("metric_name", FAIRNESS_METRICS) |
| 120 | + def test_fairness_metric_schedule_with_pvc_storage( |
| 121 | + self, admin_client, current_client_token, trustyai_service_with_pvc_storage, onnx_loan_model, metric_name |
118 | 122 | ): |
119 | 123 | verify_trustyai_service_metric_scheduling_request( |
120 | 124 | client=admin_client, |
121 | 125 | trustyai_service=trustyai_service_with_pvc_storage, |
122 | 126 | token=current_client_token, |
123 | | - metric_name=TrustyAIServiceMetrics.Fairness.SPD, |
| 127 | + metric_name=metric_name, |
124 | 128 | json_data=get_fairness_request_json_data(isvc=onnx_loan_model), |
125 | 129 | ) |
126 | 130 |
|
| 131 | + @pytest.mark.parametrize("metric_name", FAIRNESS_METRICS) |
127 | 132 | def test_fairness_metric_prometheus( |
128 | | - self, |
129 | | - admin_client, |
130 | | - model_namespace, |
131 | | - trustyai_service_with_pvc_storage, |
132 | | - onnx_loan_model, |
133 | | - prometheus, |
| 133 | + self, admin_client, model_namespace, trustyai_service_with_pvc_storage, onnx_loan_model, prometheus, metric_name |
134 | 134 | ): |
135 | 135 | validate_metrics_field( |
136 | 136 | prometheus=prometheus, |
137 | | - metrics_query=f'trustyai_{TrustyAIServiceMetrics.Fairness.SPD}{{namespace="{model_namespace.name}"}}', |
138 | | - expected_value=TrustyAIServiceMetrics.Fairness.SPD.upper(), |
| 137 | + metrics_query=f'trustyai_{metric_name}{{namespace="{model_namespace.name}"}}', |
| 138 | + expected_value=metric_name.upper(), |
139 | 139 | field_getter=partial(get_metric_label, label_name="metricName"), |
140 | 140 | ) |
141 | 141 |
|
| 142 | + @pytest.mark.parametrize("metric_name", FAIRNESS_METRICS) |
142 | 143 | def test_fairness_metric_delete_with_pvc_storage( |
143 | | - self, admin_client, current_client_token, trustyai_service_with_pvc_storage, onnx_loan_model |
| 144 | + self, admin_client, current_client_token, trustyai_service_with_pvc_storage, onnx_loan_model, metric_name |
144 | 145 | ): |
145 | 146 | verify_trustyai_service_metric_delete_request( |
146 | 147 | client=admin_client, |
147 | 148 | trustyai_service=trustyai_service_with_pvc_storage, |
148 | 149 | token=current_client_token, |
149 | | - metric_name=TrustyAIServiceMetrics.Fairness.SPD, |
| 150 | + metric_name=metric_name, |
150 | 151 | ) |
151 | 152 |
|
152 | 153 |
|
@@ -204,34 +205,37 @@ def test_name_mappings_with_db_storage( |
204 | 205 | output_mappings=OUTPUT_NAME_MAPPINGS, |
205 | 206 | ) |
206 | 207 |
|
207 | | - def test_fairness_metric_spd_with_db_storage( |
208 | | - self, admin_client, current_client_token, trustyai_service_with_db_storage, onnx_loan_model |
| 208 | + @pytest.mark.parametrize("metric_name", FAIRNESS_METRICS) |
| 209 | + def test_fairness_metric_with_db_storage( |
| 210 | + self, admin_client, current_client_token, trustyai_service_with_db_storage, onnx_loan_model, metric_name |
209 | 211 | ): |
210 | 212 | verify_trustyai_service_metric_request( |
211 | 213 | client=admin_client, |
212 | 214 | trustyai_service=trustyai_service_with_db_storage, |
213 | 215 | token=current_client_token, |
214 | | - metric_name=TrustyAIServiceMetrics.Fairness.SPD, |
| 216 | + metric_name=metric_name, |
215 | 217 | json_data=get_fairness_request_json_data(isvc=onnx_loan_model), |
216 | 218 | ) |
217 | 219 |
|
218 | | - def test_fairness_metric_schedule_spd_with_db_storage( |
219 | | - self, admin_client, current_client_token, trustyai_service_with_db_storage, onnx_loan_model |
| 220 | + @pytest.mark.parametrize("metric_name", FAIRNESS_METRICS) |
| 221 | + def test_fairness_metric_schedule_with_db_storage( |
| 222 | + self, admin_client, current_client_token, trustyai_service_with_db_storage, onnx_loan_model, metric_name |
220 | 223 | ): |
221 | 224 | verify_trustyai_service_metric_scheduling_request( |
222 | 225 | client=admin_client, |
223 | 226 | trustyai_service=trustyai_service_with_db_storage, |
224 | 227 | token=current_client_token, |
225 | | - metric_name=TrustyAIServiceMetrics.Fairness.SPD, |
| 228 | + metric_name=metric_name, |
226 | 229 | json_data=get_fairness_request_json_data(isvc=onnx_loan_model), |
227 | 230 | ) |
228 | 231 |
|
| 232 | + @pytest.mark.parametrize("metric_name", FAIRNESS_METRICS) |
229 | 233 | def test_fairness_metric_delete_with_db_storage( |
230 | | - self, admin_client, current_client_token, trustyai_service_with_db_storage, onnx_loan_model |
| 234 | + self, admin_client, current_client_token, trustyai_service_with_db_storage, onnx_loan_model, metric_name |
231 | 235 | ): |
232 | 236 | verify_trustyai_service_metric_delete_request( |
233 | 237 | client=admin_client, |
234 | 238 | trustyai_service=trustyai_service_with_db_storage, |
235 | 239 | token=current_client_token, |
236 | | - metric_name=TrustyAIServiceMetrics.Fairness.SPD, |
| 240 | + metric_name=metric_name, |
237 | 241 | ) |
0 commit comments