diff --git a/engine/commands/model_upd_cmd.cc b/engine/commands/model_upd_cmd.cc index 0864c227a..3d3e14fea 100644 --- a/engine/commands/model_upd_cmd.cc +++ b/engine/commands/model_upd_cmd.cc @@ -12,7 +12,8 @@ void ModelUpdCmd::Exec( namespace fs = std::filesystem; namespace fmu = file_manager_utils; try { - auto model_entry = model_list_utils_.GetModelInfo(model_handle_); + cortex::db::Models modellist_handler; + auto model_entry = modellist_handler.GetModelInfo(model_handle_); if (model_entry.has_error()) { CLI_LOG("Error: " + model_entry.error()); return; diff --git a/engine/commands/model_upd_cmd.h b/engine/commands/model_upd_cmd.h index 49c104157..384b36288 100644 --- a/engine/commands/model_upd_cmd.h +++ b/engine/commands/model_upd_cmd.h @@ -17,7 +17,6 @@ class ModelUpdCmd { std::string model_handle_; config::ModelConfig model_config_; config::YamlHandler yaml_handler_; - cortex::db::Models model_list_utils_; void UpdateConfig(const std::string& key, const std::string& value); void UpdateVectorField(const std::string& key, const std::string& value); diff --git a/engine/controllers/command_line_parser.cc b/engine/controllers/command_line_parser.cc index ab7e41da5..2ee3157af 100644 --- a/engine/controllers/command_line_parser.cc +++ b/engine/controllers/command_line_parser.cc @@ -56,6 +56,11 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) { app_.add_flag("--verbose", log_verbose, "Verbose logging"); + // Logic is handled in main.cc, just for cli helper command + std::string path; + app_.add_option("--config_file_path", path, "Configuration file path"); + app_.add_option("--data_folder_path", path, "Data folder path"); + // cortex version auto cb = [&](int c) { #ifdef CORTEX_CPP_VERSION diff --git a/engine/database/database.h b/engine/database/database.h index e12b39a1b..27c75e923 100644 --- a/engine/database/database.h +++ b/engine/database/database.h @@ -5,8 +5,6 @@ #include "utils/file_manager_utils.h" namespace cortex::db { -const std::string kDefaultDbPath = - file_manager_utils::GetCortexDataPath().string() + "/cortex.db"; class Database { public: Database(Database const&) = delete; @@ -22,7 +20,8 @@ class Database { private: Database() - : db_(kDefaultDbPath, SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE) {} + : db_(file_manager_utils::GetCortexDataPath().string() + "/cortex.db", + SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE) {} SQLite::Database db_; }; } // namespace cortex::db diff --git a/engine/main.cc b/engine/main.cc index 24ccbaab8..186e64c18 100644 --- a/engine/main.cc +++ b/engine/main.cc @@ -119,6 +119,15 @@ int main(int argc, char* argv[]) { return 1; } + for (int i = 0; i < argc; i++) { + if (strcmp(argv[i], "--config_file_path") == 0) { + file_manager_utils::cortex_config_file_path = argv[i + 1]; + + } else if(strcmp(argv[i], "--data_folder_path") == 0) { + file_manager_utils::cortex_data_folder_path = argv[i + 1]; + } + } + { file_manager_utils::CreateConfigFileIfNotExist(); } // Delete temporary file if it exists diff --git a/engine/utils/file_manager_utils.h b/engine/utils/file_manager_utils.h index 8d452e5f8..47aca20b1 100644 --- a/engine/utils/file_manager_utils.h +++ b/engine/utils/file_manager_utils.h @@ -24,6 +24,10 @@ constexpr char kLogsLlamacppBaseName[] = "./logs/cortex.log"; constexpr char kLogsTensorrtllmBaseName[] = "./logs/cortex.log"; constexpr char kLogsOnnxBaseName[] = "./logs/cortex.log"; +inline std::string cortex_config_file_path; + +inline std::string cortex_data_folder_path; + inline std::filesystem::path GetExecutableFolderContainerPath() { #if defined(__APPLE__) && defined(__MACH__) char buffer[1024]; @@ -88,10 +92,15 @@ inline std::filesystem::path GetConfigurationPath() { #ifndef CORTEX_VARIANT #define CORTEX_VARIANT kProdVariant #endif - std::string config_file_path{CORTEX_CONFIG_FILE_PATH}; + std::string config_file_path; + if (cortex_config_file_path.empty()) { + config_file_path = CORTEX_CONFIG_FILE_PATH; + } else { + config_file_path = cortex_config_file_path; + } if (config_file_path != kDefaultConfigurationPath) { - CTL_INF("Config file path: " + config_file_path); + // CTL_INF("Config file path: " + config_file_path); return std::filesystem::path(config_file_path); } @@ -139,7 +148,11 @@ inline void CreateConfigFileIfNotExist() { CLI_LOG("Config file not found. Creating one at " + config_path.string()); auto defaultDataFolderPath = - file_manager_utils::GetHomeDirectoryPath() / default_data_folder_name; + cortex_data_folder_path.empty() + ? file_manager_utils::GetHomeDirectoryPath() / + default_data_folder_name + : std::filesystem::path(cortex_data_folder_path) / + default_data_folder_name; CLI_LOG("Default data folder path: " + defaultDataFolderPath.string()); auto config = config_yaml_utils::CortexConfig{