Skip to content

Commit 7ea6cb2

Browse files
authored
[Misc] Improve modelscope import error (#17983)
Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
1 parent 9fbf2bf commit 7ea6cb2

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

vllm/transformers_utils/__init__.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
from vllm.envs import VLLM_USE_MODELSCOPE
44

55
if VLLM_USE_MODELSCOPE:
6-
# Patch here, before each import happens
7-
import modelscope
8-
from packaging import version
6+
try:
7+
# Patch here, before each import happens
8+
import modelscope
9+
from packaging import version
910

10-
# patch_hub begins from modelscope>=1.18.1
11-
if version.parse(modelscope.__version__) <= version.parse('1.18.0'):
12-
raise ImportError(
13-
'Using vLLM with ModelScope needs modelscope>=1.18.1, please '
14-
'install by `pip install modelscope -U`')
15-
16-
from modelscope.utils.hf_util import patch_hub
11+
# patch_hub begins from modelscope>=1.18.1
12+
if version.parse(modelscope.__version__) <= version.parse('1.18.0'):
13+
raise ImportError(
14+
'Using vLLM with ModelScope needs modelscope>=1.18.1, please '
15+
'install by `pip install modelscope -U`')
16+
from modelscope.utils.hf_util import patch_hub
1717

18-
# Patch hub to download models from modelscope to speed up.
19-
patch_hub()
18+
# Patch hub to download models from modelscope to speed up.
19+
patch_hub()
20+
except ImportError as err:
21+
raise ImportError(
22+
"Please install modelscope>=1.18.1 via "
23+
"`pip install modelscope>=1.18.1` to use ModelScope.") from err

0 commit comments

Comments
 (0)