Spaces:
Running
Running
File size: 1,521 Bytes
ff27dd7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #!/usr/bin/env python3
"""Fetch model Hub publication dates for the static release timeline."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
from urllib.parse import quote
from urllib.request import Request, urlopen
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument(
"--leaderboards",
type=Path,
default=Path("data/leaderboards.json"),
)
parser.add_argument(
"--output",
type=Path,
default=Path("data/model_releases.json"),
)
args = parser.parse_args()
bundle = json.loads(args.leaderboards.read_text())
model_ids = sorted(
{
row["hub_model"]
for rows in bundle["leaderboards"].values()
for row in rows
}
)
releases = {}
for model_id in model_ids:
api_url = f"https://huggingface.co/api/models/{quote(model_id, safe='/')}"
request = Request(api_url, headers={"User-Agent": "MIMIC-CDM-leaderboard"})
with urlopen(request, timeout=30) as response:
model = json.load(response)
releases[model_id] = {
"released_at": model["createdAt"][:10],
"source": f"https://huggingface.co/{model_id}",
}
print(f"{model_id}: {releases[model_id]['released_at']}")
args.output.write_text(json.dumps(releases, indent=2) + "\n")
print(f"Wrote {len(releases)} release dates to {args.output}")
if __name__ == "__main__":
main()
|