"tests/test_modeling_layoutlmv2.py" did not exist on "439e7abd2d4e0b2bfb592a1cf0eadbd2042d8a93"
Unverified Commit 38db04ec authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Find module name in an OS-agnostic fashion (#24526)

* Find module name in an OS-agnostic fashion

* address review comment
parent 7d150d68
......@@ -234,7 +234,7 @@ def get_cached_module_file(
pretrained_model_name_or_path = str(pretrained_model_name_or_path)
is_local = os.path.isdir(pretrained_model_name_or_path)
if is_local:
submodule = pretrained_model_name_or_path.split(os.path.sep)[-1]
submodule = os.path.basename(pretrained_model_name_or_path)
else:
submodule = pretrained_model_name_or_path.replace("/", os.path.sep)
cached_module = try_to_load_from_cache(
......@@ -271,7 +271,7 @@ def get_cached_module_file(
full_submodule = TRANSFORMERS_DYNAMIC_MODULE_NAME + os.path.sep + submodule
create_dynamic_module(full_submodule)
submodule_path = Path(HF_MODULES_CACHE) / full_submodule
if submodule == pretrained_model_name_or_path.split(os.path.sep)[-1]:
if submodule == os.path.basename(pretrained_model_name_or_path):
# We copy local files to avoid putting too many folders in sys.path. This copy is done when the file is new or
# has changed since last copy.
if not (submodule_path / module_file).exists() or not filecmp.cmp(
......
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