From a1e4d0d3919c3c05f9a9ce0c746260855111752b Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 1 Sep 2025 15:19:05 +0300 Subject: [PATCH] search-restore-2 --- pyproject.toml | 2 +- scripts/preload_models.py | 8 ++++++-- services/search.py | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5fd9fd36..b1aa363b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "discours-core" -version = "0.9.14" +version = "0.9.18" description = "Core backend for Discours.io platform" authors = [ {name = "Tony Rewin", email = "tonyrewin@yandex.ru"} diff --git a/scripts/preload_models.py b/scripts/preload_models.py index 5f328923..627e9b7b 100755 --- a/scripts/preload_models.py +++ b/scripts/preload_models.py @@ -15,17 +15,21 @@ def get_models_cache_dir() -> str: """Определяет лучшую папку для кеша моделей""" # Пробуем /dump если доступен для записи dump_path = Path("/dump") + print(f"🔍 Checking /dump - exists: {dump_path.exists()}, writable: {os.access('/dump', os.W_OK) if dump_path.exists() else 'N/A'}") + if dump_path.exists() and os.access("/dump", os.W_OK): cache_dir = "/dump/huggingface" try: Path(cache_dir).mkdir(parents=True, exist_ok=True) + print(f"✅ Using mounted storage: {cache_dir}") return cache_dir - except Exception: # noqa: S110 - pass + except Exception as e: + print(f"❌ Failed to create {cache_dir}: {e}") # Fallback - локальная папка ./dump cache_dir = "./dump/huggingface" Path(cache_dir).mkdir(parents=True, exist_ok=True) + print(f"📁 Using local fallback: {cache_dir}") return cache_dir diff --git a/services/search.py b/services/search.py index d9ba81d3..04e208d3 100644 --- a/services/search.py +++ b/services/search.py @@ -22,17 +22,21 @@ def get_models_cache_dir() -> str: """Определяет лучшую папку для кеша моделей""" # Пробуем /dump если доступен для записи dump_path = Path("/dump") + logger.info(f"🔍 Checking /dump - exists: {dump_path.exists()}, writable: {os.access('/dump', os.W_OK) if dump_path.exists() else 'N/A'}") + if dump_path.exists() and os.access("/dump", os.W_OK): cache_dir = "/dump/huggingface" try: Path(cache_dir).mkdir(parents=True, exist_ok=True) + logger.info(f"✅ Using mounted storage: {cache_dir}") return cache_dir - except Exception: # noqa: S110 - pass + except Exception as e: + logger.warning(f"Failed to create {cache_dir}: {e}") # Fallback - локальная папка ./dump cache_dir = "./dump/huggingface" Path(cache_dir).mkdir(parents=True, exist_ok=True) + logger.info(f"📁 Using local fallback: {cache_dir}") return cache_dir