File size: 916 Bytes
2cd42be
b545869
 
2cd42be
 
 
 
b545869
2cd42be
 
b545869
2cd42be
 
b545869
 
 
 
 
 
 
 
2cd42be
b545869
 
 
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
from huggingface_hub import HfApi
import shutil, os
from dotenv import load_dotenv

load_dotenv()
HF_DATA_REPO_ID = os.getenv("HF_DATA_REPO_ID")
HF_DATA_TOKEN = os.getenv("HF_DATA_TOKEN")

api = HfApi()

# 1๏ธโƒฃ ๋ชจ๋“  ํŒŒ์ผ ์‚ญ์ œ
files = api.list_repo_files(repo_id=HF_DATA_REPO_ID, repo_type="dataset", token=HF_DATA_TOKEN)
for path in files:
    api.delete_file(path_in_repo=path, repo_id=HF_DATA_REPO_ID, repo_type="dataset", token=HF_DATA_TOKEN)
print("๐Ÿ—‘๏ธ repo ๋‚ด๋ถ€ ํŒŒ์ผ ๋ชจ๋‘ ์‚ญ์ œ ์™„๋ฃŒ")

# 2๏ธโƒฃ ์บ์‹œ ์‚ญ์ œ
cache_dir = os.path.expanduser("~/.cache/huggingface/datasets")
if os.path.exists(cache_dir):
    shutil.rmtree(cache_dir)
print("๐Ÿงน ๋กœ์ปฌ ์บ์‹œ ์ดˆ๊ธฐํ™” ์™„๋ฃŒ")

# 3๏ธโƒฃ repo ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ์ดˆ๊ธฐํ™”
api.create_repo(HF_DATA_REPO_ID, repo_type="dataset", token=HF_DATA_TOKEN, exist_ok=True, private=True)
print("โœ… dataset repo metadata ์žฌ์„ค์ • ์™„๋ฃŒ (๋นˆ ์ƒํƒœ)")