File size: 2,374 Bytes
623e14e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Test script to verify Hugging Face Spaces configuration
"""

import os
import sys

def check_huggingface_config():
    """Check if Hugging Face configuration is correct"""
    print("Checking Hugging Face Spaces configuration...")
    
    # Check if README.md exists and has the correct format
    if not os.path.exists("README.md"):
        print("❌ README.md file not found")
        return False
    
    with open("README.md", "r", encoding="utf-8") as f:
        content = f.read()
        
        # Check for required configuration section
        if not content.startswith("---"):
            print("❌ README.md missing configuration section")
            return False
            
        # Check for required fields
        required_fields = ["title:", "emoji:", "colorFrom:", "colorTo:", "sdk:", "app_file:"]
        for field in required_fields:
            if field not in content:
                print(f"❌ README.md missing required field: {field}")
                return False
                
        print("✅ README.md configuration section is correct")
    
    # Check if Dockerfile exists
    if not os.path.exists("Dockerfile"):
        print("❌ Dockerfile not found")
        return False
    print("✅ Dockerfile found")
    
    # Check if docker-compose.yml exists
    if not os.path.exists("docker-compose.yml"):
        print("❌ docker-compose.yml not found")
        return False
    print("✅ docker-compose.yml found")
    
    # Check if src directory exists
    if not os.path.exists("src"):
        print("❌ src directory not found")
        return False
    print("✅ src directory found")
    
    # Check if requirements.txt exists
    if not os.path.exists("requirements.txt"):
        print("❌ requirements.txt not found")
        return False
    print("✅ requirements.txt found")
    
    print("\n🎉 All Hugging Face Spaces configuration checks passed!")
    print("\nTo deploy to Hugging Face Spaces:")
    print("1. Create a new Space at https://huggingface.co/spaces/new")
    print("2. Select 'Docker' as the SDK")
    print("3. Upload all files in this directory to your Space repository")
    print("4. The Space will automatically build and deploy")
    
    return True

if __name__ == "__main__":
    success = check_huggingface_config()
    sys.exit(0 if success else 1)