File size: 2,518 Bytes
1de56de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Test script to verify the fixes work correctly.
"""

import sys
from pathlib import Path

def test_training_scripts():
    """Test that training scripts can be imported without errors."""
    print("πŸ§ͺ Testing training script imports...")
    
    try:
        # Test train_lora.py
        sys.path.insert(0, str(Path(__file__).parent / "scripts"))
        from train_lora import main as train_lora_main
        print("βœ… train_lora.py imports successfully")
        
        # Test train.py
        from train import main as train_main
        print("βœ… train.py imports successfully")
        
        return True
    except Exception as e:
        print(f"❌ Training script import failed: {e}")
        return False

def test_deploy_script_syntax():
    """Test that deploy script has valid syntax."""
    print("πŸ§ͺ Testing deploy script syntax...")
    
    try:
        # Read the file and check for basic syntax issues
        with open("scripts/deploy_demo_space.py", "r", encoding="utf-8") as f:
            content = f.read()
        
        # Check for common syntax issues
        if "json.dumps(" in content and "}" in content:
            # Check if there are any stray } characters after json.dumps
            lines = content.split('\n')
            for i, line in enumerate(lines, 1):
                if "json.dumps(" in line and line.strip().endswith('}'):
                    print(f"❌ Found stray }} on line {i}: {line.strip()}")
                    return False
        
        print("βœ… Deploy script syntax appears valid")
        return True
    except Exception as e:
        print(f"❌ Deploy script syntax test failed: {e}")
        return False

if __name__ == "__main__":
    print("πŸš€ Testing fixes...")
    
    success = True
    
    # Test training scripts
    if not test_training_scripts():
        success = False
    
    # Test deploy script syntax
    if not test_deploy_script_syntax():
        success = False
    
    if success:
        print("\nπŸŽ‰ All fixes appear to be working!")
        print("\nKey fixes applied:")
        print("1. βœ… Changed report_to from 'wandb' to 'trackio' to avoid WandbCallback error")
        print("2. βœ… Fixed f-string syntax errors in deploy_demo_space.py")
        print("3. βœ… Removed stray } characters from json.dumps calls")
        print("\nThe training should now work correctly!")
    else:
        print("\n❌ Some tests failed. Please check the errors above.")
        sys.exit(1)