@@ -60,7 +60,7 @@ def create(
60
60
)
61
61
62
62
weights = model_description .weights
63
- errors : List [Tuple [str , str ]] = []
63
+ errors : List [Tuple [WeightsFormat , Exception ]] = []
64
64
weight_format_priority_order = (
65
65
DEFAULT_WEIGHT_FORMAT_PRIORITY_ORDER
66
66
if weight_format_priority_order is None
@@ -82,7 +82,7 @@ def create(
82
82
devices = devices ,
83
83
)
84
84
except Exception as e :
85
- errors .append ((wf , str ( e ) ))
85
+ errors .append ((wf , e ))
86
86
elif (
87
87
wf == "tensorflow_saved_model_bundle"
88
88
and weights .tensorflow_saved_model_bundle is not None
@@ -94,7 +94,7 @@ def create(
94
94
model_description = model_description , devices = devices
95
95
)
96
96
except Exception as e :
97
- errors .append ((wf , str ( e ) ))
97
+ errors .append ((wf , e ))
98
98
elif wf == "onnx" and weights .onnx is not None :
99
99
try :
100
100
from ._onnx_model_adapter import ONNXModelAdapter
@@ -103,7 +103,7 @@ def create(
103
103
model_description = model_description , devices = devices
104
104
)
105
105
except Exception as e :
106
- errors .append ((wf , str ( e ) ))
106
+ errors .append ((wf , e ))
107
107
elif wf == "torchscript" and weights .torchscript is not None :
108
108
try :
109
109
from ._torchscript_model_adapter import TorchscriptModelAdapter
@@ -112,7 +112,7 @@ def create(
112
112
model_description = model_description , devices = devices
113
113
)
114
114
except Exception as e :
115
- errors .append ((wf , str ( e ) ))
115
+ errors .append ((wf , e ))
116
116
elif wf == "keras_hdf5" and weights .keras_hdf5 is not None :
117
117
# keras can either be installed as a separate package or used as part of tensorflow
118
118
# we try to first import the keras model adapter using the separate package and,
@@ -130,22 +130,22 @@ def create(
130
130
model_description = model_description , devices = devices
131
131
)
132
132
except Exception as e :
133
- errors .append ((wf , str ( e ) ))
133
+ errors .append ((wf , e ))
134
134
135
135
assert errors
136
136
if len (weight_format_priority_order ) == 1 :
137
137
assert len (errors ) == 1
138
138
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 "
142
141
)
143
142
144
143
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
+ )
146
147
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"
149
149
+ f" in this environment. Errors are:\n \n { error_list } .\n \n "
150
150
)
151
151
0 commit comments