File size: 4,479 Bytes
96fd5b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ebe598e
96fd5b3
 
ebe598e
96fd5b3
 
ebe598e
96fd5b3
 
ebe598e
96fd5b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ebe598e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96fd5b3
 
 
 
 
 
 
 
 
ebe598e
96fd5b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env python3
"""
Test script to verify the string formatting fix
"""

import sys
import os
import logging

# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def test_logging():
    """Test that logging works without f-string formatting errors"""
    try:
        # Test various logging scenarios that were causing issues
        logger.info("Testing logging with %s", "string formatting")
        logger.info("Testing with %d numbers", 42)
        logger.info("Testing with %s and %d", "text", 123)
        
        # Test error logging
        try:
            raise ValueError("Test error")
        except Exception as e:
            logger.error("Caught error: %s", e)
        
        print("βœ… All logging tests passed!")
        return True
        
    except Exception as e:
        print("❌ Logging test failed: {}".format(e))
        return False

def test_imports():
    """Test that all modules can be imported without formatting errors"""
    try:
        # Test importing the main modules
        from src.monitoring import SmolLM3Monitor
        print("βœ… monitoring module imported successfully")
        
        from src.trainer import SmolLM3Trainer
        print("βœ… trainer module imported successfully")
        
        from src.model import SmolLM3Model
        print("βœ… model module imported successfully")
        
        from src.data import SmolLM3Dataset
        print("βœ… data module imported successfully")
        
        return True
        
    except Exception as e:
        print("❌ Import test failed: {}".format(e))
        return False

def test_config_loading():
    """Test that configuration files can be loaded"""
    try:
        # Test loading a configuration
        config_path = "config/train_smollm3_openhermes_fr_a100_balanced.py"
        if os.path.exists(config_path):
            import importlib.util
            spec = importlib.util.spec_from_file_location("config_module", config_path)
            config_module = importlib.util.module_from_spec(spec)
            spec.loader.exec_module(config_module)
            
            if hasattr(config_module, 'config'):
                config = config_module.config
                print("βœ… Configuration loaded successfully")
                print("   Model: {}".format(config.model_name))
                print("   Batch size: {}".format(config.batch_size))
                print("   Learning rate: {}".format(config.learning_rate))
                return True
            else:
                print("❌ No config found in {}".format(config_path))
                return False
        else:
            print("❌ Config file not found: {}".format(config_path))
            return False
            
    except Exception as e:
        print("❌ Config loading test failed: {}".format(e))
        return False

def test_monitoring_creation():
    """Test that monitoring can be created without formatting errors"""
    try:
        from src.monitoring import SmolLM3Monitor
        
        # Test creating a monitor instance
        monitor = SmolLM3Monitor(
            experiment_name="test_experiment",
            enable_tracking=False  # Disable tracking for test
        )
        
        print("βœ… Monitoring instance created successfully")
        return True
        
    except Exception as e:
        print("❌ Monitoring creation test failed: {}".format(e))
        return False

def main():
    """Run all tests"""
    print("πŸ§ͺ Testing String Formatting Fix")
    print("=" * 40)
    
    tests = [
        ("Logging", test_logging),
        ("Imports", test_imports),
        ("Config Loading", test_config_loading),
        ("Monitoring Creation", test_monitoring_creation),
    ]
    
    passed = 0
    total = len(tests)
    
    for test_name, test_func in tests:
        print("\nπŸ” Testing: {}".format(test_name))
        if test_func():
            passed += 1
            print("βœ… {} test passed".format(test_name))
        else:
            print("❌ {} test failed".format(test_name))
    
    print("\n" + "=" * 40)
    print("πŸ“Š Test Results: {}/{} tests passed".format(passed, total))
    
    if passed == total:
        print("πŸŽ‰ All tests passed! The formatting fix is working correctly.")
        return 0
    else:
        print("⚠️  Some tests failed. Please check the errors above.")
        return 1

if __name__ == "__main__":
    sys.exit(main())