Skip to content

Commit 4bc1aa7

Browse files
Feat/config log location for engines (#1356)
* fix/mistral-nemo-chat-template * feat/config-engines-log-path * Fix: use file system path instead of string concat * Fix: CI build window * Fix: CI build window * Fix: CI build windows
1 parent 44d831f commit 4bc1aa7

File tree

4 files changed

+56
-11
lines changed

4 files changed

+56
-11
lines changed

engine/controllers/server.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ void server::LoadModel(const HttpRequestPtr& req,
347347
if (engine_type == kLlamaEngine) { //fix for llamacpp engine first
348348
auto config = file_manager_utils::GetCortexConfig();
349349
if (en->IsSupported("SetFileLogger")) {
350-
en->SetFileLogger(config.maxLogLines, config.logFolderPath + "/" +
351-
cortex_utils::logs_base_name);
350+
en->SetFileLogger(config.maxLogLines, (std::filesystem::path(config.logFolderPath) /
351+
std::filesystem::path(config.logLlamaCppPath)).string());
352352
} else {
353353
LOG_WARN << "Method SetFileLogger is not supported yet";
354354
}

engine/test/components/test_cortex_config.cc

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ class CortexConfigTest : public ::testing::Test {
99

1010
void SetUp() override {
1111
// Set up default configuration
12-
default_config = {
13-
"default_log_path", "default_data_path", 1000,
14-
kDefaultHost, kDefaultPort, kDefaultCheckedForUpdateAt,
15-
kDefaultLatestRelease};
12+
default_config = {"default_log_path",
13+
"default_llamacpp_log_path",
14+
"default_tensorrtllm_log_path",
15+
"default_onnx_log_path",
16+
"default_data_path",
17+
1000,
18+
kDefaultHost,
19+
kDefaultPort,
20+
kDefaultCheckedForUpdateAt,
21+
kDefaultLatestRelease};
1622
}
1723

1824
void TearDown() override {
@@ -24,8 +30,16 @@ class CortexConfigTest : public ::testing::Test {
2430
};
2531

2632
TEST_F(CortexConfigTest, DumpYamlConfig_WritesCorrectly) {
27-
CortexConfig config = {"log_path", "data_path", 5000, "localhost",
28-
"8080", 123456789, "v1.0.0"};
33+
CortexConfig config = {"log_path",
34+
"default_llamacpp_log_path",
35+
"default_tensorrtllm_log_path",
36+
"default_onnx_log_path",
37+
"data_path",
38+
5000,
39+
"localhost",
40+
"8080",
41+
123456789,
42+
"v1.0.0"};
2943

3044
DumpYamlConfig(config, test_file_path);
3145

@@ -43,8 +57,16 @@ TEST_F(CortexConfigTest, DumpYamlConfig_WritesCorrectly) {
4357

4458
TEST_F(CortexConfigTest, FromYaml_ReadsCorrectly) {
4559
// First, create a valid YAML configuration file
46-
CortexConfig config = {"log_path", "data_path", 5000, "localhost",
47-
"8080", 123456789, "v1.0.0"};
60+
CortexConfig config = {"log_path",
61+
"default_llamacpp_log_path",
62+
"default_tensorrtllm_log_path",
63+
"default_onnx_log_path",
64+
"data_path",
65+
5000,
66+
"localhost",
67+
"8080",
68+
123456789,
69+
"v1.0.0"};
4870

4971
DumpYamlConfig(config, test_file_path);
5072

engine/utils/config_yaml_utils.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
namespace config_yaml_utils {
1010
struct CortexConfig {
1111
std::string logFolderPath;
12+
std::string logLlamaCppPath;
13+
std::string logTensorrtLLMPath;
14+
std::string logOnnxPath;
1215
std::string dataFolderPath;
1316
int maxLogLines;
1417
std::string apiServerHost;
@@ -35,6 +38,9 @@ inline void DumpYamlConfig(const CortexConfig& config,
3538
}
3639
YAML::Node node;
3740
node["logFolderPath"] = config.logFolderPath;
41+
node["logLlamaCppPath"] = config.logLlamaCppPath;
42+
node["logTensorrtLLMPath"] = config.logTensorrtLLMPath;
43+
node["logOnnxPath"] = config.logOnnxPath;
3844
node["dataFolderPath"] = config.dataFolderPath;
3945
node["maxLogLines"] = config.maxLogLines;
4046
node["apiServerHost"] = config.apiServerHost;
@@ -63,12 +69,22 @@ inline CortexConfig FromYaml(const std::string& path,
6369
(!node["logFolderPath"] || !node["dataFolderPath"] ||
6470
!node["maxLogLines"] || !node["apiServerHost"] ||
6571
!node["apiServerPort"] || !node["checkedForUpdateAt"] ||
66-
!node["latestRelease"]);
72+
!node["latestRelease"] || !node["logLlamaCppPath"] ||
73+
!node["logOnnxPath"] || !node["logTensorrtLLMPath"]);
6774

6875
CortexConfig config = {
6976
.logFolderPath = node["logFolderPath"]
7077
? node["logFolderPath"].as<std::string>()
7178
: default_cfg.logFolderPath,
79+
.logLlamaCppPath = node["logLlamaCppPath"]
80+
? node["logLlamaCppPath"].as<std::string>()
81+
: default_cfg.logLlamaCppPath,
82+
.logTensorrtLLMPath = node["logTensorrtLLMPath"]
83+
? node["logTensorrtLLMPath"].as<std::string>()
84+
: default_cfg.logTensorrtLLMPath,
85+
.logOnnxPath = node["logOnnxPath"]
86+
? node["logOnnxPath"].as<std::string>()
87+
: default_cfg.logOnnxPath,
7288
.dataFolderPath = node["dataFolderPath"]
7389
? node["dataFolderPath"].as<std::string>()
7490
: default_cfg.dataFolderPath,

engine/utils/file_manager_utils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "services/download_service.h"
77
#include "utils/config_yaml_utils.h"
88

9+
910
#if defined(__APPLE__) && defined(__MACH__)
1011
#include <mach-o/dyld.h>
1112
#elif defined(__linux__)
@@ -20,6 +21,9 @@ constexpr std::string_view kDefaultConfigurationPath = "user_home";
2021
constexpr std::string_view kProdVariant = "prod";
2122
constexpr std::string_view kBetaVariant = "beta";
2223
constexpr std::string_view kNightlyVariant = "nightly";
24+
constexpr char kLogsLlamacppBaseName[] = "./logs/cortex.log";
25+
constexpr char kLogsTensorrtllmBaseName[] = "./logs/cortex.log";
26+
constexpr char kLogsOnnxBaseName[] = "./logs/cortex.log";
2327

2428
inline std::filesystem::path GetExecutableFolderContainerPath() {
2529
#if defined(__APPLE__) && defined(__MACH__)
@@ -156,6 +160,9 @@ inline config_yaml_utils::CortexConfig GetCortexConfig() {
156160
file_manager_utils::GetHomeDirectoryPath() / default_data_folder_name;
157161
auto default_cfg = config_yaml_utils::CortexConfig{
158162
.logFolderPath = default_data_folder_path.string(),
163+
.logLlamaCppPath = kLogsLlamacppBaseName,
164+
.logTensorrtLLMPath = kLogsTensorrtllmBaseName,
165+
.logOnnxPath = kLogsOnnxBaseName,
159166
.dataFolderPath = default_data_folder_path.string(),
160167
.maxLogLines = config_yaml_utils::kDefaultMaxLines,
161168
.apiServerHost = config_yaml_utils::kDefaultHost,

0 commit comments

Comments
 (0)