Migrate release runtime and gates to Python 3.14

This commit is contained in:
anor
2026-11-28 00:41:25 +10:00
parent a0de4659f1
commit 3af59574f3
41 changed files with 305 additions and 106 deletions
+5 -5
View File
@@ -1,7 +1,7 @@
"""Search functions for smeta-web.
Provides text search in ФСНБ-2022 resources, ФССЦ materials (86 regions),
full ГЭСН norms (181K), and winter cost zones. Uses pymorphy2 for normalization.
full ГЭСН norms (181K), and winter cost zones. Uses pymorphy3 for normalization.
"""
import json
@@ -10,11 +10,11 @@ import re
import threading
from pathlib import Path
import pymorphy2
import pymorphy3
SMETA_DIR = Path(os.environ.get("SMETA_PROJECT_DIR", os.path.expanduser("~/smeta-railway")))
_morph = pymorphy2.MorphAnalyzer()
_morph = pymorphy3.MorphAnalyzer()
# После выноса поиска в to_thread (claude_bridge_glm) _search_* идут в тредпуле
# параллельно; MorphAnalyzer.parse не гарантированно потокобезопасен (общий DAWG/кэш)
# → сериализуем разбор локом (parse дешёвый, глобальную конкуренцию не создаёт). Fable.
@@ -22,7 +22,7 @@ _morph_lock = threading.Lock()
def _normalize(word: str) -> str:
"""Normalize Russian word to its base form via pymorphy2."""
"""Normalize Russian word to its base form via pymorphy3."""
word = re.sub(r'[^\w]', '', word)
if len(word) <= 2 or word.isdigit():
return word.lower()
@@ -235,7 +235,7 @@ def _search_winter(query: str) -> str:
# === Resources (resources.json, 24K norms) ===
def _search_resources(query: str, resources: dict, top_k: int = 5) -> str:
"""Search in resources.json using pymorphy2 normalization."""
"""Search in resources.json using pymorphy3 normalization."""
if not resources:
return ""