Unverified Commit f6af3462 authored by Harry Mellor's avatar Harry Mellor Committed by GitHub
Browse files

Fix offline test for Transformers v5 (#33682)


Signed-off-by: default avatarHarry Mellor <19981378+hmellor@users.noreply.github.com>
parent ceab70c8
...@@ -109,8 +109,15 @@ def _re_import_modules(): ...@@ -109,8 +109,15 @@ def _re_import_modules():
if k.startswith("transformers") and not k.startswith("transformers_modules") if k.startswith("transformers") and not k.startswith("transformers_modules")
] ]
# These modules are aliased in Transformers v5 and so cannot be reloaded directly
aliased_modules = ["tokenization_utils", "tokenization_utils_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):
# Remove from sys.modules so they are re-aliased on next import
del sys.modules[module_name]
continue
try: try:
importlib.reload(sys.modules[module_name]) importlib.reload(sys.modules[module_name])
except Exception as e: except Exception as e:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment