@@ -30,15 +30,34 @@ def test_model(
3030) -> dict :
3131 """Test whether the test output(s) of a model can be reproduced.
3232
33- Returns summary dict with "error" and "traceback" key; summary[" error"] is None if no errors were encountered.
33+ Returns: summary dict with keys: name, status, error, traceback, bioimageio_spec_version, bioimageio_core_version
3434 """
35- model = load_resource_description (
36- model_rdf , weights_priority_order = None if weight_format is None else [weight_format ]
37- )
35+ # todo: reuse more of 'test_resource'
36+ tb = None
37+ try :
38+ model = load_resource_description (
39+ model_rdf , weights_priority_order = None if weight_format is None else [weight_format ]
40+ )
41+ except Exception as e :
42+ model = None
43+ error = str (e )
44+ tb = traceback .format_tb (e .__traceback__ )
45+ else :
46+ error = None
47+
3848 if isinstance (model , Model ):
3949 return test_resource (model , weight_format = weight_format , devices = devices , decimal = decimal )
4050 else :
41- return {"error" : f"Expected RDF type Model, got { type (model )} instead." , "traceback" : None }
51+ error = error or f"Expected RDF type Model, got { type (model )} instead."
52+
53+ return dict (
54+ name = "reproduced test outputs from test inputs" ,
55+ status = "failed" ,
56+ error = error ,
57+ traceback = tb ,
58+ bioimageio_spec_version = bioimageio_spec_version ,
59+ bioimageio_core_version = bioimageio_core_version ,
60+ )
4261
4362
4463def _validate_input_shape (shape : Tuple [int , ...], shape_spec ) -> bool :
@@ -80,7 +99,7 @@ def _validate_output_shape(shape: Tuple[int, ...], shape_spec, input_shapes) ->
8099
81100
82101def test_resource (
83- model_rdf : Union [RawResourceDescription , ResourceDescription , URI , Path , str ],
102+ rdf : Union [RawResourceDescription , ResourceDescription , URI , Path , str ],
84103 * ,
85104 weight_format : Optional [WeightsFormat ] = None ,
86105 devices : Optional [List [str ]] = None ,
@@ -95,9 +114,7 @@ def test_resource(
95114 test_name : str = "load resource description"
96115
97116 try :
98- rd = load_resource_description (
99- model_rdf , weights_priority_order = None if weight_format is None else [weight_format ]
100- )
117+ rd = load_resource_description (rdf , weights_priority_order = None if weight_format is None else [weight_format ])
101118 except Exception as e :
102119 error = str (e )
103120 tb = traceback .format_tb (e .__traceback__ )
0 commit comments