|
|
from huggingface_hub import HfApi |
|
|
import os |
|
|
import glob |
|
|
|
|
|
|
|
|
def update_huggingface_dataset(repo_name, repo_type="dataset"): |
|
|
""" |
|
|
Update/overwrite files in an existing Hugging Face dataset repository, |
|
|
excluding the video subfolder. |
|
|
|
|
|
Args: |
|
|
repo_name (str): Name of the repository (format: "username/repo-name") |
|
|
repo_type (str): Type of repository ("dataset" or "model") |
|
|
""" |
|
|
|
|
|
api = HfApi() |
|
|
|
|
|
try: |
|
|
|
|
|
repo_root = "/nas/pohan/datasets/AIConfVideo/learningpaper24" |
|
|
|
|
|
|
|
|
files_to_upload = [] |
|
|
for root, dirs, files in os.walk(repo_root): |
|
|
|
|
|
if "video" in dirs: |
|
|
dirs.remove("video") |
|
|
|
|
|
for file in files: |
|
|
file_path = os.path.join(root, file) |
|
|
rel_path = os.path.relpath(file_path, repo_root) |
|
|
files_to_upload.append((file_path, rel_path)) |
|
|
|
|
|
|
|
|
for file_path, rel_path in files_to_upload: |
|
|
api.upload_file( |
|
|
path_or_fileobj=file_path, |
|
|
path_in_repo=rel_path, |
|
|
repo_id=repo_name, |
|
|
repo_type=repo_type, |
|
|
commit_message=f"Update file: {rel_path}", |
|
|
) |
|
|
print(f"Uploaded: {rel_path}") |
|
|
|
|
|
print(f"Successfully updated all files (except video folder) in {repo_name}") |
|
|
|
|
|
except Exception as e: |
|
|
print(f"Error occurred: {str(e)}") |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|
|
REPO_NAME = "vivianchen98/LearningPaper24" |
|
|
|
|
|
update_huggingface_dataset(REPO_NAME) |
|
|
|