File size: 1,634 Bytes
795183d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
from huggingface_hub import HfApi
import os
def force_update_space():
"""Force update the Hugging Face Space with latest content"""
print("π FORCE UPDATING HUGGING FACE SPACE")
print("=" * 50)
try:
token = os.getenv("HF_TOKEN")
api = HfApi(token=token)
# Test login
user_info = api.whoami()
print(f"β
Logged in as: {user_info['name']}")
print("\nπ€ Force uploading all files...")
# Upload with force overwrite
api.upload_folder(
folder_path=".",
repo_id="Cosmo125/Singtel_Bill_Scanner",
repo_type="space",
ignore_patterns=[
"*.pyc",
"__pycache__/",
".venv/",
"test_*.png",
"test_*.jpg",
"sample_*.jpg",
"*.log",
".git/",
"check_space.py",
"force_update.py"
],
commit_message="π Force update: Fix README and Streamlit app functionality",
delete_patterns="*" # This will replace all files
)
print("\nπ SUCCESS! Force update completed!")
print("π Check your space: https://huggingface.co/spaces/Cosmo125/Singtel_Bill_Scanner")
print("β³ Allow 2-3 minutes for the app to rebuild")
return True
except Exception as e:
print(f"β Force update failed: {e}")
return False
if __name__ == "__main__":
force_update_space()
|