| |
| """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) |
|
|
| |
| FULL_CLEAR = ["Bali", "Dubai"] |
| |
| COMBO_CLEAR = [ |
| ("Marrakech", "Landmark"), |
| ("Kyoto", "Shopping"), |
| ] |
|
|
| with open(CACHE_FILE) as f: |
| cache = json.load(f) |
|
|
| removed = 0 |
| |
| 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 |
|
|
| |
| 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) |
|
|
| |
| 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") |
|
|