#!/usr/bin/env python3 """Clear specific cache entries so they get regenerated with the new adaptive radius.""" import json, os, sys sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src")) from dotenv import load_dotenv load_dotenv(dotenv_path=os.path.join(os.path.dirname(__file__), "..", ".env"), override=True) CACHE_FILE = os.path.join(os.path.dirname(__file__), "..", ".cache", "llm_cache.json") WARMUP_PROGRESS = os.path.join(os.path.dirname(__file__), "..", ".warmup_progress.json") CATS = ["Landmark", "Culture", "Nature", "Gems", "Photo", "Food", "Shopping"] def cat_hash(name): d = {c: (c == name) for c in CATS} return json.dumps(d, sort_keys=True) # Cities to fully clear (all categories) FULL_CLEAR = ["Bali", "Dubai"] # Specific combos to clear COMBO_CLEAR = [ ("Marrakech", "Landmark"), ("Kyoto", "Shopping"), ] with open(CACHE_FILE) as f: cache = json.load(f) removed = 0 # Full clear for city in FULL_CLEAR: for cat in CATS: key = json.dumps([city, cat_hash(cat)]) if key in cache: del cache[key] removed += 1 # Specific combos for city, cat in COMBO_CLEAR: key = json.dumps([city, cat_hash(cat)]) if key in cache: del cache[key] removed += 1 with open(CACHE_FILE, "w") as f: json.dump(cache, f) # Also clear warmup progress for these so the warmup retries them with open(WARMUP_PROGRESS) as f: progress = json.load(f) for cid in list(progress["combos"].keys()): city, cat = cid.split("::") if city in FULL_CLEAR: del progress["combos"][cid] elif (city, cat) in COMBO_CLEAR: del progress["combos"][cid] with open(WARMUP_PROGRESS, "w") as f: json.dump(progress, f, indent=2) print(f"Cleared {removed} cache entries + progress for re-warmup")