#!/usr/bin/env python3 """ Update HuggingFace dataset with new data. This script assumes you have: 1. HuggingFace CLI installed and logged in (huggingface-cli login) 2. Write access to your dataset repository """ import subprocess import sys import os def main(): # Get the dataset name from user or use a default dataset_name = input("Enter your HuggingFace dataset name (e.g., 'username/dataset-name'): ").strip() if not dataset_name: print("Dataset name is required!") sys.exit(1) # Current directory contains all the dataset files dataset_dir = os.path.dirname(os.path.abspath(__file__)) print(f"\nUpdating dataset: {dataset_name}") print(f"From directory: {dataset_dir}") # Use huggingface-cli to upload cmd = [ "huggingface-cli", "upload", dataset_name, dataset_dir, "--repo-type", "dataset", "--include", "*.json", "--include", "*.arrow", "--include", "*.md", "--include", "dataset_info.json", "--include", "dataset_dict.json", "--include", "state.json", "--include", "metadata.json" ] print("\nRunning command:") print(" ".join(cmd)) try: result = subprocess.run(cmd, check=True, capture_output=True, text=True) print("\nSuccess! Dataset updated.") print(result.stdout) except subprocess.CalledProcessError as e: print(f"\nError updating dataset: {e}") print(f"Error output: {e.stderr}") sys.exit(1) except FileNotFoundError: print("\nError: huggingface-cli not found!") print("Please install it with: pip install huggingface-hub") print("Then login with: huggingface-cli login") sys.exit(1) if __name__ == "__main__": main()