From 144089b1441343e8a65c05a6144fd88a5c788cd2 Mon Sep 17 00:00:00 2001 From: Masonmason Date: Thu, 17 Jul 2025 12:12:47 +0800 Subject: [PATCH] add test_ui_deployment --- cluster4npu_ui/test_ui_deployment.py | 115 +++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 cluster4npu_ui/test_ui_deployment.py diff --git a/cluster4npu_ui/test_ui_deployment.py b/cluster4npu_ui/test_ui_deployment.py new file mode 100644 index 0000000..8f73366 --- /dev/null +++ b/cluster4npu_ui/test_ui_deployment.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 +""" +Test UI deployment dialog without requiring Kneron SDK. +This tests the UI deployment flow to verify our fixes work. +""" + +import sys +import os +from PyQt5.QtWidgets import QApplication +from typing import Dict, Any + +# Add project paths +project_root = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, project_root) + +def create_test_pipeline_data() -> Dict[str, Any]: + """Create a minimal test pipeline that should work.""" + return { + 'project_name': 'Test Deployment Pipeline', + 'description': 'Testing fixed deployment with result handling', + 'version': '1.0', + 'nodes': [ + { + 'id': 'input_1', + 'name': 'Camera Input', + 'type': 'ExactInputNode', + 'pos': [100, 100], + 'properties': { + 'source_type': 'camera', # lowercase to match WorkflowOrchestrator + 'device_id': 0, + 'resolution': '640x480', + 'fps': 10 + } + }, + { + 'id': 'model_1', + 'name': 'Test Model', + 'type': 'ExactModelNode', + 'pos': [300, 100], + 'properties': { + 'model_path': '/path/to/test.nef', + 'scpu_fw_path': 'fw_scpu.bin', + 'ncpu_fw_path': 'fw_ncpu.bin', + 'port_ids': [28, 32], + 'upload_fw': True + } + }, + { + 'id': 'output_1', + 'name': 'Debug Output', + 'type': 'ExactOutputNode', + 'pos': [500, 100], + 'properties': { + 'output_type': 'console', + 'destination': './debug_output' + } + } + ], + 'connections': [ + { + 'input_node': 'input_1', + 'input_port': 'output', + 'output_node': 'model_1', + 'output_port': 'input' + }, + { + 'input_node': 'model_1', + 'input_port': 'output', + 'output_node': 'output_1', + 'output_port': 'input' + } + ] + } + +def main(): + """Test the deployment dialog.""" + print("๐Ÿงช TESTING UI DEPLOYMENT DIALOG") + print("=" * 50) + + app = QApplication(sys.argv) + + try: + # Import UI components + from ui.dialogs.deployment import DeploymentDialog + + # Create test pipeline data + pipeline_data = create_test_pipeline_data() + + print("1. Creating deployment dialog...") + dialog = DeploymentDialog(pipeline_data) + + print("2. Showing dialog...") + print(" - Click 'Analyze Pipeline' to test configuration") + print(" - Click 'Deploy to Dongles' to test deployment") + print(" - With our fixes, you should now see result debugging output") + print(" - Results should appear in the Live View tab") + + # Show the dialog + result = dialog.exec_() + + if result == dialog.Accepted: + print("โœ… Dialog completed successfully") + else: + print("โŒ Dialog was cancelled") + + except ImportError as e: + print(f"โŒ Could not import UI components: {e}") + print("This test needs to run with PyQt5 available") + except Exception as e: + print(f"โŒ Error testing deployment dialog: {e}") + import traceback + traceback.print_exc() + +if __name__ == "__main__": + main() \ No newline at end of file