Spaces:
Running
Running
Download scripts/fetch_release_dates.py from MIMIC-CDM/leaderboard: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/MIMIC-CDM/leaderboard/resolve/main/scripts/fetch_release_dates.py
- Command line
-
hf download hf://spaces/MIMIC-CDM/leaderboard/scripts/fetch_release_dates.py
-
curl -L -o fetch_release_dates.py https://huggingface.co/spaces/MIMIC-CDM/leaderboard/resolve/main/scripts/fetch_release_dates.py
1.52 kB
| #!/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() | |