File size: 1,364 Bytes
929b3ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
57
58
59
60
"""Create + push the HF Space for PromptOps Arena."""

from __future__ import annotations

import os
import sys
from pathlib import Path

from huggingface_hub import HfApi, create_repo

ROOT = Path(__file__).resolve().parents[1]
SPACE_ID = os.environ.get("SPACE_ID", "Dar3devil/promptops-arena")


def main() -> int:
    token = os.environ.get("HF_TOKEN")
    api = HfApi(token=token)

    create_repo(
        repo_id=SPACE_ID,
        repo_type="space",
        space_sdk="gradio",
        exist_ok=True,
        token=token,
    )

    ignore = [
        "outputs/*",
        "outputs/**",
        ".venv/*",
        ".venv/**",
        ".git/*",
        ".git/**",
        "__pycache__/*",
        "**/__pycache__/**",
        "*.pyc",
        "node_modules/**",
        ".pytest_cache/**",
        ".mypy_cache/**",
        ".ruff_cache/**",
        ".cursor/**",
        "logs/**",
        "results/.cache/**",
    ]

    print(f"[push] uploading {ROOT} -> space {SPACE_ID}")
    api.upload_folder(
        folder_path=str(ROOT),
        repo_id=SPACE_ID,
        repo_type="space",
        ignore_patterns=ignore,
        commit_message="PromptOps Arena demo",
    )
    print(f"[push] done. https://huggingface.co/spaces/{SPACE_ID}")
    return 0


if __name__ == "__main__":
    sys.exit(main())