Spaces:
Runtime error
Runtime error
| from huggingface_hub import HfApi | |
| import os | |
| import glob | |
| import sys | |
| REPO_ID = "ABPThesisGroup/ThesisProject" | |
| BASE = r"c:\Users\Carl P\Thesis Repo\FactCheckThesis" | |
| api = HfApi() | |
| try: | |
| print(f"Who am I? {api.whoami()['name']}") | |
| except Exception as e: | |
| print(f"Authentication failed: {e}") | |
| print("Please login to Hugging Face CLI: huggingface-cli login") | |
| sys.exit(1) | |
| files = glob.glob(os.path.join(BASE, "data_models", "*.pkl")) | |
| if not len(files): | |
| print("No PKL files found in data_models/") | |
| sys.exit(1) | |
| for f in files: | |
| filename = os.path.basename(f) | |
| print(f"Uploading {filename} (size: {os.path.getsize(f) / (1024*1024):.1f} MB)...") | |
| try: | |
| api.upload_file(path_or_fileobj=f, path_in_repo=f"data_models/{filename}", repo_id=REPO_ID, repo_type="space") | |
| print(f" ✓ {filename} uploaded") | |
| except Exception as e: | |
| print(f" ❌ Failed to upload {filename}: {e}") | |
| print("\n✅ All PKL models successfully uploaded to Hugging Face!") | |