#!/usr/bin/env python3 """ Script to verify Hugging Face Spaces configuration """ import os import sys import logging # Configure logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) def check_required_files(): """Check if all required files for HF Spaces deployment exist""" required_files = [ "app.py", "requirements.txt", "README.md", "build.py", "download_model.py", ".gitignore" ] missing_files = [] for file in required_files: if not os.path.exists(file): missing_files.append(file) if missing_files: logger.error(f"Missing required files: {missing_files}") return False logger.info("✅ All required files present") return True def check_app_imports(): """Check if app.py can be imported without errors""" try: # Test basic imports import gradio as gr import torch from transformers import AutoModelForCausalLM, AutoTokenizer logger.info("✅ Basic imports successful") return True except Exception as e: logger.error(f"❌ Import error: {e}") return False def check_download_script(): """Check if download script can be imported""" try: from download_model import main as download_main logger.info("✅ Download script import successful") return True except Exception as e: logger.error(f"❌ Download script import error: {e}") return False def main(): """Main verification function""" logger.info("🔍 Verifying Hugging Face Spaces configuration...") checks = [ ("Required Files", check_required_files), ("App Imports", check_app_imports), ("Download Script", check_download_script) ] all_passed = True for check_name, check_func in checks: logger.info(f"Checking {check_name}...") if check_func(): logger.info(f"✅ {check_name} passed") else: logger.error(f"❌ {check_name} failed") all_passed = False if all_passed: logger.info("🎉 All checks passed! Ready for Hugging Face Spaces deployment.") else: logger.error("❌ Some checks failed. Please fix the issues above.") return all_passed if __name__ == "__main__": success = main() sys.exit(0 if success else 1)