Skip to content

chore: Move to C++17 and fix extra warnings #2138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 20, 2025
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
4 changes: 1 addition & 3 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,8 @@ if(CMAKE_CXX_STANDARD LESS 17)
message(STATUS "use c++14")
find_package(Boost 1.61.0 REQUIRED)
target_include_directories(${TARGET_NAME} PRIVATE ${Boost_INCLUDE_DIRS})
elseif(CMAKE_CXX_STANDARD LESS 20)
message(STATUS "use c++17")
else()
message(STATUS "use c++20")
message(STATUS "use c++17")
endif()

aux_source_directory(controllers CTL_SRC)
Expand Down
1 change: 1 addition & 0 deletions engine/cli/command_line_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
#else
CLI_LOG("default");
#endif
(void) c;
};
app_.add_flag_function("-v,--version", cb, "Get Cortex version");

Expand Down
7 changes: 4 additions & 3 deletions engine/cli/commands/config_get_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ void commands::ConfigGetCmd::Exec(const std::string& host, int port) {
}
}
auto url = url_parser::Url{
.protocol = "http",
.host = host + ":" + std::to_string(port),
.pathParams = {"v1", "configs"},
/* .protocol = */ "http",
/* .host = */ host + ":" + std::to_string(port),
/* .pathParams = */ {"v1", "configs"},
/* .queries = */ {},
};

auto get_config_result = curl_utils::SimpleGetJson(url.ToFullPath());
Expand Down
7 changes: 4 additions & 3 deletions engine/cli/commands/config_upd_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ void commands::ConfigUpdCmd::Exec(
}

auto url = url_parser::Url{
.protocol = "http",
.host = host + ":" + std::to_string(port),
.pathParams = {"v1", "configs"},
/* .protocol = */ "http",
/* .host = */ host + ":" + std::to_string(port),
/* .pathParams = */ {"v1", "configs"},
/* .queries = */ {},
};

auto json = NormalizeJson(non_null_opts);
Expand Down
97 changes: 60 additions & 37 deletions engine/cli/commands/cortex_upd_cmd.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "cortex_upd_cmd.h"
#include <optional>
#include "cli/commands/server_start_cmd.h"
#include "server_stop_cmd.h"
#include "utils/archive_utils.h"
Expand Down Expand Up @@ -27,7 +28,8 @@ std::chrono::seconds GetTimeSinceEpochMillisec() {
return duration_cast<seconds>(system_clock::now().time_since_epoch());
}

