ROMB-1.0 / scripts /check_hub_metadata.py
d0rj's picture
Fix Hub eval metadata validation for custom Inspect scorer
01a96a9
Raw History Blame Contribute Delete
1.91 kB
"""Check the rendered HF eval.yaml page at an immutable revision, without a GPU.
Usage: uv run --no-project scripts/check_hub_metadata.py --revision main
This checks metadata validation, not benchmark allow-list activation.
"""
import argparse
import json
from html.parser import HTMLParser
from urllib.parse import quote
from urllib.request import urlopen
class VisibleText(HTMLParser):
def __init__(self):
super().__init__()
self.parts = []
self.hidden = 0
def handle_starttag(self, tag, attrs):
if tag in {"script", "style"}:
self.hidden += 1
def handle_endtag(self, tag):
if tag in {"script", "style"}:
self.hidden = max(0, self.hidden - 1)
def handle_data(self, data):
if not self.hidden:
self.parts.append(data)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--revision", default="main")
args = parser.parse_args()
repo = "d0rj/ROMB-1.0"
with urlopen(
f"https://huggingface.co/api/datasets/{repo}/revision/{quote(args.revision, safe='')}",
timeout=30,
) as response:
revision = json.load(response)["sha"]
url = f"https://huggingface.co/datasets/{repo}/blob/{revision}/eval.yaml"
with urlopen(url, timeout=30) as response:
page = response.read().decode("utf-8")
text = VisibleText()
text.feed(page)
visible = " ".join(" ".join(text.parts).split())
if "eval.yaml" not in visible:
raise SystemExit("Unexpected page: eval.yaml viewer was not found")
if "YAML Metadata" in visible or "Invalid content in eval.yaml" in visible:
raise SystemExit(f"HF metadata validation FAILED: {url}")
print(f"HF metadata validation passed: {url}")
print("This does not confirm benchmark activation or hosted custom-code support.")
if __name__ == "__main__":
main()