Spaces:
Build error
Build error
Commit ·
3cc7351
1
Parent(s): a9f8f75
Fix: improve error handling in upload script for auth failures
Browse files- scripts/upload_data.py +6 -0
scripts/upload_data.py
CHANGED
|
@@ -12,6 +12,12 @@ def upload_data(repo_id, token, data_dir=".", db_file="rag-kb.db", vector_store_
|
|
| 12 |
print(f"Repository {repo_id} ensures.")
|
| 13 |
except Exception as e:
|
| 14 |
print(f"Note: Repo creation check: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Upload database
|
| 17 |
if os.path.exists(db_file):
|
|
|
|
| 12 |
print(f"Repository {repo_id} ensures.")
|
| 13 |
except Exception as e:
|
| 14 |
print(f"Note: Repo creation check: {e}")
|
| 15 |
+
if "401" in str(e) or "Unauthorized" in str(e):
|
| 16 |
+
print("\n❌ Error: Authentication failed. Your HF_TOKEN is invalid or expired.")
|
| 17 |
+
print("Please check your token at https://huggingface.co/settings/tokens")
|
| 18 |
+
print("You can run this script with a specific token:")
|
| 19 |
+
print(f" python3 scripts/upload_data.py --token hf_YOUR_TOKEN")
|
| 20 |
+
return
|
| 21 |
|
| 22 |
# Upload database
|
| 23 |
if os.path.exists(db_file):
|