Petite-LLM-3 / docsandtests /verify_spaces_config.py
Tonic's picture
small mods on the title and description
5975026
#!/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)