@@ -97,7 +97,10 @@ def __init__(
97
97
test_suite_ids = [test_suite ._id ],
98
98
config = config ,
99
99
)
100
- res = krequests .post (endpoint_path = API .Path .CREATE_OR_RETRIEVE , data = json .dumps (dataclasses .asdict (request )))
100
+ res = krequests .post (
101
+ endpoint_path = API .Path .CREATE_OR_RETRIEVE .value ,
102
+ data = json .dumps (dataclasses .asdict (request )),
103
+ )
101
104
krequests .raise_for_status (res )
102
105
response = from_dict (data_class = API .CreateOrRetrieveResponse , data = res .json ())
103
106
self ._id = response .test_run_id
@@ -128,7 +131,7 @@ def __exit__(
128
131
self ._submit_custom_metrics ()
129
132
self ._active = False
130
133
if exc_type is not None :
131
- report_crash (self ._id , API .Path .MARK_CRASHED )
134
+ report_crash (self ._id , API .Path .MARK_CRASHED . value )
132
135
133
136
@validate_arguments (config = ValidatorConfig )
134
137
def add_inferences (self , image : _TestImageClass , inferences : Optional [List [_InferenceClass ]]) -> None :
@@ -160,7 +163,7 @@ def add_inferences(self, image: _TestImageClass, inferences: Optional[List[_Infe
160
163
161
164
self ._inferences [image_id ] = context_image_inferences
162
165
163
- if self ._n_inferences >= _BatchSize .UPLOAD_RESULTS :
166
+ if self ._n_inferences >= _BatchSize .UPLOAD_RESULTS . value :
164
167
log .info (f"uploading batch of '{ self ._n_inferences } ' inference results" )
165
168
self ._upload_chunk ()
166
169
log .success (f"uploaded batch of '{ self ._n_inferences } ' inference results" )
@@ -176,7 +179,7 @@ def iter_images(self) -> Iterator[_TestImageClass]:
176
179
yield self ._image_from_load_image_record (record )
177
180
178
181
@validate_arguments (config = ValidatorConfig )
179
- def load_images (self , batch_size : int = _BatchSize .LOAD_SAMPLES ) -> List [_TestImageClass ]:
182
+ def load_images (self , batch_size : int = _BatchSize .LOAD_SAMPLES . value ) -> List [_TestImageClass ]:
180
183
"""
181
184
Returns a list of images that still need inferences evaluated, bounded in count
182
185
by batch_size. Note that image ground truths will be excluded from the returned
@@ -195,7 +198,10 @@ def load_images(self, batch_size: int = _BatchSize.LOAD_SAMPLES) -> List[_TestIm
195
198
return [self ._image_from_load_image_record (record ) for record in df_image_batch .itertuples ()]
196
199
197
200
@validate_arguments (config = ValidatorConfig )
198
- def _iter_image_batch (self , batch_size : int = _BatchSize .LOAD_SAMPLES ) -> Iterator [_LoadTestImagesDataFrameClass ]:
201
+ def _iter_image_batch (
202
+ self ,
203
+ batch_size : int = _BatchSize .LOAD_SAMPLES .value ,
204
+ ) -> Iterator [_LoadTestImagesDataFrameClass ]:
199
205
if batch_size <= 0 :
200
206
raise InputValidationError (f"invalid batch_size '{ batch_size } ': expected positive integer" )
201
207
init_request = API .InitLoadRemainingImagesRequest (
@@ -205,7 +211,7 @@ def _iter_image_batch(self, batch_size: int = _BatchSize.LOAD_SAMPLES) -> Iterat
205
211
)
206
212
yield from _BatchedLoader .iter_data (
207
213
init_request = init_request ,
208
- endpoint_path = API .Path .INIT_LOAD_REMAINING_IMAGES ,
214
+ endpoint_path = API .Path .INIT_LOAD_REMAINING_IMAGES . value ,
209
215
df_class = self ._LoadTestImagesDataFrameClass ,
210
216
)
211
217
@@ -239,7 +245,7 @@ def _finalize_upload(self) -> None:
239
245
log .info ("finalizing inference upload for test run" )
240
246
request = API .UploadImageResultsRequest (uuid = self ._upload_uuid , test_run_id = self ._id , reset = self ._reset )
241
247
finalize_res = krequests .put (
242
- endpoint_path = API .Path .UPLOAD_IMAGE_RESULTS ,
248
+ endpoint_path = API .Path .UPLOAD_IMAGE_RESULTS . value ,
243
249
data = json .dumps (dataclasses .asdict (request )),
244
250
)
245
251
krequests .raise_for_status (finalize_res )
@@ -289,6 +295,9 @@ def _submit_custom_metrics(self) -> None:
289
295
log .info ("submitting custom metrics for test run" )
290
296
custom_metrics = self ._compute_custom_metrics ()
291
297
request = API .UpdateCustomMetricsRequest (model_id = self ._model ._id , metrics = custom_metrics )
292
- res = krequests .put (endpoint_path = API .Path .UPLOAD_CUSTOM_METRICS , data = json .dumps (dataclasses .asdict (request )))
298
+ res = krequests .put (
299
+ endpoint_path = API .Path .UPLOAD_CUSTOM_METRICS .value ,
300
+ data = json .dumps (dataclasses .asdict (request )),
301
+ )
293
302
krequests .raise_for_status (res )
294
303
log .success ("submitted custom metrics for test run" )
0 commit comments