From 6ef5ca541a2b137c6aab84adf9cbc2772f9b7cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sat, 6 Jan 2024 22:38:34 +0100 Subject: [PATCH] Add app version to command line utils --- config/config.h.in | 2 +- src/BayesNet/CMakeLists.txt | 16 +++++++++------- src/Platform/CMakeLists.txt | 25 ++++++++++++++----------- src/Platform/b_best.cc | 4 ++-- src/Platform/b_grid.cc | 3 ++- src/Platform/b_main.cc | 3 ++- src/Platform/b_manage.cc | 3 ++- src/PyClassifiers/CMakeLists.txt | 13 +++++++------ 8 files changed, 39 insertions(+), 30 deletions(-) diff --git a/config/config.h.in b/config/config.h.in index d95e710..ad83bda 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -7,7 +7,7 @@ #define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR @ #define PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH @ -static constexpr std::string_view project_name = " @PROJECT_NAME@ "; +static constexpr std::string_view project_name = "@PROJECT_NAME@"; static constexpr std::string_view project_version = "@PROJECT_VERSION@"; static constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@"; static constexpr std::string_view git_sha = "@GIT_SHA@"; diff --git a/src/BayesNet/CMakeLists.txt b/src/BayesNet/CMakeLists.txt index c14e625..f4ef172 100644 --- a/src/BayesNet/CMakeLists.txt +++ b/src/BayesNet/CMakeLists.txt @@ -1,10 +1,12 @@ -include_directories(${BayesNet_SOURCE_DIR}/lib/mdlp) -include_directories(${BayesNet_SOURCE_DIR}/lib/Files) -include_directories(${BayesNet_SOURCE_DIR}/lib/json/include) -include_directories(${BayesNet_SOURCE_DIR}/src/BayesNet) -include_directories(${BayesNet_SOURCE_DIR}/src/Platform) -include_directories(${BayesNet_SOURCE_DIR}/src/PyClassifiers) -include_directories(${Python3_INCLUDE_DIRS}) +include_directories( + ${BayesNet_SOURCE_DIR}/lib/mdlp + ${BayesNet_SOURCE_DIR}/lib/Files + ${BayesNet_SOURCE_DIR}/lib/json/include + ${BayesNet_SOURCE_DIR}/src/BayesNet + ${BayesNet_SOURCE_DIR}/src/Platform + ${BayesNet_SOURCE_DIR}/src/PyClassifiers + ${Python3_INCLUDE_DIRS} +) add_library(BayesNet bayesnetUtils.cc Network.cc Node.cc BayesMetrics.cc Classifier.cc KDB.cc TAN.cc SPODE.cc Ensemble.cc AODE.cc TANLd.cc KDBLd.cc SPODELd.cc AODELd.cc BoostAODE.cc diff --git a/src/Platform/CMakeLists.txt b/src/Platform/CMakeLists.txt index e475b16..52336f1 100644 --- a/src/Platform/CMakeLists.txt +++ b/src/Platform/CMakeLists.txt @@ -1,20 +1,23 @@ -include_directories(${BayesNet_SOURCE_DIR}/src/BayesNet) -include_directories(${BayesNet_SOURCE_DIR}/src/Platform) -include_directories(${BayesNet_SOURCE_DIR}/src/PyClassifiers) -include_directories(${BayesNet_SOURCE_DIR}/lib/Files) -include_directories(${BayesNet_SOURCE_DIR}/lib/mdlp) -include_directories(${BayesNet_SOURCE_DIR}/lib/argparse/include) -include_directories(${BayesNet_SOURCE_DIR}/lib/json/include) -include_directories(${BayesNet_SOURCE_DIR}/lib/libxlsxwriter/include) -include_directories(${Python3_INCLUDE_DIRS}) -include_directories(${MPI_CXX_INCLUDE_DIRS}) - add_executable(b_best b_best.cc BestResults.cc Result.cc Statistics.cc BestResultsExcel.cc ReportExcel.cc ReportBase.cc Datasets.cc Dataset.cc ExcelFile.cc) add_executable(b_grid b_grid.cc GridSearch.cc GridData.cc HyperParameters.cc Folding.cc Datasets.cc Dataset.cc) add_executable(b_list b_list.cc Datasets.cc Dataset.cc) add_executable(b_main b_main.cc Folding.cc Experiment.cc Datasets.cc Dataset.cc Models.cc HyperParameters.cc ReportConsole.cc ReportBase.cc) add_executable(b_manage b_manage.cc Results.cc ManageResults.cc CommandParser.cc Result.cc ReportConsole.cc ReportExcel.cc ReportBase.cc Datasets.cc Dataset.cc ExcelFile.cc) +include_directories( + ${BayesNet_SOURCE_DIR}/src/BayesNet + ${BayesNet_SOURCE_DIR}/src/Platform + ${BayesNet_SOURCE_DIR}/src/PyClassifiers + ${BayesNet_SOURCE_DIR}/lib/Files + ${BayesNet_SOURCE_DIR}/lib/mdlp + ${BayesNet_SOURCE_DIR}/lib/argparse/include + ${BayesNet_SOURCE_DIR}/lib/json/include + ${BayesNet_SOURCE_DIR}/lib/libxlsxwriter/include + ${Python3_INCLUDE_DIRS} + ${MPI_CXX_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR}/configured_files/include +) + target_link_libraries(b_best Boost::boost "${XLSXWRITER_LIB}" "${TORCH_LIBRARIES}" ArffFiles mdlp) target_link_libraries(b_grid BayesNet PyWrap ${MPI_CXX_LIBRARIES}) target_link_libraries(b_list ArffFiles mdlp "${TORCH_LIBRARIES}") diff --git a/src/Platform/b_best.cc b/src/Platform/b_best.cc index 4112f4b..f305ae5 100644 --- a/src/Platform/b_best.cc +++ b/src/Platform/b_best.cc @@ -3,7 +3,7 @@ #include "Paths.h" #include "BestResults.h" #include "Colors.h" - +#include "config.h" void manageArguments(argparse::ArgumentParser& program, int argc, char** argv) { @@ -31,7 +31,7 @@ void manageArguments(argparse::ArgumentParser& program, int argc, char** argv) int main(int argc, char** argv) { - argparse::ArgumentParser program("b_sbest"); + argparse::ArgumentParser program("b_best", { project_version.begin(), project_version.end() }); manageArguments(program, argc, argv); std::string model, score; bool build, report, friedman, excel; diff --git a/src/Platform/b_grid.cc b/src/Platform/b_grid.cc index 6e9796d..7a750f8 100644 --- a/src/Platform/b_grid.cc +++ b/src/Platform/b_grid.cc @@ -10,6 +10,7 @@ #include "Paths.h" #include "Timer.h" #include "Colors.h" +#include "config.h" using json = nlohmann::json; const int MAXL = 133; @@ -156,7 +157,7 @@ void list_results(json& results, std::string& model) */ int main(int argc, char** argv) { - argparse::ArgumentParser program("b_grid"); + argparse::ArgumentParser program("b_grid", { project_version.begin(), project_version.end() }); manageArguments(program); struct platform::ConfigGrid config; bool dump, compute; diff --git a/src/Platform/b_main.cc b/src/Platform/b_main.cc index 0dee793..7872239 100644 --- a/src/Platform/b_main.cc +++ b/src/Platform/b_main.cc @@ -7,6 +7,7 @@ #include "Models.h" #include "modelRegister.h" #include "Paths.h" +#include "config.h" using json = nlohmann::json; @@ -53,7 +54,7 @@ void manageArguments(argparse::ArgumentParser& program) int main(int argc, char** argv) { - argparse::ArgumentParser program("b_main"); + argparse::ArgumentParser program("b_main", { project_version.begin(), project_version.end() }); manageArguments(program); std::string file_name, model_name, title, hyperparameters_file; json hyperparameters_json; diff --git a/src/Platform/b_manage.cc b/src/Platform/b_manage.cc index a6e7be2..3b499c6 100644 --- a/src/Platform/b_manage.cc +++ b/src/Platform/b_manage.cc @@ -1,6 +1,7 @@ #include #include #include "ManageResults.h" +#include "config.h" void manageArguments(argparse::ArgumentParser& program, int argc, char** argv) @@ -32,7 +33,7 @@ void manageArguments(argparse::ArgumentParser& program, int argc, char** argv) int main(int argc, char** argv) { - auto program = argparse::ArgumentParser("b_manage"); + auto program = argparse::ArgumentParser("b_manage", { project_version.begin(), project_version.end() }); manageArguments(program, argc, argv); int number = program.get("number"); std::string model = program.get("model"); diff --git a/src/PyClassifiers/CMakeLists.txt b/src/PyClassifiers/CMakeLists.txt index 61af573..63714da 100644 --- a/src/PyClassifiers/CMakeLists.txt +++ b/src/PyClassifiers/CMakeLists.txt @@ -1,9 +1,10 @@ -include_directories(${BayesNet_SOURCE_DIR}/lib/Files) -include_directories(${BayesNet_SOURCE_DIR}/lib/json/include) -include_directories(${BayesNet_SOURCE_DIR}/src/BayesNet) -include_directories(${Python3_INCLUDE_DIRS}) -include_directories(${TORCH_INCLUDE_DIRS}) - +include_directories( + ${BayesNet_SOURCE_DIR}/lib/Files + ${BayesNet_SOURCE_DIR}/lib/json/include + ${BayesNet_SOURCE_DIR}/src/BayesNet + ${Python3_INCLUDE_DIRS} + ${TORCH_INCLUDE_DIRS} +) add_library(PyWrap SHARED PyWrap.cc STree.cc ODTE.cc SVC.cc RandomForest.cc PyClassifier.cc) #target_link_libraries(PyWrap ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::boost Boost::python Boost::numpy xgboost::xgboost ArffFiles) target_link_libraries(PyWrap ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::boost Boost::python Boost::numpy ArffFiles) \ No newline at end of file