fix: stale __version__, scheduler import order, quality test coverage
- __init__.py: derive __version__ from importlib.metadata instead of a hardcoded "0.1.0" that was six releases out of date - scheduler.py: move winnow.cli import to module top (no more noqa); clean up redundant bool variables in check_models - tests/test_quality.py: 17 tests covering all five quality check functions individually plus assess_quality integration cases Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+6
-8
@@ -11,6 +11,10 @@ except ImportError:
|
||||
print("croniter not installed. Run: uv add croniter")
|
||||
sys.exit(1)
|
||||
|
||||
# Imported at module level so models loaded during the first run stay
|
||||
# resident in memory across all subsequent scheduled runs.
|
||||
from winnow.cli import main
|
||||
|
||||
SCHEDULE = os.environ["CRON_SCHEDULE"]
|
||||
MODELS_DIR = os.environ.get("HF_HOME", "/models/huggingface")
|
||||
INSIGHTFACE_BASE = os.environ.get("INSIGHTFACE_HOME", "/models")
|
||||
@@ -21,18 +25,12 @@ logger = logging.getLogger(__name__)
|
||||
def check_models() -> None:
|
||||
buffalo = Path(INSIGHTFACE_BASE) / ".insightface" / "models" / "buffalo_l"
|
||||
hf_hub = Path(MODELS_DIR) / "hub"
|
||||
buffalo_ok = buffalo.exists()
|
||||
hf_ok = hf_hub.exists() and any(hf_hub.iterdir())
|
||||
if not buffalo_ok:
|
||||
if not buffalo.exists():
|
||||
print(" InsightFace Buffalo_L not found — will download on first run", flush=True)
|
||||
if not hf_ok:
|
||||
if not (hf_hub.exists() and any(hf_hub.iterdir())):
|
||||
print(" HuggingFace models not found — will download on first run", flush=True)
|
||||
|
||||
|
||||
# Import once — models loaded during the first run stay resident in memory
|
||||
# for all subsequent scheduled runs, avoiding repeated multi-GB load times.
|
||||
from winnow.cli import main # noqa: E402
|
||||
|
||||
NOW = time.time()
|
||||
cron = croniter(SCHEDULE, NOW)
|
||||
next_run = cron.get_next(float)
|
||||
|
||||
Reference in New Issue
Block a user