From fb56ea19ced3a0c8b33f744be848e3dfa938f6ca Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Thu, 14 Nov 2024 13:26:30 +0700 Subject: [PATCH 1/3] fix: bypass check if activate GPU list is empty --- engine/services/hardware_service.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engine/services/hardware_service.cc b/engine/services/hardware_service.cc index c40133564..b9f8fe63b 100644 --- a/engine/services/hardware_service.cc +++ b/engine/services/hardware_service.cc @@ -297,6 +297,8 @@ void HardwareService::UpdateHardwareInfos() { bool HardwareService::IsValidConfig( const cortex::hw::ActivateHardwareConfig& ahc) { + if (ahc.gpus.empty()) + return true; cortex::db::Hardwares hw_db; auto is_valid = [&ahc](int software_id) { return std::count(ahc.gpus.begin(), ahc.gpus.end(), software_id) > 0; From 5861cf79f327e014c7ac5c057b6b0473a0c553e2 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Thu, 14 Nov 2024 13:40:12 +0700 Subject: [PATCH 2/3] chore: column name --- engine/cli/commands/hardware_list_cmd.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/engine/cli/commands/hardware_list_cmd.cc b/engine/cli/commands/hardware_list_cmd.cc index 0b65bba39..c5757a2f8 100644 --- a/engine/cli/commands/hardware_list_cmd.cc +++ b/engine/cli/commands/hardware_list_cmd.cc @@ -50,7 +50,7 @@ bool HardwareListCmd::Exec(const std::string& host, int port, if (!ho.has_value() || ho.value().show_cpu) { std::cout << "CPU Information:" << std::endl; Table table; - std::vector column_headers{"(Index)", "Arch", "Cores", "Model", + std::vector column_headers{"#", "Arch", "Cores", "Model", "Instructions"}; Row_t header{column_headers.begin(), column_headers.end()}; @@ -74,7 +74,7 @@ bool HardwareListCmd::Exec(const std::string& host, int port, if (!ho.has_value() || ho.value().show_os) { std::cout << "OS Information:" << std::endl; Table table; - std::vector column_headers{"(Index)", "Version", "Name"}; + std::vector column_headers{"#", "Version", "Name"}; Row_t header{column_headers.begin(), column_headers.end()}; table.add_row(header); @@ -91,7 +91,7 @@ bool HardwareListCmd::Exec(const std::string& host, int port, if (!ho.has_value() || ho.value().show_ram) { std::cout << "RAM Information:" << std::endl; Table table; - std::vector column_headers{"(Index)", "Total (MiB)", + std::vector column_headers{"#", "Total (MiB)", "Available (MiB)"}; Row_t header{column_headers.begin(), column_headers.end()}; @@ -110,7 +110,7 @@ bool HardwareListCmd::Exec(const std::string& host, int port, std::cout << "GPU Information:" << std::endl; Table table; std::vector column_headers{ - "(Index)", "ID", + "#", "GPU ID", "Name", "Version", "Total (MiB)", "Available (MiB)", "Driver Version", "Compute Capability", "Activated"}; @@ -144,7 +144,7 @@ bool HardwareListCmd::Exec(const std::string& host, int port, if (!ho.has_value() || ho.value().show_storage) { std::cout << "Storage Information:" << std::endl; Table table; - std::vector column_headers{"(Index)", "Total (GiB)", + std::vector column_headers{"#", "Total (GiB)", "Available (GiB)"}; Row_t header{column_headers.begin(), column_headers.end()}; @@ -163,7 +163,7 @@ bool HardwareListCmd::Exec(const std::string& host, int port, if (!ho.has_value() || ho.value().show_power) { std::cout << "Power Information:" << std::endl; Table table; - std::vector column_headers{"(Index)", "Battery Life", + std::vector column_headers{"#", "Battery Life", "Charging Status", "Power Saving"}; Row_t header{column_headers.begin(), column_headers.end()}; From 395b8163583cc837ec66f89914606f664130259a Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Thu, 14 Nov 2024 13:40:37 +0700 Subject: [PATCH 3/3] chore: column naming --- engine/cli/commands/hardware_list_cmd.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/engine/cli/commands/hardware_list_cmd.cc b/engine/cli/commands/hardware_list_cmd.cc index c5757a2f8..a800b0e24 100644 --- a/engine/cli/commands/hardware_list_cmd.cc +++ b/engine/cli/commands/hardware_list_cmd.cc @@ -106,14 +106,18 @@ bool HardwareListCmd::Exec(const std::string& host, int port, std::cout << std::endl; } - if (!ho.has_value() || ho.value().show_gpu) { + if (!ho.has_value() || ho.value().show_gpu) { std::cout << "GPU Information:" << std::endl; Table table; - std::vector column_headers{ - "#", "GPU ID", - "Name", "Version", - "Total (MiB)", "Available (MiB)", - "Driver Version", "Compute Capability", "Activated"}; + std::vector column_headers{"#", + "GPU ID", + "Name", + "Version", + "Total (MiB)", + "Available (MiB)", + "Driver Version", + "Compute Capability", + "Activated"}; Row_t header{column_headers.begin(), column_headers.end()}; table.add_row(header); @@ -170,7 +174,8 @@ bool HardwareListCmd::Exec(const std::string& host, int port, table.add_row(header); table.format().font_color(Color::green); std::vector row = {"1"}; - cortex::hw::PowerInfo pi = cortex::hw::power::FromJson(result.value()["power"]); + cortex::hw::PowerInfo pi = + cortex::hw::power::FromJson(result.value()["power"]); row.emplace_back(std::to_string(pi.battery_life)); row.emplace_back(pi.charging_status); row.emplace_back(pi.is_power_saving ? "Yes" : "No");