File size: 1,681 Bytes
47a719e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Publish the audit as a single commit (upload_folder), so repeated republishes do not
burn the Hub's per-hour commit budget the way a file-at-a-time loop does."""
import os, sys, shutil, glob, time
sys.path.insert(0, "/root/mergeability/src")
from huggingface_hub import HfApi, create_repo
REPO = "Mergeability-2/compose-audit"
ROOT = "/root/compose-audit"
STAGE = "/root/compose-audit/.stage"

api = HfApi()
create_repo(REPO, repo_type="dataset", exist_ok=True)
if os.path.isdir(STAGE):
    shutil.rmtree(STAGE)
os.makedirs(f"{STAGE}/results", exist_ok=True)
os.makedirs(f"{STAGE}/figs", exist_ok=True)
os.makedirs(f"{STAGE}/code", exist_ok=True)
for fp in glob.glob(f"{ROOT}/results/*"):
    if os.path.isfile(fp):
        shutil.copy(fp, f"{STAGE}/results/{os.path.basename(fp)}")
for fp in glob.glob(f"{ROOT}/figs/*.png"):
    shutil.copy(fp, f"{STAGE}/figs/{os.path.basename(fp)}")
for fp in glob.glob(f"{ROOT}/*.py") + glob.glob(f"{ROOT}/*.sh"):
    shutil.copy(fp, f"{STAGE}/code/{os.path.basename(fp)}")
shutil.copy(f"{ROOT}/RESULTS_COMPOSE_AUDIT.md", f"{STAGE}/RESULTS_COMPOSE_AUDIT.md")
hdr = ("---\nlicense: apache-2.0\ntags:\n- model-merging\n- alignment\n- polypythia\n- goldfish\n"
       "- multilingual\n- blimp\n---\n\n")
with open(f"{ROOT}/RESULTS_COMPOSE_AUDIT.md", encoding="utf-8") as f:
    body = f.read()
with open(f"{STAGE}/README.md", "w", encoding="utf-8") as f:
    f.write(hdr + body)

api.upload_folder(folder_path=STAGE, repo_id=REPO, repo_type="dataset",
                  commit_message=f"compose-audit refresh {time.strftime('%Y-%m-%d %H:%M UTC')}")
shutil.rmtree(STAGE, ignore_errors=True)
print("URL: https://huggingface.co/datasets/" + REPO)