File size: 2,450 Bytes
384c439
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/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)