automated update: 2026-06-10 22:25:47

This commit is contained in:
root
2026-06-10 22:25:47 -04:00
parent 78ce09adaa
commit b9b734507b
13 changed files with 243 additions and 79 deletions
+43 -10
View File
@@ -3,23 +3,56 @@ import os
import sys
import subprocess
import time
from croniter import croniter
import logging
from pathlib import Path
try:
from croniter import croniter
except ImportError:
print("❌ croniter not installed. Run: uv add croniter")
sys.exit(1)
SCHEDULE = os.environ["CRON_SCHEDULE"]
MODELS_DIR = os.environ.get("HF_HOME", "/models/huggingface")
INSIGHTFACE_BASE = os.environ.get("INSIGHTFACE_HOME", "/models")
SCHEDULE = os.environ.get("CRON_SCHEDULE", "0 3 * * SUN")
RUN_ENV = {**os.environ, "PYTHONUNBUFFERED": "1"}
def run_curator():
print(f"\n▶ [{time.strftime('%Y-%m-%d %H:%M:%S')}] Starting if-curator...", flush=True)
subprocess.run(["uv", "run", "python", "-m", "if_curator.cli"], env=RUN_ENV)
logger = logging.getLogger(__name__)
now = time.time()
cron = croniter(SCHEDULE, now)
def check_models():
"""Log model status before each run."""
print("📦 Checking models...", flush=True)
buffalo = Path(INSIGHTFACE_BASE) / ".insightface" / "models" / "buffalo_l"
if buffalo.exists():
print(" ✅ InsightFace Buffalo_L: present", flush=True)
else:
print(" ⬇️ InsightFace Buffalo_L: not found — will download", flush=True)
hf_hub = Path(MODELS_DIR) / "hub"
if hf_hub.exists() and any(hf_hub.iterdir()):
print(" ✅ HuggingFace models: present", flush=True)
else:
print(" ⬇️ HuggingFace models: not found — will download", flush=True)
print("🚀 Starting if-curator...", flush=True)
NOW = time.time()
cron = croniter(SCHEDULE, NOW)
next_run = cron.get_next(float)
print(f"▶ Scheduler active. Next run: {time.ctime(next_run)}")
while True:
if time.time() >= next_run:
run_curator()
now = time.time()
if now >= next_run:
print(f"\n▶ [{time.strftime('%Y-%m-%d %H:%M:%S')}] Starting if-curator...", flush=True)
check_models()
result = subprocess.run(["uv", "run", "if-curator"], env=RUN_ENV)
if result.returncode != 0:
logger.error(f"if-curator exited with code {result.returncode}")
print(f"❌ if-curator failed with exit code {result.returncode}", flush=True)
else:
print("✅ if-curator completed successfully", flush=True)
next_run = cron.get_next(float)
time.sleep(60)