Fix offline mode test for Transformers v5 (#38095)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import importlib
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import regex as re
|
||||||
import urllib3
|
import urllib3
|
||||||
|
|
||||||
from vllm import LLM
|
from vllm import LLM
|
||||||
@@ -110,11 +111,15 @@ def _re_import_modules():
|
|||||||
]
|
]
|
||||||
|
|
||||||
# These modules are aliased in Transformers v5 and so cannot be reloaded directly
|
# These modules are aliased in Transformers v5 and so cannot be reloaded directly
|
||||||
aliased_modules = ["tokenization_utils", "tokenization_utils_fast"]
|
aliased_module_patterns = [
|
||||||
|
r".+\.tokenization_utils$",
|
||||||
|
r".+\.tokenization_utils_fast$",
|
||||||
|
r".+\.models\..+\.image_processing_.+_fast$",
|
||||||
|
]
|
||||||
|
|
||||||
reload_exception = None
|
reload_exception = None
|
||||||
for module_name in hf_hub_module_names + transformers_module_names:
|
for module_name in hf_hub_module_names + transformers_module_names:
|
||||||
if any(module_name.endswith(f".{alias}") for alias in aliased_modules):
|
if any(re.match(pattern, module_name) for pattern in aliased_module_patterns):
|
||||||
# Remove from sys.modules so they are re-aliased on next import
|
# Remove from sys.modules so they are re-aliased on next import
|
||||||
del sys.modules[module_name]
|
del sys.modules[module_name]
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user