Spaces:
Running
Running
File size: 4,968 Bytes
764a584 5fe0328 764a584 5fe0328 764a584 5fe0328 764a584 |
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 |
#!/usr/bin/env python3
"""
Test script to verify TrackioConfig update method fix
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
def test_trackio_config_update():
"""Test that TrackioConfig update method works correctly"""
print("π§ͺ Testing TrackioConfig update method...")
try:
# Import trackio module
import trackio
# Test that config attribute exists
assert hasattr(trackio, 'config'), "trackio.config not found"
print("β
trackio.config exists")
# Test that config has update method
config = trackio.config
assert hasattr(config, 'update'), "TrackioConfig.update method not found"
print("β
TrackioConfig.update method exists")
# Test update method functionality with dictionary
test_config = {
'project_name': 'test_project',
'experiment_name': 'test_experiment',
'new_attribute': 'test_value'
}
# Call update method with dictionary
config.update(test_config)
# Verify updates
assert config.project_name == 'test_project', f"Expected 'test_project', got '{config.project_name}'"
assert config.experiment_name == 'test_experiment', f"Expected 'test_experiment', got '{config.experiment_name}'"
assert config.new_attribute == 'test_value', f"Expected 'test_value', got '{config.new_attribute}'"
print("β
TrackioConfig.update method works correctly with dictionary")
# Test update method with keyword arguments (TRL style)
config.update(allow_val_change=True, trl_setting='test_value')
# Verify keyword argument updates
assert config.allow_val_change == True, f"Expected True, got '{config.allow_val_change}'"
assert config.trl_setting == 'test_value', f"Expected 'test_value', got '{config.trl_setting}'"
print("β
TrackioConfig.update method works correctly with keyword arguments")
print("β
All attributes updated successfully")
return True
except Exception as e:
print(f"β Test failed: {e}")
return False
def test_trackio_trl_compatibility():
"""Test that trackio is fully compatible with TRL expectations"""
print("\nπ Testing TRL Compatibility...")
try:
import trackio
# Test all required functions exist
required_functions = ['init', 'log', 'finish']
for func_name in required_functions:
assert hasattr(trackio, func_name), f"trackio.{func_name} not found"
print(f"β
trackio.{func_name} exists")
# Test config attribute exists and has update method
assert hasattr(trackio, 'config'), "trackio.config not found"
assert hasattr(trackio.config, 'update'), "trackio.config.update not found"
print("β
trackio.config.update exists")
# Test that init can be called without arguments (TRL compatibility)
try:
experiment_id = trackio.init()
print(f"β
trackio.init() called successfully: {experiment_id}")
except Exception as e:
print(f"β trackio.init() failed: {e}")
return False
# Test that log can be called
try:
trackio.log({'test_metric': 1.0})
print("β
trackio.log() called successfully")
except Exception as e:
print(f"β trackio.log() failed: {e}")
return False
# Test that finish can be called
try:
trackio.finish()
print("β
trackio.finish() called successfully")
except Exception as e:
print(f"β trackio.finish() failed: {e}")
return False
print("β
All TRL compatibility tests passed")
return True
except Exception as e:
print(f"β TRL compatibility test failed: {e}")
return False
def main():
"""Run all tests"""
print("π§ͺ TrackioConfig Update Fix Test")
print("=" * 40)
# Test 1: Update method functionality
test1_passed = test_trackio_config_update()
# Test 2: TRL compatibility
test2_passed = test_trackio_trl_compatibility()
# Summary
print("\n" + "=" * 40)
print("π Test Results Summary")
print("=" * 40)
print(f"β
Update Method Test: {'PASSED' if test1_passed else 'FAILED'}")
print(f"β
TRL Compatibility Test: {'PASSED' if test2_passed else 'FAILED'}")
if test1_passed and test2_passed:
print("\nπ All tests passed! TrackioConfig update fix is working correctly.")
return True
else:
print("\nβ Some tests failed. Please check the implementation.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1) |