std::unique_ptr<system_info_utils::SystemInfo> GetSystemInfoWithUniversal() {
[[maybe_unused]] std::unique_ptr<system_info_utils::SystemInfo>
GetSystemInfoWithUniversal() {
auto system_info = system_info_utils::GetSystemInfo();
if (system_info->os == "mac") {
CTL_INF("Change arch from " << system_info->arch << " to universal");
Expand All @@ -36,8 +38,8 @@ std::unique_ptr<system_info_utils::SystemInfo> GetSystemInfoWithUniversal() {
return system_info;
}

std::string GetNightlyInstallerName(const std::string& v,
const std::string& os_arch) {
[[maybe_unused]] std::string GetNightlyInstallerName(
const std::string& v, const std::string& os_arch) {
const std::string kCortex = "cortex";
// Remove 'v' in file name
std::string version = v == "latest" ? "" : (v.substr(1) + "-");
Expand All @@ -50,7 +52,7 @@ std::string GetNightlyInstallerName(const std::string& v,
#endif
}

std::string GetInstallCmd(const std::string& exe_path) {
[[maybe_unused]] std::string GetInstallCmd(const std::string& exe_path) {
#if defined(__APPLE__) && defined(__MACH__)
return "sudo touch /var/tmp/cortex_installer_skip_postinstall_check && sudo "
"installer "
Expand Down Expand Up @@ -133,6 +135,7 @@ bool InstallNewVersion(const std::filesystem::path& dst,

std::optional<std::string> CheckNewUpdate(
std::optional<std::chrono::milliseconds> timeout) {
(void)timeout;
// Get info from .cortexrc
auto should_check_update = false;
auto config = file_manager_utils::GetCortexConfig();
Expand All @@ -152,9 +155,10 @@ std::optional<std::string> CheckNewUpdate(
}

auto url = url_parser::Url{
.protocol = "https",
.host = GetHostName(),
.pathParams = GetReleasePath(),
/* .protocol = */ "https",
/* .host = */ GetHostName(),
/* .pathParams = */ GetReleasePath(),
/* .queries = */ {},
};

CTL_INF("Engine release path: " << url.ToFullPath());
Expand Down Expand Up @@ -264,9 +268,10 @@ bool CortexUpdCmd::GetStable(const std::string& v) {
CTL_INF("OS: " << system_info->os << ", Arch: " << system_info->arch);

auto url_obj = url_parser::Url{
.protocol = "https",
.host = GetHostName(),
.pathParams = GetReleasePath(),
/* .protocol = */ "https",
/* .host = */ GetHostName(),
/* .pathParams = */ GetReleasePath(),
/* .queries = */ {},
};
CTL_INF("Engine release path: " << url_obj.ToFullPath());

Expand Down Expand Up @@ -318,9 +323,10 @@ bool CortexUpdCmd::GetBeta(const std::string& v) {
CTL_INF("OS: " << system_info->os << ", Arch: " << system_info->arch);

auto url_obj = url_parser::Url{
.protocol = "https",
.host = GetHostName(),
.pathParams = GetReleasePath(),
/* .protocol = */ "https",
/* .host = */ GetHostName(),
/* .pathParams = */ GetReleasePath(),
/* queries = */ {},
};
CTL_INF("Engine release path: " << url_obj.ToFullPath());
auto res = curl_utils::SimpleGetJson(url_obj.ToFullPath());
Expand Down Expand Up @@ -410,12 +416,17 @@ std::optional<std::string> CortexUpdCmd::HandleGithubRelease(
return std::nullopt;
}
auto download_task{DownloadTask{
.id = "cortex",
.type = DownloadType::Cortex,
.items = {DownloadItem{
.id = "cortex",
.downloadUrl = download_url,
.localPath = local_path,
/* .id = */ "cortex",
/* .status = */ DownloadTask::Status::Pending,
/* .type = */ DownloadType::Cortex,
/* .items = */
{DownloadItem{
/* .id = */ "cortex",
/* .downloadUrl = */ download_url,
/* .localPath = */ local_path,
/* .checksum = */ std::nullopt,
/* .bytes = */ std::nullopt,
/* .downloadedBytes = */ std::nullopt,
}},
}};

Expand Down Expand Up @@ -456,9 +467,10 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
};
std::vector<std::string> path_list(paths, std::end(paths));
auto url_obj = url_parser::Url{
.protocol = "https",
.host = kNightlyHost,
.pathParams = path_list,
/* .protocol = */ "https",
/* .host = */ kNightlyHost,
/* .pathParams = */ path_list,
/* .queries = */ {},
};

CTL_INF("Cortex release path: " << url_parser::FromUrl(url_obj));
Expand All @@ -474,12 +486,17 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
return false;
}
auto download_task =
DownloadTask{.id = "cortex",
.type = DownloadType::Cortex,
.items = {DownloadItem{
.id = "cortex",
.downloadUrl = url_parser::FromUrl(url_obj),
.localPath = localPath,
DownloadTask{/* .id = */ "cortex",
/* .status = */ DownloadTask::Status::Pending,
/* .type = */ DownloadType::Cortex,
/* .items = */
{DownloadItem{
/* .id = */ "cortex",
/* .downloadUrl = */ url_parser::FromUrl(url_obj),
/* .localPath = */ localPath,
/* .checksum = */ std::nullopt,
/* .bytes = */ std::nullopt,
/* .downloadedBytes = */ std::nullopt,
}}};

auto result = download_service_->AddDownloadTask(
Expand Down Expand Up @@ -522,9 +539,10 @@ bool CortexUpdCmd::GetLinuxInstallScript(const std::string& v,
"templates", "linux", "install.sh"};
}
auto url_obj = url_parser::Url{
.protocol = "https",
.host = "raw.githubusercontent.com",
.pathParams = path_list,
/* .protocol = */ "https",
/* .host = */ "raw.githubusercontent.com",
/* .pathParams = */ path_list,
/* .queries = */ {},
};

CTL_INF("Linux installer script path: " << url_parser::FromUrl(url_obj));
Expand All @@ -540,12 +558,17 @@ bool CortexUpdCmd::GetLinuxInstallScript(const std::string& v,
return false;
}
auto download_task =
DownloadTask{.id = "cortex",
.type = DownloadType::Cortex,
.items = {DownloadItem{
.id = "cortex",
.downloadUrl = url_parser::FromUrl(url_obj),
.localPath = localPath,
DownloadTask{/* .id = */ "cortex",
/* .status = */ DownloadTask::Status::Pending,
/* .type = */ DownloadType::Cortex,
/* .items = */
{DownloadItem{
/* .id = */ "cortex",
/* .downloadUrl = */ url_parser::FromUrl(url_obj),
/* .localPath = */ localPath,
/* .checksum = */ std::nullopt,
/* .bytes = */ std::nullopt,
/* .downloadedBytes = */ std::nullopt,
}}};

auto result = download_service_->AddDownloadTask(
Expand Down
16 changes: 8 additions & 8 deletions engine/cli/commands/engine_get_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ void EngineGetCmd::Exec(const std::string& host, int port,
tabulate::Table table;
table.add_row({"#", "Name", "Version", "Variant", "Status"});

auto url = url_parser::Url{
.protocol = "http",
.host = host + ":" + std::to_string(port),
.pathParams = {"v1", "engines", engine_name},
};
auto url = url_parser::Url{/* .protocol = */ "http",
/* .host = */ host + ":" + std::to_string(port),
/* .pathParams = */ {"v1", "engines", engine_name},
/* .queries = */ {}};
auto result = curl_utils::SimpleGetJson(url.ToFullPath());
if (result.has_error()) {
// TODO: refactor this
Expand All @@ -50,9 +49,10 @@ void EngineGetCmd::Exec(const std::string& host, int port,
auto installed_variants = result.value();
for (const auto& variant : installed_variants) {
output.push_back(EngineVariantResponse{
.name = variant["name"].asString(),
.version = variant["version"].asString(),
.engine = engine_name,
/* .name = */ variant["name"].asString(),
/* .version = */ variant["version"].asString(),
/* .engine = */ engine_name,
/* .type = */ "",
});
}

Expand Down
66 changes: 35 additions & 31 deletions engine/cli/commands/engine_install_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ bool EngineInstallCmd::Exec(const std::string& engine,
});

auto releases_url = url_parser::Url{
.protocol = "http",
.host = host_ + ":" + std::to_string(port_),
.pathParams = {"v1", "engines", engine, "releases"},
/* .protocol = */ "http",
/* .host = */ host_ + ":" + std::to_string(port_),
/* .pathParams = */ {"v1", "engines", engine, "releases"},
/* .queries = */ {},
};
auto releases_result = curl_utils::SimpleGetJson(releases_url.ToFullPath());
if (releases_result.has_error()) {
Expand All @@ -70,16 +71,17 @@ bool EngineInstallCmd::Exec(const std::string& engine,
std::cout << "Selected version: " << selected_release.value() << std::endl;

auto variant_url = url_parser::Url{
.protocol = "http",
.host = host_ + ":" + std::to_string(port_),
.pathParams =
{
"v1",
"engines",
engine,
"releases",
selected_release.value(),
},
/* .protocol = */ "http",
/* .host = */ host_ + ":" + std::to_string(port_),
/* .pathParams = */
{
"v1",
"engines",
engine,
"releases",
selected_release.value(),
},
/* queries = */ {},
};
auto variant_result = curl_utils::SimpleGetJson(variant_url.ToFullPath());
if (variant_result.has_error()) {
Expand Down Expand Up @@ -117,15 +119,16 @@ bool EngineInstallCmd::Exec(const std::string& engine,
<< selected_release.value() << std::endl;

auto install_url = url_parser::Url{
.protocol = "http",
.host = host_ + ":" + std::to_string(port_),
.pathParams =
{
"v1",
"engines",
engine,
"install",
},
/* .protocol = */ "http",
/* .host = */ host_ + ":" + std::to_string(port_),
/* .pathParams = */
{
"v1",
"engines",
engine,
"install",
},
/* queries = */ {},
};
Json::Value body;
body["version"] = selected_release.value();
Expand Down Expand Up @@ -160,15 +163,16 @@ bool EngineInstallCmd::Exec(const std::string& engine,
});

auto install_url = url_parser::Url{
.protocol = "http",
.host = host_ + ":" + std::to_string(port_),
.pathParams =
{
"v1",
"engines",
engine,
"install",
},
/* .protocol = */ "http",
/* .host = */ host_ + ":" + std::to_string(port_),
/* .pathParams = */
{
"v1",
"engines",
engine,
"install",
},
/* .queries = */ {},
};

Json::Value body;
Expand Down
10 changes: 7 additions & 3 deletions engine/cli/commands/engine_install_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ class EngineInstallCmd {
host_(host),
port_(port),
show_menu_(show_menu),
hw_inf_{.sys_inf = system_info_utils::GetSystemInfo(),
.cuda_driver_version =
system_info_utils::GetDriverAndCudaVersion().second} {};
hw_inf_{
system_info_utils::GetSystemInfo(), //sysinfo
{}, //cpu_info

system_info_utils::GetDriverAndCudaVersion()
.second //cuda_driver_version
} {};

bool Exec(const std::string& engine, const std::string& version = "latest",
const std::string& src = "");
Expand Down
Loading
Loading