Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jug-dev committed May 12, 2023
2 parents 2bf710b + 4b2a9ae commit 8a5a237
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hordelib/model_manager/compvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def modelToRam(
model_name: str,
**kwargs,
) -> dict[str, typing.Any]:

embeddings_path = os.getenv("HORDE_MODEL_DIR_EMBEDDINGS", "./")

if not kwargs.get("local", False):
Expand Down Expand Up @@ -67,6 +66,12 @@ def have_model_cache(self, model_name):
model_filename = self.getFullModelPath(model_name)
cache_file = self.get_model_cache_filename(model_name)
if os.path.exists(cache_file):
if not self.validate_model(model_name):
# The model is invalid, so delete the cache file because that's almost certainly no good either
# This should only happen if the model was updated on disk manually, or the model reference changed
logger.error(f"The model {model_name} is invalid, deleting the cache file.")
os.remove(path=cache_file)
return False
# We have a cache file but only consider it valid if it's up to date
model_timestamp = os.path.getmtime(model_filename)
cache_timestamp = os.path.getmtime(cache_file)
Expand Down

0 comments on commit 8a5a237

Please sign in to comment.