diff --git a/cluster4npu_ui/Screenshot 2025-07-10 at 1.22.11 PM.png b/cluster4npu_ui/Screenshot 2025-07-10 at 1.22.11 PM.png deleted file mode 100644 index 2bc851c..0000000 Binary files a/cluster4npu_ui/Screenshot 2025-07-10 at 1.22.11 PM.png and /dev/null differ diff --git a/cluster4npu_ui/core/functions/Multidongle.py b/cluster4npu_ui/core/functions/Multidongle.py index 3031438..73fff46 100644 --- a/cluster4npu_ui/core/functions/Multidongle.py +++ b/cluster4npu_ui/core/functions/Multidongle.py @@ -78,6 +78,14 @@ class MultiDongle: # 'YCBCR422_Y0CBY1CR': kp.ImageFormat.KP_IMAGE_FORMAT_Y0CBY1CR, } + DongleModelMap = { + "0x100": "KL520", + "0x720": "KL720", + "0x630": "KL630", + "0x730": "KL730", + "0x540": "KL540", + } + @staticmethod def scan_devices(): """ @@ -98,67 +106,33 @@ class MultiDongle: devices_info = [] - # Handle both dict and object formats - if isinstance(device_descriptors, dict): - # Handle JSON dict format: {"0": {...}, "1": {...}} - print(f' - Found {len(device_descriptors)} device(s):') - - for key, device_desc in device_descriptors.items(): - # Get device series using product_id - series = MultiDongle._get_device_series(device_desc) - # Use usb_port_id from the device descriptor - port_id = device_desc.get('usb_port_id', 0) + # device_descriptors can be a list of devices or a single device object + devices = device_descriptors + if not isinstance(devices, list): + devices = [devices] + + print(f' - Found {len(devices)} device(s):') + + for i, device_desc in enumerate(devices): + try: + product_id_hex = hex(device_desc.product_id).strip().lower() + dongle_model = MultiDongle.DongleModelMap.get(product_id_hex, "Unknown") device_info = { - 'port_id': port_id, - 'series': series, + 'port_id': device_desc.usb_port_id, + 'product_id': product_id_hex, + 'kn_number': device_desc.kn_number, + 'dongle': dongle_model, + 'series': dongle_model, # Assuming series is the same as dongle model 'device_descriptor': device_desc } devices_info.append(device_info) - print(f' [{int(key)+1}] Port ID: {port_id}, Series: {series}, Product ID: {device_desc.get("product_id", "Unknown")}') - - elif isinstance(device_descriptors, (list, tuple)): - # Handle list/array format - print(f' - Found {len(device_descriptors)} device(s):') - - for i, device_desc in enumerate(device_descriptors): - # Get device series - series = MultiDongle._get_device_series(device_desc) - - # Extract port_id based on format - if isinstance(device_desc, dict): - port_id = device_desc.get('usb_port_id', device_desc.get('port_id', 0)) - else: - port_id = getattr(device_desc, 'usb_port_id', getattr(device_desc, 'port_id', 0)) - - device_info = { - 'port_id': port_id, - 'series': series, - 'device_descriptor': device_desc - } - devices_info.append(device_info) - - print(f' [{i+1}] Port ID: {port_id}, Series: {series}') - else: - # Handle single device or other formats - print(' - Found 1 device:') - series = MultiDongle._get_device_series(device_descriptors) - - if isinstance(device_descriptors, dict): - port_id = device_descriptors.get('usb_port_id', device_descriptors.get('port_id', 0)) - else: - port_id = getattr(device_descriptors, 'usb_port_id', getattr(device_descriptors, 'port_id', 0)) - - device_info = { - 'port_id': port_id, - 'series': series, - 'device_descriptor': device_descriptors - } - devices_info.append(device_info) - - print(f' [1] Port ID: {port_id}, Series: {series}') - + print(f' [{i+1}] Port ID: {device_info["port_id"]}, Series: {device_info["series"]}, Product ID: {device_info["product_id"]}, KN Number: {device_info["kn_number"]}') + + except Exception as e: + print(f"Error processing device: {e}") + return devices_info except kp.ApiKPException as exception: @@ -177,20 +151,11 @@ class MultiDongle: str: Device series (e.g., 'KL520', 'KL720', etc.) """ try: - # TODO: Check Product ID to device series mapping - product_id_mapping = { - '0x100': 'KL520', - '0x720': 'KL720', - '0x630': 'KL630', - '0x730': 'KL730', - '0x540': 'KL540', - } - # Handle dict format (from JSON) if isinstance(device_descriptor, dict): product_id = device_descriptor.get('product_id', '') - if product_id in product_id_mapping: - return product_id_mapping[product_id] + if product_id in MultiDongle.DongleModelMap: + return MultiDongle.DongleModelMap[product_id] return f'Unknown ({product_id})' # Handle object format (from SDK) @@ -198,8 +163,8 @@ class MultiDongle: product_id = device_descriptor.product_id if isinstance(product_id, int): product_id = hex(product_id) - if product_id in product_id_mapping: - return product_id_mapping[product_id] + if product_id in MultiDongle.DongleModelMap: + return MultiDongle.DongleModelMap[product_id] return f'Unknown ({product_id})' # Legacy chip-based detection (fallback) diff --git a/cluster4npu_ui/debug_deployment.py b/cluster4npu_ui/tests/debug_deployment.py similarity index 100% rename from cluster4npu_ui/debug_deployment.py rename to cluster4npu_ui/tests/debug_deployment.py diff --git a/cluster4npu_ui/deploy_demo.py b/cluster4npu_ui/tests/deploy_demo.py similarity index 100% rename from cluster4npu_ui/deploy_demo.py rename to cluster4npu_ui/tests/deploy_demo.py diff --git a/cluster4npu_ui/deployment_terminal_example.py b/cluster4npu_ui/tests/deployment_terminal_example.py similarity index 100% rename from cluster4npu_ui/deployment_terminal_example.py rename to cluster4npu_ui/tests/deployment_terminal_example.py diff --git a/cluster4npu_ui/device_detection_example.py b/cluster4npu_ui/tests/device_detection_example.py similarity index 100% rename from cluster4npu_ui/device_detection_example.py rename to cluster4npu_ui/tests/device_detection_example.py diff --git a/cluster4npu_ui/test_deploy.py b/cluster4npu_ui/tests/test_deploy.py similarity index 100% rename from cluster4npu_ui/test_deploy.py rename to cluster4npu_ui/tests/test_deploy.py diff --git a/cluster4npu_ui/test_deploy_simple.py b/cluster4npu_ui/tests/test_deploy_simple.py similarity index 100% rename from cluster4npu_ui/test_deploy_simple.py rename to cluster4npu_ui/tests/test_deploy_simple.py diff --git a/cluster4npu_ui/test_modifications.py b/cluster4npu_ui/tests/test_modifications.py similarity index 100% rename from cluster4npu_ui/test_modifications.py rename to cluster4npu_ui/tests/test_modifications.py diff --git a/cluster4npu_ui/test_ui_deployment.py b/cluster4npu_ui/tests/test_ui_deployment.py similarity index 100% rename from cluster4npu_ui/test_ui_deployment.py rename to cluster4npu_ui/tests/test_ui_deployment.py