File size: 1,795 Bytes
5f9a50b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from huggingface_hub import HfApi

# ────────────────
#  CONFIGURATION
# ────────────────
HF_TOKEN  = os.getenv("HF_TOKEN")                       # ensure: export HF_TOKEN="hf_xxx…"
REPO_ID   = "agreeupon/wrkspace-backup-ttl"             # YOUR_HF_USERNAME/YOUR_REPO_NAME
VOL_PATH  = "/workspace"                                # your RunPod mount
REPO_TYPE = "dataset"                                   # or "model"

# ────────────────
#  1) Initialize API (with token) & create repo if needed
# ────────────────
api = HfApi(token=HF_TOKEN)
try:
    api.create_repo(
        repo_id  = REPO_ID,
        repo_type= REPO_TYPE,
        private  = False,    # public = free unlimited
        exist_ok = True      # skip error if it already exists
    )
    print(f"βœ… Repo ready: {REPO_ID}")
except TypeError:
    # If your version doesn't support exist_ok, just ignore conflicts:
    pass

# ────────────────
#  2) Remove stray .index.json pointers (to avoid LFS errors)
# ────────────────
for root, _, files in os.walk(VOL_PATH):
    for fname in files:
        if fname.endswith(".index.json"):
            os.remove(os.path.join(root, fname))
print("πŸ—‘οΈ  Removed any .index.json files")

# ────────────────
#  3) Parallel large-folder upload
# ────────────────
api.upload_large_folder(
    repo_id         = REPO_ID,
    repo_type       = REPO_TYPE,
    folder_path     = VOL_PATH,
    ignore_patterns = [
        ".git", "__pycache__", "*.pyc", "*.tmp", "*.DS_Store"
    ]
)

print("πŸš€ Large-folder upload complete!")