Spaces:
Running
Running
File size: 3,819 Bytes
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 |
#!/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 monitoring import SmolLM3Monitor
print("β
monitoring module imported successfully")
from trainer import SmolLM3Trainer
print("β
trainer module imported successfully")
from model import SmolLM3Model
print("β
model module imported successfully")
from 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 main():
"""Run all tests"""
print("π§ͺ Testing String Formatting Fix")
print("=" * 40)
tests = [
("Logging", test_logging),
("Imports", test_imports),
("Config Loading", test_config_loading),
]
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()) |