eeee / backend /sync.py
harii88's picture
Update backend/sync.py
c7169fc verified
raw
history blame contribute delete
472 Bytes
import os
import asyncio
from huggingface_hub import HfApi
api = HfApi()
async def upload_to_dataset(local_path, md5_name, original_name, repo_id, token):
if not token or not os.path.exists(local_path): return
try:
await asyncio.to_thread(api.upload_file, path_or_fileobj=local_path, path_in_repo=md5_name, repo_id=repo_id, repo_type="dataset", commit_message=f"Upload {original_name}", token=token)
os.remove(local_path)
except Exception: pass