File size: 1,117 Bytes
b610752
 
 
 
 
 
 
 
 
 
 
b0688c5
 
 
 
 
 
b610752
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6981847
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
from huggingface_hub import HfApi
import os

REPO_ID = "MintplexLabs/multilingual-e5-small"
LOCAL_PATH = "."  # your local directory

api = HfApi()

# Get list of files in repo
remote_files = {f for f in api.list_repo_files(repo_id=REPO_ID)}

# Delete .DS_Store files if present in remote
ds_store_files = {f for f in remote_files if f.endswith('.DS_Store')}
for file in ds_store_files:
    print(f"Deleting {file} from repo...")
    api.delete_file(path_in_repo=file, repo_id=REPO_ID)

# Get list of files locally (recursively)
local_files = set()
for root, _, files in os.walk(LOCAL_PATH):
    for file in files:
        full_path = os.path.join(root, file)
        relative_path = os.path.relpath(full_path, LOCAL_PATH)
        local_files.add(relative_path.replace("\\", "/"))

# Find files that exist remotely but not locally
files_to_delete = remote_files - local_files

# Delete them
for file in files_to_delete:
    print(f"Deleting {file} from repo...")
    api.delete_file(path_in_repo=file, repo_id=REPO_ID)

# Now re-upload local files using the CLI
print(f"huggingface-cli upload {REPO_ID} {LOCAL_PATH}")