Skip to content

Commit ccb9273

Browse files
fix: bypass check if activate GPU list is empty (#1682)
* fix: bypass check if activate GPU list is empty * chore: column name * chore: column naming --------- Co-authored-by: vansangpfiev <[email protected]>
1 parent 916e29f commit ccb9273

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

engine/cli/commands/hardware_list_cmd.cc

+17-12
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ bool HardwareListCmd::Exec(const std::string& host, int port,
5050
if (!ho.has_value() || ho.value().show_cpu) {
5151
std::cout << "CPU Information:" << std::endl;
5252
Table table;
53-
std::vector<std::string> column_headers{"(Index)", "Arch", "Cores", "Model",
53+
std::vector<std::string> column_headers{"#", "Arch", "Cores", "Model",
5454
"Instructions"};
5555

5656
Row_t header{column_headers.begin(), column_headers.end()};
@@ -74,7 +74,7 @@ bool HardwareListCmd::Exec(const std::string& host, int port,
7474
if (!ho.has_value() || ho.value().show_os) {
7575
std::cout << "OS Information:" << std::endl;
7676
Table table;
77-
std::vector<std::string> column_headers{"(Index)", "Version", "Name"};
77+
std::vector<std::string> column_headers{"#", "Version", "Name"};
7878

7979
Row_t header{column_headers.begin(), column_headers.end()};
8080
table.add_row(header);
@@ -91,7 +91,7 @@ bool HardwareListCmd::Exec(const std::string& host, int port,
9191
if (!ho.has_value() || ho.value().show_ram) {
9292
std::cout << "RAM Information:" << std::endl;
9393
Table table;
94-
std::vector<std::string> column_headers{"(Index)", "Total (MiB)",
94+
std::vector<std::string> column_headers{"#", "Total (MiB)",
9595
"Available (MiB)"};
9696

9797
Row_t header{column_headers.begin(), column_headers.end()};
@@ -106,14 +106,18 @@ bool HardwareListCmd::Exec(const std::string& host, int port,
106106
std::cout << std::endl;
107107
}
108108

109-
if (!ho.has_value() || ho.value().show_gpu) {
109+
if (!ho.has_value() || ho.value().show_gpu) {
110110
std::cout << "GPU Information:" << std::endl;
111111
Table table;
112-
std::vector<std::string> column_headers{
113-
"(Index)", "ID",
114-
"Name", "Version",
115-
"Total (MiB)", "Available (MiB)",
116-
"Driver Version", "Compute Capability", "Activated"};
112+
std::vector<std::string> column_headers{"#",
113+
"GPU ID",
114+
"Name",
115+
"Version",
116+
"Total (MiB)",
117+
"Available (MiB)",
118+
"Driver Version",
119+
"Compute Capability",
120+
"Activated"};
117121

118122
Row_t header{column_headers.begin(), column_headers.end()};
119123
table.add_row(header);
@@ -144,7 +148,7 @@ bool HardwareListCmd::Exec(const std::string& host, int port,
144148
if (!ho.has_value() || ho.value().show_storage) {
145149
std::cout << "Storage Information:" << std::endl;
146150
Table table;
147-
std::vector<std::string> column_headers{"(Index)", "Total (GiB)",
151+
std::vector<std::string> column_headers{"#", "Total (GiB)",
148152
"Available (GiB)"};
149153

150154
Row_t header{column_headers.begin(), column_headers.end()};
@@ -163,14 +167,15 @@ bool HardwareListCmd::Exec(const std::string& host, int port,
163167
if (!ho.has_value() || ho.value().show_power) {
164168
std::cout << "Power Information:" << std::endl;
165169
Table table;
166-
std::vector<std::string> column_headers{"(Index)", "Battery Life",
170+
std::vector<std::string> column_headers{"#", "Battery Life",
167171
"Charging Status", "Power Saving"};
168172

169173
Row_t header{column_headers.begin(), column_headers.end()};
170174
table.add_row(header);
171175
table.format().font_color(Color::green);
172176
std::vector<std::string> row = {"1"};
173-
cortex::hw::PowerInfo pi = cortex::hw::power::FromJson(result.value()["power"]);
177+
cortex::hw::PowerInfo pi =
178+
cortex::hw::power::FromJson(result.value()["power"]);
174179
row.emplace_back(std::to_string(pi.battery_life));
175180
row.emplace_back(pi.charging_status);
176181
row.emplace_back(pi.is_power_saving ? "Yes" : "No");

engine/services/hardware_service.cc

+2
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ void HardwareService::UpdateHardwareInfos() {
297297

298298
bool HardwareService::IsValidConfig(
299299
const cortex::hw::ActivateHardwareConfig& ahc) {
300+
if (ahc.gpus.empty())
301+
return true;
300302
cortex::db::Hardwares hw_db;
301303
auto is_valid = [&ahc](int software_id) {
302304
return std::count(ahc.gpus.begin(), ahc.gpus.end(), software_id) > 0;

0 commit comments

Comments
 (0)