- Move test scripts to tests/ directory for better organization - Add improved YOLOv5 postprocessing with reference implementation - Update gitignore to exclude *.mflow files and include main.spec - Add debug capabilities and coordinate scaling improvements - Enhance multi-series support with proper validation - Add AGENTS.md documentation and example utilities 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
204 lines
7.7 KiB
Python
204 lines
7.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script for new series-specific port ID configuration functionality
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
# Add the project root to Python path
|
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
parent_dir = os.path.dirname(current_dir)
|
|
sys.path.insert(0, parent_dir)
|
|
|
|
try:
|
|
from core.nodes.exact_nodes import ExactModelNode
|
|
print("[OK] Successfully imported ExactModelNode")
|
|
except ImportError as e:
|
|
print(f"[ERROR] Failed to import ExactModelNode: {e}")
|
|
sys.exit(1)
|
|
|
|
def test_port_id_properties():
|
|
"""Test that new port ID properties are created correctly"""
|
|
print("\n=== Testing Port ID Properties Creation ===")
|
|
|
|
try:
|
|
node = ExactModelNode()
|
|
|
|
# Test that all series port ID properties exist
|
|
series_properties = ['kl520_port_ids', 'kl720_port_ids', 'kl630_port_ids', 'kl730_port_ids', 'kl540_port_ids']
|
|
|
|
for prop in series_properties:
|
|
if hasattr(node, 'get_property'):
|
|
try:
|
|
value = node.get_property(prop)
|
|
print(f"[OK] Property {prop} exists with value: '{value}'")
|
|
except:
|
|
print(f"[ERROR] Property {prop} does not exist or cannot be accessed")
|
|
else:
|
|
print(f"[WARN] Node does not have get_property method (NodeGraphQt not available)")
|
|
break
|
|
|
|
# Test property options
|
|
if hasattr(node, '_property_options'):
|
|
for prop in series_properties:
|
|
if prop in node._property_options:
|
|
options = node._property_options[prop]
|
|
print(f"[OK] Property options for {prop}: {options}")
|
|
else:
|
|
print(f"[ERROR] No property options found for {prop}")
|
|
else:
|
|
print("[WARN] Node does not have _property_options")
|
|
|
|
except Exception as e:
|
|
print(f"[ERROR] Error testing port ID properties: {e}")
|
|
|
|
def test_display_properties():
|
|
"""Test that display properties work correctly"""
|
|
print("\n=== Testing Display Properties ===")
|
|
|
|
try:
|
|
node = ExactModelNode()
|
|
|
|
if not hasattr(node, 'get_display_properties'):
|
|
print("[WARN] Node does not have get_display_properties method (NodeGraphQt not available)")
|
|
return
|
|
|
|
# Test single-series mode
|
|
if hasattr(node, 'set_property'):
|
|
node.set_property('multi_series_mode', False)
|
|
single_props = node.get_display_properties()
|
|
print(f"[OK] Single-series display properties: {single_props}")
|
|
|
|
# Test multi-series mode
|
|
node.set_property('multi_series_mode', True)
|
|
node.set_property('enabled_series', ['520', '720'])
|
|
multi_props = node.get_display_properties()
|
|
print(f"[OK] Multi-series display properties: {multi_props}")
|
|
|
|
# Check if port ID properties are included
|
|
expected_port_props = ['kl520_port_ids', 'kl720_port_ids']
|
|
found_port_props = [prop for prop in multi_props if prop in expected_port_props]
|
|
print(f"[OK] Found port ID properties in display: {found_port_props}")
|
|
|
|
# Test with different enabled series
|
|
node.set_property('enabled_series', ['630', '730'])
|
|
multi_props_2 = node.get_display_properties()
|
|
print(f"[OK] Display properties with KL630/730: {multi_props_2}")
|
|
|
|
else:
|
|
print("[WARN] Node does not have set_property method (NodeGraphQt not available)")
|
|
|
|
except Exception as e:
|
|
print(f"[ERROR] Error testing display properties: {e}")
|
|
|
|
def test_multi_series_config():
|
|
"""Test multi-series configuration building"""
|
|
print("\n=== Testing Multi-Series Config Building ===")
|
|
|
|
try:
|
|
node = ExactModelNode()
|
|
|
|
if not hasattr(node, '_build_multi_series_config'):
|
|
print("[ERROR] Node does not have _build_multi_series_config method")
|
|
return
|
|
|
|
if not hasattr(node, 'set_property'):
|
|
print("[WARN] Node does not have set_property method (NodeGraphQt not available)")
|
|
return
|
|
|
|
# Test with sample configuration
|
|
node.set_property('enabled_series', ['520', '720'])
|
|
node.set_property('kl520_port_ids', '28,32')
|
|
node.set_property('kl720_port_ids', '30,34')
|
|
node.set_property('assets_folder', '/fake/assets/path')
|
|
|
|
# Build multi-series config
|
|
config = node._build_multi_series_config()
|
|
print(f"[OK] Generated multi-series config: {config}")
|
|
|
|
# Verify structure
|
|
if config:
|
|
expected_keys = ['KL520', 'KL720']
|
|
for key in expected_keys:
|
|
if key in config:
|
|
series_config = config[key]
|
|
print(f"[OK] {key} config: {series_config}")
|
|
|
|
if 'port_ids' in series_config:
|
|
print(f" - Port IDs: {series_config['port_ids']}")
|
|
else:
|
|
print(f" [ERROR] Missing port_ids in {key} config")
|
|
else:
|
|
print(f"[ERROR] Missing {key} in config")
|
|
else:
|
|
print("[ERROR] Generated config is None or empty")
|
|
|
|
# Test with invalid port IDs
|
|
node.set_property('kl520_port_ids', 'invalid,port,ids')
|
|
config_invalid = node._build_multi_series_config()
|
|
print(f"[OK] Config with invalid port IDs: {config_invalid}")
|
|
|
|
except Exception as e:
|
|
print(f"[ERROR] Error testing multi-series config: {e}")
|
|
|
|
def test_inference_config():
|
|
"""Test inference configuration"""
|
|
print("\n=== Testing Inference Config ===")
|
|
|
|
try:
|
|
node = ExactModelNode()
|
|
|
|
if not hasattr(node, 'get_inference_config'):
|
|
print("[ERROR] Node does not have get_inference_config method")
|
|
return
|
|
|
|
if not hasattr(node, 'set_property'):
|
|
print("[WARN] Node does not have set_property method (NodeGraphQt not available)")
|
|
return
|
|
|
|
# Test multi-series inference config
|
|
node.set_property('multi_series_mode', True)
|
|
node.set_property('enabled_series', ['520', '720'])
|
|
node.set_property('kl520_port_ids', '28,32')
|
|
node.set_property('kl720_port_ids', '30,34')
|
|
node.set_property('assets_folder', '/fake/assets')
|
|
node.set_property('max_queue_size', 50)
|
|
|
|
inference_config = node.get_inference_config()
|
|
print(f"[OK] Inference config: {inference_config}")
|
|
|
|
# Check if multi_series_config is included
|
|
if 'multi_series_config' in inference_config:
|
|
ms_config = inference_config['multi_series_config']
|
|
print(f"[OK] Multi-series config included: {ms_config}")
|
|
else:
|
|
print("[WARN] Multi-series config not found in inference config")
|
|
|
|
# Test single-series mode
|
|
node.set_property('multi_series_mode', False)
|
|
node.set_property('model_path', '/fake/model.nef')
|
|
node.set_property('port_id', '28')
|
|
|
|
single_config = node.get_inference_config()
|
|
print(f"[OK] Single-series config: {single_config}")
|
|
|
|
except Exception as e:
|
|
print(f"[ERROR] Error testing inference config: {e}")
|
|
|
|
def main():
|
|
"""Run all tests"""
|
|
print("Testing Series-Specific Port ID Configuration")
|
|
print("=" * 50)
|
|
|
|
test_port_id_properties()
|
|
test_display_properties()
|
|
test_multi_series_config()
|
|
test_inference_config()
|
|
|
|
print("\n" + "=" * 50)
|
|
print("Test completed!")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|