Spaces:
Running
Check SKU mapping before loading CLIP, not after embedding 6k photos
Why: the image->SKU map comes from photo_name() (the last URL segment of a catalogue image reference) matched against the mirrored filenames in dist/prodimgs/. If the two naming schemes disagree, owner.get() falls back to the filename and every row silently ships a filename in the sku field.
The failure is invisible and reaches the UI: worker.js groups results with best.set(sku, ...) in a Map keyed by sku, so each photo becomes its own "product" whose sku is a filename; ProductResults.jsx then looks that up in the gallery and finds nothing. 24 results with no name, no price. Meanwhile the matrix uploads successfully and nothing anywhere raises an error.
What: count the matches right after listing the mirror -- cheap, and before the model loads. A mismatch then costs ~10 seconds instead of a full 30-minute embedding pass over 6,372 photos.
- fatal on zero matches, where the mapping is certainly useless
- warn below 50% and record
sku_match_ratioinproduct-emb.json, so the number is auditable rather than invisible
This adds no new dependency and changes no existing behaviour when filenames line up.
Not verified: I could not confirm the mirror's actual filename format. The script that generated dist/prodimgs/ is not in the repo, and list_refs shows only main plus the pre-rebuild-static-fix tag. The builder already prints gallery: N products, M referenced photos -- that line is the ground truth to compare against.