Spaces:
Sleeping
Sleeping
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 ์ฌ์ค์ ์๋ฃ (๋น ์ํ)")
|