File size: 863 Bytes
9c6799a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Upload a finished run (metrics + final model) to a private HF model repo under runs/<run>/."""

import argparse
from pathlib import Path

from huggingface_hub import HfApi


def main():
    p = argparse.ArgumentParser()
    p.add_argument("--repo", default="Broyojo/world-pretraining-runs")
    p.add_argument("--run", required=True)
    p.add_argument("dirs", nargs="+", help="local dirs whose contents go to runs/<run>/")
    args = p.parse_args()
    api = HfApi()
    api.create_repo(args.repo, private=True, exist_ok=True)
    for d in args.dirs:
        if Path(d).is_dir():
            api.upload_folder(repo_id=args.repo, folder_path=d, path_in_repo=f"runs/{args.run}",
                              commit_message=f"{args.run}: {Path(d).name}")
            print(f"uploaded {d} -> {args.repo}/runs/{args.run}")


if __name__ == "__main__":
    main()