add a JIT download_and_cache() call to the model installer

This commit is contained in:
Lincoln Stein
2024-02-12 14:27:17 -05:00
committed by Brandon Rising
parent 195768c9ee
commit 93fb2d1a55
6 changed files with 154 additions and 5 deletions

View File

@ -53,7 +53,13 @@ class ModelConvertCache(ModelConvertCacheBase):
sentinel = path / config
if sentinel.exists():
return sentinel.stat().st_atime
return 0.0
# no sentinel file found! - pick the most recent file in the directory
try:
atimes = sorted([x.stat().st_atime for x in path.iterdir() if x.is_file()], reverse=True)
return atimes[0]
except IndexError:
return 0.0
# sort by last access time - least accessed files will be at the end
lru_models = sorted(self._cache_path.iterdir(), key=by_atime, reverse=True)