From 38c4eb1cc55a37dc4e842fd6874a3ba4e20c6f14 Mon Sep 17 00:00:00 2001 From: Nathan LeRoy <41063083+nleroy917@users.noreply.github.com> Date: Wed, 21 Feb 2024 03:26:14 -0500 Subject: [PATCH] Check for existing files in cache dir before instantiating a model (#128) * check for existing files * (chore: model_management.py): Add comment --------- Co-authored-by: Nirant --- fastembed/common/model_management.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fastembed/common/model_management.py b/fastembed/common/model_management.py index 732d5e70..96403da9 100644 --- a/fastembed/common/model_management.py +++ b/fastembed/common/model_management.py @@ -131,7 +131,8 @@ def retrieve_model_gcs(cls, model_name: str, source_url: str, cache_dir: str) -> model_tmp_dir = cache_tmp_dir / fast_model_name model_dir = Path(cache_dir) / fast_model_name - if model_dir.exists(): + # check if the model_dir and the model files are both present for macOS + if model_dir.exists() and len(list(model_dir.glob("*"))) > 0: return model_dir if model_tmp_dir.exists():