Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions engine/cli/commands/hardware_list_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> column_headers{"(Index)", "Arch", "Cores", "Model",
std::vector<std::string> column_headers{"#", "Arch", "Cores", "Model",
"Instructions"};

Row_t header{column_headers.begin(), column_headers.end()};
Expand All @@ -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<std::string> column_headers{"(Index)", "Version", "Name"};
std::vector<std::string> column_headers{"#", "Version", "Name"};

Row_t header{column_headers.begin(), column_headers.end()};
table.add_row(header);
Expand All @@ -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<std::string> column_headers{"(Index)", "Total (MiB)",
std::vector<std::string> column_headers{"#", "Total (MiB)",
"Available (MiB)"};

Row_t header{column_headers.begin(), column_headers.end()};
Expand All @@ -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<std::string> column_headers{
"(Index)", "ID",
"Name", "Version",
"Total (MiB)", "Available (MiB)",
"Driver Version", "Compute Capability", "Activated"};
std::vector<std::string> 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);
Expand Down Expand Up @@ -144,7 +148,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<std::string> column_headers{"(Index)", "Total (GiB)",
std::vector<std::string> column_headers{"#", "Total (GiB)",
"Available (GiB)"};

Row_t header{column_headers.begin(), column_headers.end()};
Expand All @@ -163,14 +167,15 @@ 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<std::string> column_headers{"(Index)", "Battery Life",
std::vector<std::string> column_headers{"#", "Battery Life",
"Charging Status", "Power Saving"};

Row_t header{column_headers.begin(), column_headers.end()};
table.add_row(header);
table.format().font_color(Color::green);
std::vector<std::string> 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");
Expand Down
2 changes: 2 additions & 0 deletions engine/services/hardware_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading