Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Gregor Betz
commited on
Commit
•
b7dd05f
1
Parent(s):
a0a4a40
add script
Browse files- scripts/update_readme.py +67 -0
scripts/update_readme.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import glob
|
4 |
+
import yaml
|
5 |
+
|
6 |
+
import click
|
7 |
+
from colorama import Fore
|
8 |
+
from huggingface_hub import HfApi, snapshot_download
|
9 |
+
|
10 |
+
EVAL_REQUESTS_PATH = "eval-queue"
|
11 |
+
QUEUE_REPO = "cot-leaderboard/cot-leaderboard-requests"
|
12 |
+
READMES = ["README.md", "../open_cot_dashboard/README.md"]
|
13 |
+
|
14 |
+
precisions = ("float16", "bfloat16", "8bit (LLM.int8)", "4bit (QLoRA / FP4)", "GPTQ")
|
15 |
+
model_types = ("pretrained", "fine-tuned", "RL-tuned", "instruction-tuned")
|
16 |
+
weight_types = ("Original", "Delta", "Adapter")
|
17 |
+
|
18 |
+
|
19 |
+
def update_readme(readme_path: str, models: list[str]):
|
20 |
+
# read lines from the readme
|
21 |
+
with open(readme_path, "r") as f:
|
22 |
+
lines = f.readlines()
|
23 |
+
lines = [line.rstrip() for line in lines]
|
24 |
+
if not lines:
|
25 |
+
raise ValueError(f"Readme file {readme_path} is empty")
|
26 |
+
if not lines[0].startswith("---"):
|
27 |
+
raise ValueError(f"Readme file {readme_path} does not start with a metadata block")
|
28 |
+
lines = lines[1:]
|
29 |
+
if "---" not in lines:
|
30 |
+
raise ValueError(f"Readme file {readme_path} does not close the metadata block")
|
31 |
+
lines = lines[:lines.index("---")]
|
32 |
+
models_idx = lines.index("models:")
|
33 |
+
if any(not line.startswith(" - ") for line in lines[models_idx + 1:]):
|
34 |
+
raise ValueError(f"Readme file {readme_path} does not have a valid list of models")
|
35 |
+
lines = lines[:models_idx + 1]
|
36 |
+
for model in models:
|
37 |
+
lines.append(f" - {model}")
|
38 |
+
lines = ["---"] + lines + ["---"]
|
39 |
+
# write lines back to the readme
|
40 |
+
with open(readme_path, "w") as f:
|
41 |
+
f.write("\n".join(lines)+"\n")
|
42 |
+
|
43 |
+
|
44 |
+
def main():
|
45 |
+
api = HfApi()
|
46 |
+
snapshot_download(repo_id=QUEUE_REPO, revision="main", local_dir=EVAL_REQUESTS_PATH, repo_type="dataset")
|
47 |
+
|
48 |
+
eval_requests = []
|
49 |
+
|
50 |
+
for file in glob.glob(f"{EVAL_REQUESTS_PATH}/**/*.json", recursive=True):
|
51 |
+
with open(file, "r") as f:
|
52 |
+
eval_requests.append(json.load(f))
|
53 |
+
|
54 |
+
models_evaluated = [
|
55 |
+
eval_request['model'] for eval_request in eval_requests
|
56 |
+
if eval_request["status"] == "FINISHED"
|
57 |
+
]
|
58 |
+
models_evaluated.sort()
|
59 |
+
|
60 |
+
print(models_evaluated)
|
61 |
+
|
62 |
+
for readme in READMES:
|
63 |
+
update_readme(readme, models_evaluated)
|
64 |
+
|
65 |
+
|
66 |
+
if __name__ == "__main__":
|
67 |
+
main()
|