Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Script de vérification avant déploiement sur Hugging Face | |
| """ | |
| import os | |
| import sys | |
| from pathlib import Path | |
| def check_file_exists(filename, required=True): | |
| """Vérifie si un fichier existe""" | |
| exists = Path(filename).exists() | |
| status = "✅" if exists else ("❌" if required else "⚠️") | |
| required_text = "(requis)" if required else "(optionnel)" | |
| print(f"{status} {filename} {required_text}") | |
| return exists | |
| def check_env_file(): | |
| """Vérifie le fichier .env""" | |
| env_path = Path(".env") | |
| if env_path.exists(): | |
| print("\n⚠️ ATTENTION: Fichier .env détecté!") | |
| print(" Assurez-vous qu'il est dans .gitignore") | |
| print(" Ne JAMAIS commiter ce fichier!") | |
| return True | |
| else: | |
| print("\n✅ Pas de fichier .env (bien!)") | |
| print(" Utilisez les Repository secrets de Hugging Face") | |
| return False | |
| def check_requirements(): | |
| """Vérifie requirements.txt""" | |
| req_path = Path("requirements.txt") | |
| if req_path.exists(): | |
| with open(req_path) as f: | |
| lines = f.readlines() | |
| print(f"\n✅ requirements.txt trouvé ({len(lines)} dépendances)") | |
| return True | |
| else: | |
| print("\n❌ requirements.txt manquant!") | |
| return False | |
| def main(): | |
| print("=" * 60) | |
| print("🔍 Vérification Pre-Déploiement Hugging Face") | |
| print("=" * 60) | |
| print("\n📁 Fichiers Essentiels:") | |
| all_good = True | |
| # Fichiers requis | |
| all_good &= check_file_exists("app.py", required=True) | |
| all_good &= check_file_exists("main.py", required=True) | |
| all_good &= check_file_exists("Dockerfile", required=True) | |
| all_good &= check_file_exists("requirements.txt", required=True) | |
| print("\n📄 Documentation:") | |
| check_file_exists("README_HUGGINGFACE.md", required=True) | |
| check_file_exists("DEPLOYMENT_GUIDE.md", required=False) | |
| check_file_exists("QUICK_START.md", required=False) | |
| print("\n🛡️ Protection:") | |
| check_file_exists(".gitignore", required=True) | |
| check_file_exists(".dockerignore", required=True) | |
| print("\n🔑 Variables d'Environnement:") | |
| check_env_file() | |
| print("\n📦 Dépendances:") | |
| check_requirements() | |
| print("\n📋 Structure du Projet:") | |
| dirs_to_check = ["app", "app/routers", "app/services", "app/repositories", "app/models", "app/core"] | |
| for dir_name in dirs_to_check: | |
| exists = Path(dir_name).exists() | |
| status = "✅" if exists else "❌" | |
| print(f"{status} {dir_name}/") | |
| print("\n" + "=" * 60) | |
| if all_good: | |
| print("✅ TOUT EST PRÊT pour le déploiement!") | |
| print("\n📌 Prochaines étapes:") | |
| print(" 1. Créer un Space sur huggingface.co/new-space") | |
| print(" 2. Choisir SDK: Docker") | |
| print(" 3. Configurer Repository secrets (Settings)") | |
| print(" 4. Pousser le code (git ou interface web)") | |
| print("\n📖 Voir QUICK_START.md pour les détails") | |
| else: | |
| print("❌ Certains fichiers essentiels sont manquants!") | |
| print(" Vérifiez les ❌ ci-dessus") | |
| return 1 | |
| print("=" * 60) | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |