import time from huggingface_hub import HfApi, login # --- CONFIGURATION --- # 1. Your Dataset ID (format: username/dataset-name) REPO_ID = "enronarchive/mail" # 2. Your local folder path (using 'r' for raw string is safer on Windows) LOCAL_FOLDER = r"D:\git\enron-mail" # --------------------- # Optional: Login explicitly if not already logged in # login(token="YOUR_WRITE_TOKEN_HERE") api = HfApi() print(f"Starting upload from '{LOCAL_FOLDER}' to '{REPO_ID}'...") print("The library will automatically handle the 370k files in batches.") try: api.upload_folder( folder_path=LOCAL_FOLDER, repo_id=REPO_ID, repo_type="dataset", path_in_repo=".", # This prevents uploading your git history and this script itself ignore_patterns=[".git", ".gitattributes", "upload_script.py", ".gitignore"] ) print("\n✅ Upload Complete! Your Enron Archive is live.") except Exception as e: print(f"\n❌ Error: {e}") print("If it stopped, simply run this script again. It will verify existing files and resume.")