File size: 1,503 Bytes
1919b3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Test script to verify TrackioConfig dictionary-style access
"""

import trackio

print("Testing TrackioConfig dictionary-style access...")

# Test that config exists and has dictionary-style access
config = trackio.config
print(f"Config type: {type(config)}")
print(f"Has __getitem__: {hasattr(config, '__getitem__')}")
print(f"Has __setitem__: {hasattr(config, '__setitem__')}")

# Test dictionary-style assignment
print(f"Before assignment - project_name: {config.project_name}")
config['project_name'] = 'test_project'
print(f"After assignment - project_name: {config.project_name}")

# Test dictionary-style access
print(f"Dictionary access - project_name: {config['project_name']}")

# Test new key assignment
config['new_key'] = 'new_value'
print(f"New key assignment - new_key: {config['new_key']}")

# Test contains check
print(f"Contains 'project_name': {'project_name' in config}")
print(f"Contains 'nonexistent': {'nonexistent' in config}")

# Test get method
print(f"Get existing key: {config.get('project_name', 'default')}")
print(f"Get nonexistent key: {config.get('nonexistent', 'default')}")

# Test keys and items
print(f"Config keys: {list(config.keys())}")
print(f"Config items: {list(config.items())}")

# Test TRL-style usage
config['allow_val_change'] = True
config['report_to'] = 'trackio'
print(f"TRL-style config: allow_val_change={config['allow_val_change']}, report_to={config['report_to']}")

print("✅ Dictionary-style access works correctly!")