|
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)
|
|
|
|
|
|
user_info = api.whoami()
|
|
print(f"β
Logged in as: {user_info['name']}")
|
|
|
|
print("\nπ€ Force uploading all files...")
|
|
|
|
|
|
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="*"
|
|
)
|
|
|
|
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()
|
|
|