Sundew_Diabetes_Commons / deploy_to_hf.py
mgbam's picture
Upload 12 files
ea7d209 verified
#!/usr/bin/env python3
"""
Deploy Sundew Diabetes Watch to Hugging Face Spaces
"""
import os
from pathlib import Path
from huggingface_hub import HfApi, login
def deploy():
print("🌿 Sundew Diabetes Watch - Hugging Face Deployment")
print("=" * 60)
# Check if already logged in
try:
api = HfApi()
whoami = api.whoami()
print(f"βœ… Already logged in as: {whoami['name']}")
except:
print("\nπŸ“ Please login to Hugging Face:")
print(" Get your token from: https://huggingface.co/settings/tokens")
print(" (You need a token with WRITE permissions)")
print()
login()
print("βœ… Login successful!")
# Upload files
repo_id = "mgbam/sundew_diabetes_watch"
repo_type = "space"
print(f"\nπŸ“€ Uploading to {repo_id}...")
files_to_upload = [
"app_advanced.py",
"app.py",
"requirements.txt",
"Dockerfile",
"README.md",
".streamlit/config.toml",
]
base_path = Path(__file__).parent
for file in files_to_upload:
file_path = base_path / file
if file_path.exists():
print(f" βœ“ {file}")
try:
api.upload_file(
path_or_fileobj=str(file_path),
path_in_repo=file,
repo_id=repo_id,
repo_type=repo_type,
)
except Exception as e:
print(f" ⚠ Warning: {e}")
else:
print(f" βœ— {file} (not found)")
print("\nβœ… Deployment complete!")
print(f"🌐 Your Space: https://huggingface.co/spaces/{repo_id}")
print("\n⏳ Docker build will start automatically (5-10 minutes)")
print(f"πŸ“Š Monitor build: https://huggingface.co/spaces/{repo_id}/logs")
print("\nπŸŽ‰ Once built, the ADVANCED app will be live!")
if __name__ == "__main__":
deploy()