@@ -60,7 +60,7 @@ def create(
6060 )
6161
6262 weights = model_description .weights
63- errors : List [Tuple [str , str ]] = []
63+ errors : List [Tuple [WeightsFormat , Exception ]] = []
6464 weight_format_priority_order = (
6565 DEFAULT_WEIGHT_FORMAT_PRIORITY_ORDER
6666 if weight_format_priority_order is None
@@ -82,7 +82,7 @@ def create(
8282 devices = devices ,
8383 )
8484 except Exception as e :
85- errors .append ((wf , str ( e ) ))
85+ errors .append ((wf , e ))
8686 elif (
8787 wf == "tensorflow_saved_model_bundle"
8888 and weights .tensorflow_saved_model_bundle is not None
@@ -94,7 +94,7 @@ def create(
9494 model_description = model_description , devices = devices
9595 )
9696 except Exception as e :
97- errors .append ((wf , str ( e ) ))
97+ errors .append ((wf , e ))
9898 elif wf == "onnx" and weights .onnx is not None :
9999 try :
100100 from ._onnx_model_adapter import ONNXModelAdapter
@@ -103,7 +103,7 @@ def create(
103103 model_description = model_description , devices = devices
104104 )
105105 except Exception as e :
106- errors .append ((wf , str ( e ) ))
106+ errors .append ((wf , e ))
107107 elif wf == "torchscript" and weights .torchscript is not None :
108108 try :
109109 from ._torchscript_model_adapter import TorchscriptModelAdapter
@@ -112,7 +112,7 @@ def create(
112112 model_description = model_description , devices = devices
113113 )
114114 except Exception as e :
115- errors .append ((wf , str ( e ) ))
115+ errors .append ((wf , e ))
116116 elif wf == "keras_hdf5" and weights .keras_hdf5 is not None :
117117 # keras can either be installed as a separate package or used as part of tensorflow
118118 # we try to first import the keras model adapter using the separate package and,
@@ -130,22 +130,22 @@ def create(
130130 model_description = model_description , devices = devices
131131 )
132132 except Exception as e :
133- errors .append ((wf , str ( e ) ))
133+ errors .append ((wf , e ))
134134
135135 assert errors
136136 if len (weight_format_priority_order ) == 1 :
137137 assert len (errors ) == 1
138138 raise ValueError (
139- f"The '{ weight_format_priority_order [0 ]} ' model adapter could not be created for"
140- + f" '{ model_description .id or model_description .name } '"
141- + f" in this environment:\n { errors [0 ][1 ]} .\n \n "
139+ f"The '{ weight_format_priority_order [0 ]} ' model adapter could not be created"
140+ + f" in this environment:\n { errors [0 ][1 ].__class__ .__name__ } ({ errors [0 ][1 ]} ).\n \n "
142141 )
143142
144143 else :
145- error_list = "\n - " .join (f"{ wf } : { e } " for wf , e in errors )
144+ error_list = "\n - " .join (
145+ f"{ wf } : { e .__class__ .__name__ } ({ e } )" for wf , e in errors
146+ )
146147 raise ValueError (
147- "None of the weight format specific model adapters could be created for"
148- + f" '{ model_description .id or model_description .name } '"
148+ "None of the weight format specific model adapters could be created"
149149 + f" in this environment. Errors are:\n \n { error_list } .\n \n "
150150 )
151151
0 commit comments