ui-test-vision-2b-alpha / code /scripts /fix_settings_gold.py
yuta24's picture
v0.1.0-alpha: PyTorch LoRA + heads, code, model card
e379257 verified
Raw History Blame Contribute Delete
2.08 kB
"""Gold fix (Yu, 2026-10-24): a destructive row inside the settings list (e.g. Delete Account)
is NOT the primary button. For settings_destructive records whose primary_button gold is that
destructive row, set primary_button -> "none" and box_primary_button -> {"present": false}.
A record keeps its gold if it has a real primary CTA (a primary box distinct from the destructive box
and a non-destructive gold value). has_destructive_action is left untouched.
usage: python scripts/fix_settings_gold.py in.jsonl out.jsonl
"""
import collections, json, sys
DESTRUCTIVE = {"delete", "discard"}
def main(src, dst):
n = changed = 0
before, kept = collections.Counter(), collections.Counter()
with open(src, encoding="utf-8") as f, open(dst, "w", encoding="utf-8", newline="\n") as out:
for line in f:
if not line.strip():
continue
r = json.loads(line)
n += 1
if "settings_destructive" in r["id"]:
g = r["gold"]
old = g.get("primary_button")
before[old] += 1
pb, db = g.get("box_primary_button"), g.get("box_destructive_button")
same_box = isinstance(pb, dict) and pb.get("present") and pb == db
if old != "none" and (old in DESTRUCTIVE or same_box):
g["primary_button"] = "none"
if isinstance(pb, dict):
g["box_primary_button"] = {"present": False}
r["meta"].setdefault("gold_fixes", []).append(
f"primary_button:{old}->none (settings destructive row is not primary, 2026-10-24)")
changed += 1
else:
kept[old] += 1
out.write(json.dumps(r, ensure_ascii=False) + "\n")
print(f"{n} records, settings_destructive primary_button before={dict(before)}, "
f"changed->none={changed}, kept={dict(kept)} -> {dst}")
if __name__ == "__main__":
main(sys.argv[1], sys.argv[2])