@@ -103,9 +103,16 @@ def load_description_and_test(
103
103
_test_expected_resource_type (rd , expected_type )
104
104
105
105
if isinstance (rd , (v0_4 .ModelDescr , v0_5 .ModelDescr )):
106
- _test_model_inference (rd , weight_format , devices , decimal )
107
- if not isinstance (rd , v0_4 .ModelDescr ):
108
- _test_model_inference_parametrized (rd , weight_format , devices )
106
+ if weight_format is None :
107
+ weight_formats : List [WeightsFormat ] = [
108
+ w for w , we in rd .weights if we is not None
109
+ ] # pyright: ignore[reportAssignmentType]
110
+ else :
111
+ weight_formats = [weight_format ]
112
+ for w in weight_formats :
113
+ _test_model_inference (rd , w , devices , decimal )
114
+ if not isinstance (rd , v0_4 .ModelDescr ):
115
+ _test_model_inference_parametrized (rd , w , devices )
109
116
110
117
# TODO: add execution of jupyter notebooks
111
118
# TODO: add more tests
@@ -115,7 +122,7 @@ def load_description_and_test(
115
122
116
123
def _test_model_inference (
117
124
model : Union [v0_4 .ModelDescr , v0_5 .ModelDescr ],
118
- weight_format : Optional [ WeightsFormat ] ,
125
+ weight_format : WeightsFormat ,
119
126
devices : Optional [List [str ]],
120
127
decimal : int ,
121
128
) -> None :
@@ -161,11 +168,7 @@ def _test_model_inference(
161
168
if error is None
162
169
else [
163
170
ErrorEntry (
164
- loc = (
165
- ("weights" ,)
166
- if weight_format is None
167
- else ("weights" , weight_format )
168
- ),
171
+ loc = ("weights" , weight_format ),
169
172
msg = error ,
170
173
type = "bioimageio.core" ,
171
174
traceback = tb ,
@@ -178,7 +181,7 @@ def _test_model_inference(
178
181
179
182
def _test_model_inference_parametrized (
180
183
model : v0_5 .ModelDescr ,
181
- weight_format : Optional [ WeightsFormat ] ,
184
+ weight_format : WeightsFormat ,
182
185
devices : Optional [List [str ]],
183
186
) -> None :
184
187
if not any (
@@ -300,19 +303,15 @@ def get_ns(n: int):
300
303
301
304
model .validation_summary .add_detail (
302
305
ValidationDetail (
303
- name = "Run inference for inputs with batch_size: "
304
- + f" { batch_size } and size parameter n: { n } " ,
306
+ name = f "Run { weight_format } inference for inputs with"
307
+ + f" batch_size: { batch_size } and size parameter n: { n } " ,
305
308
status = "passed" if error is None else "failed" ,
306
309
errors = (
307
310
[]
308
311
if error is None
309
312
else [
310
313
ErrorEntry (
311
- loc = (
312
- ("weights" ,)
313
- if weight_format is None
314
- else ("weights" , weight_format )
315
- ),
314
+ loc = ("weights" , weight_format ),
316
315
msg = error ,
317
316
type = "bioimageio.core" ,
318
317
)
@@ -325,15 +324,11 @@ def get_ns(n: int):
325
324
tb = traceback .format_tb (e .__traceback__ )
326
325
model .validation_summary .add_detail (
327
326
ValidationDetail (
328
- name = "Run inference for parametrized inputs" ,
327
+ name = f "Run { weight_format } inference for parametrized inputs" ,
329
328
status = "failed" ,
330
329
errors = [
331
330
ErrorEntry (
332
- loc = (
333
- ("weights" ,)
334
- if weight_format is None
335
- else ("weights" , weight_format )
336
- ),
331
+ loc = ("weights" , weight_format ),
337
332
msg = error ,
338
333
type = "bioimageio.core" ,
339
334
traceback = tb ,
0 commit comments