Fix model downloader

This commit is contained in:
Benjamin Berman 2024-07-09 22:52:25 -07:00
parent 34c9482cfb
commit 0b45fa8db1
2 changed files with 5 additions and 4 deletions

View File

@ -458,7 +458,7 @@ def _get_cache_hits(cache_dirs: Sequence[str], local_dirs: Sequence[str], repo_i
# remove .huggingface
local_files = set(f for f in local_files if not f.startswith(f"{repo_id}/.huggingface"))
# local_files.issubsetof(repo_files)
if local_files.issubset(repo_files):
if len(local_files) > 0 and local_files.issubset(repo_files):
local_dirs_snapshots.append(str(local_path))
else:
# an empty repository or unknown repository info, trust that if the directory exists, it matches

View File

@ -58,11 +58,12 @@ def test_known_repos(tmp_path_factory):
_delete_repo_from_huggingface_cache(test_repo_id)
_delete_repo_from_huggingface_cache(test_repo_id, test_cache_dir)
try:
folder_paths.folder_names_and_paths["huggingface"] = FolderPathsTuple("huggingface", [test_local_dir], {""})
folder_paths.folder_names_and_paths["huggingface_cache"] = FolderPathsTuple("huggingface_cache", [test_cache_dir], {""})
folder_paths.folder_names_and_paths["huggingface"] += FolderPathsTuple("huggingface", [test_local_dir], {""})
folder_paths.folder_names_and_paths["huggingface_cache"] += FolderPathsTuple("huggingface_cache", [test_cache_dir], {""})
cache_hits, locals_hits = _get_cache_hits([test_cache_dir], [test_local_dir], test_repo_id)
assert len(cache_hits) == len(locals_hits) == 0, "not downloaded yet"
assert len(cache_hits) == 0, "not downloaded yet"
assert len(locals_hits) == 0, "not downloaded yet"
# test downloading the repo and observing a cache hit on second access
existing_repos = get_huggingface_repo_list()