Skip to content

Commit

Permalink
chore: improve model not found error msg (#812)
Browse files Browse the repository at this point in the history
* chore: update model not found error msg in torch runtime

* chore: reformat error msg

* fix: typo
  • Loading branch information
ZiniuYu authored Aug 31, 2022
1 parent 4461d2e commit f7ee26a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
13 changes: 12 additions & 1 deletion server/clip_server/model/clip_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ def __new__(cls, name: str, **kwargs):

instance = super().__new__(MultilingualCLIPModel)
else:
raise ValueError(f'The CLIP model name=`{name}` is not supported.')
raise ValueError(
'CLIP model {} not found; below is a list of all available models:\n{}'.format(
name,
''.join(
[
'\t- {}\n'.format(i)
for i in list(_OPENCLIP_MODELS.keys())
+ list(_MULTILINGUALCLIP_MODELS.keys())
]
),
)
)
else:
instance = super().__new__(cls)
return instance
5 changes: 4 additions & 1 deletion server/clip_server/model/clip_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ def __init__(self, name: str, model_path: str = None):
)
else:
raise RuntimeError(
f'Model {name} not found; available models = {list(_MODELS.keys())}'
'CLIP model {} not found or not supports ONNX backend; below is a list of all available models:\n{}'.format(
name,
''.join(['\t- {}\n'.format(i) for i in list(_MODELS.keys())]),
)
)

@staticmethod
Expand Down
5 changes: 4 additions & 1 deletion server/clip_server/model/clip_trt.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def __init__(
save_engine(text_engine, self._textual_path)
else:
raise RuntimeError(
f'Model {name} not found or not supports Nvidia TensorRT backend; available models = {list(_MODELS.keys())}'
'CLIP model {} not found or not supports Nvidia TensorRT backend; below is a list of all available models:\n{}'.format(
name,
''.join(['\t- {}\n'.format(i) for i in list(_MODELS.keys())]),
)
)

@staticmethod
Expand Down

0 comments on commit f7ee26a

Please sign in to comment.