#!/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()