From 9177a0731e6e2d1adb9d8e62adaf94b385278b7a Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 26 Apr 2024 16:35:53 +0200 Subject: [PATCH 1/5] Add Reader and Writer tools (for testing) Linkage with ROOT requires some fine tuning of the config.cmake file (in order to include the root headers needed by the future dependencies of hk-DataModel) --- CMakeLists.txt | 7 +++++-- DataModel/DataModel.cpp | 4 ++-- DataModel/DataModel.h | 10 +++++----- ReaderTool/README.md | 1 + ReaderTool/ReaderTool.cpp | 28 ++++++++++++++++++++++++++++ ReaderTool/ReaderTool.h | 36 ++++++++++++++++++++++++++++++++++++ WriterTool/README.md | 1 + WriterTool/WriterTool.cpp | 28 ++++++++++++++++++++++++++++ WriterTool/WriterTool.h | 36 ++++++++++++++++++++++++++++++++++++ dependencies.cmake | 1 + hk-DataModelConfig.cmake.in | 15 +++++++++++++++ hkinstall.py | 6 ++++++ 12 files changed, 164 insertions(+), 9 deletions(-) create mode 100644 ReaderTool/README.md create mode 100644 ReaderTool/ReaderTool.cpp create mode 100644 ReaderTool/ReaderTool.h create mode 100644 WriterTool/README.md create mode 100644 WriterTool/WriterTool.cpp create mode 100644 WriterTool/WriterTool.h create mode 100644 hk-DataModelConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index a5c7a68..c448d26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,11 +12,14 @@ MESSAGE("Preparing project ${PROJECT_NAME} version ${PROJECT_VERSION}" ) project(${PROJECT_NAME} VERSION ${PROJECT_VERSION}) include(HKPackageBuilder) hkbuilder_prepare_project() -set( PUBLIC_EXT_LIBS ) hk_check_dependencies() add_subdirectory(DataModel) set(hk-DataModel_LIBRARIES hk-DataModel::DataModel) -hk_finalize_project() \ No newline at end of file +include_directories(DataModel BEFORE) +hk_add_tool(ReaderTool DataModel) +hk_add_tool(WriterTool DataModel) + +hk_finalize_project() diff --git a/DataModel/DataModel.cpp b/DataModel/DataModel.cpp index 8f6138c..9b54227 100644 --- a/DataModel/DataModel.cpp +++ b/DataModel/DataModel.cpp @@ -4,7 +4,7 @@ DataModel::DataModel() { Log = 0; } -/* + TTree* DataModel::GetTTree(std::string name){ return m_trees[name]; @@ -25,4 +25,4 @@ void DataModel::DeleteTTree(std::string name,TTree *tree){ } -*/ + diff --git a/DataModel/DataModel.h b/DataModel/DataModel.h index 6a3471f..1e0f7a5 100644 --- a/DataModel/DataModel.h +++ b/DataModel/DataModel.h @@ -6,7 +6,7 @@ #include #include "Utilities.h" -// #include "TTree.h" +#include "TTree.h" #include "BStore.h" #include "Logging.h" @@ -31,9 +31,9 @@ class DataModel { DataModel(); ///< Simple constructor - // TTree* GetTTree(std::string name); - // void AddTTree(std::string name,TTree *tree); - // void DeleteTTree(std::string name,TTree *tree); + TTree* GetTTree(std::string name); + void AddTTree(std::string name,TTree *tree); + void DeleteTTree(std::string name,TTree *tree); Logging* Log; ///< Log class pointer for use in Tools, it can be used to send messages which can have ///< multiple error levels and destination end points @@ -50,7 +50,7 @@ class DataModel { private: - // std::map m_trees; + std::map m_trees; }; #endif diff --git a/ReaderTool/README.md b/ReaderTool/README.md new file mode 100644 index 0000000..23a43b1 --- /dev/null +++ b/ReaderTool/README.md @@ -0,0 +1 @@ +# ReaderTool diff --git a/ReaderTool/ReaderTool.cpp b/ReaderTool/ReaderTool.cpp new file mode 100644 index 0000000..10c4fa9 --- /dev/null +++ b/ReaderTool/ReaderTool.cpp @@ -0,0 +1,28 @@ +#include "ReaderTool.h" + +ReaderTool::ReaderTool() : Tool() {} + +bool ReaderTool::Initialise(std::string configfile, DataModel& data) { + + if(configfile != "") + m_variables.Initialise(configfile); + // m_variables.Print(); + + m_data = &data; + m_log = m_data->Log; + + if(!m_variables.Get("verbose", m_verbose)) + m_verbose = 1; + + return true; +} + +bool ReaderTool::Execute() { + + return true; +} + +bool ReaderTool::Finalise() { + + return true; +} diff --git a/ReaderTool/ReaderTool.h b/ReaderTool/ReaderTool.h new file mode 100644 index 0000000..9fd4887 --- /dev/null +++ b/ReaderTool/ReaderTool.h @@ -0,0 +1,36 @@ +#ifndef ReaderTool_H +#define ReaderTool_H + +#include +#include + +#include "DataModel.h" +#include "Tool.h" + +/** + * \class ReaderTool + * + * This is a blank template for a Tool used by the script to generate a new custom tool. Please fill out the + * description and author information. + * + * $Author: B.Richards $ + * $Date: 2019/05/28 10:44:00 $ + */ + +class ReaderTool : public Tool { + + public: + + ReaderTool(); ///< Simple constructor + bool Initialise(std::string configfile, + DataModel& data); ///< Initialise Function for setting up Tool resources. @param + ///< configfile The path and name of the dynamic configuration file + ///< to read in. @param data A reference to the transient data + ///< class used to pass information between Tools. + bool Execute(); ///< Execute function used to perform Tool purpose. + bool Finalise(); ///< Finalise funciton used to clean up resources. + + private: +}; + +#endif diff --git a/WriterTool/README.md b/WriterTool/README.md new file mode 100644 index 0000000..2a2abfc --- /dev/null +++ b/WriterTool/README.md @@ -0,0 +1 @@ +# WriterTool diff --git a/WriterTool/WriterTool.cpp b/WriterTool/WriterTool.cpp new file mode 100644 index 0000000..8a13e69 --- /dev/null +++ b/WriterTool/WriterTool.cpp @@ -0,0 +1,28 @@ +#include "WriterTool.h" + +WriterTool::WriterTool() : Tool() {} + +bool WriterTool::Initialise(std::string configfile, DataModel& data) { + + if(configfile != "") + m_variables.Initialise(configfile); + // m_variables.Print(); + + m_data = &data; + m_log = m_data->Log; + + if(!m_variables.Get("verbose", m_verbose)) + m_verbose = 1; + + return true; +} + +bool WriterTool::Execute() { + + return true; +} + +bool WriterTool::Finalise() { + + return true; +} diff --git a/WriterTool/WriterTool.h b/WriterTool/WriterTool.h new file mode 100644 index 0000000..b8c1ae7 --- /dev/null +++ b/WriterTool/WriterTool.h @@ -0,0 +1,36 @@ +#ifndef WriterTool_H +#define WriterTool_H + +#include +#include + +#include "DataModel.h" +#include "Tool.h" + +/** + * \class WriterTool + * + * This is a blank template for a Tool used by the script to generate a new custom tool. Please fill out the + * description and author information. + * + * $Author: B.Richards $ + * $Date: 2019/05/28 10:44:00 $ + */ + +class WriterTool : public Tool { + + public: + + WriterTool(); ///< Simple constructor + bool Initialise(std::string configfile, + DataModel& data); ///< Initialise Function for setting up Tool resources. @param + ///< configfile The path and name of the dynamic configuration file + ///< to read in. @param data A reference to the transient data + ///< class used to pass information between Tools. + bool Execute(); ///< Execute function used to perform Tool purpose. + bool Finalise(); ///< Finalise funciton used to clean up resources. + + private: +}; + +#endif diff --git a/dependencies.cmake b/dependencies.cmake index 6006ad6..462d5f7 100644 --- a/dependencies.cmake +++ b/dependencies.cmake @@ -1 +1,2 @@ hk_package(ToolFrameworkCore *) +hk_package(ROOT *) \ No newline at end of file diff --git a/hk-DataModelConfig.cmake.in b/hk-DataModelConfig.cmake.in new file mode 100644 index 0000000..b0baea1 --- /dev/null +++ b/hk-DataModelConfig.cmake.in @@ -0,0 +1,15 @@ +get_filename_component( @PROJECT_NAME@_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH ) + +# Taken from the hk-pilot CMake files +# Seems like we will need to past this kind of paragraph for any package that directly depends on ROOT +# Dependencies that depends on packages that depends on ROOT shouldn't have to do this, as long as the dependency has this paragraph +MESSAGE(STATUS "Including ROOT headers: @ROOT_INCLUDE_DIRS@") +include_directories(BEFORE @ROOT_INCLUDE_DIRS@) +# Manual way to set the CXX standard if ROOT uses c++17 standard +# Not very gracious... +set(CMAKE_CXX_STANDARD @CMAKE_CXX_STANDARD@) +MESSAGE(STATUS "Using CXX standard @CMAKE_CXX_STANDARD@ because of ROOT") + +include("${@PROJECT_NAME@_CMAKE_DIR}/@PROJECT_NAME@_Library_Targets.cmake") + +list (APPEND @PROJECT_NAME@_LIBRARIES @PROJECT_LIBS@) \ No newline at end of file diff --git a/hkinstall.py b/hkinstall.py index cf47ff9..9f5119d 100644 --- a/hkinstall.py +++ b/hkinstall.py @@ -6,3 +6,9 @@ class hkDataModel(CMake): def __init__(self, path): super().__init__(path) self._package_name = "hk-DataModel" + + def post_install(self): + # Run standard post_install step + super().post_install() + + return self.link_compiled_tools_dir() From 2232ee92b8c3a50ae42f6301b2c3ea320935dfe9 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 26 Apr 2024 16:37:39 +0200 Subject: [PATCH 2/5] Update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 72e36dd..84163e6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,9 @@ *.so .gitignore +.idea build/ build-* install-* __pycache__ +cmake-* \ No newline at end of file From 430689c18c6d4eedd64a682cd42f4ad760101043 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 26 Apr 2024 16:45:24 +0200 Subject: [PATCH 3/5] Disable Writer tools for now Since we are using the ToolFrameworkCore docker base image, ROOT won't be there yet. Will enable these after the ToolFrameworkCore upgrade --- CMakeLists.txt | 4 ++-- dependencies.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c448d26..fdeb06f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ add_subdirectory(DataModel) set(hk-DataModel_LIBRARIES hk-DataModel::DataModel) include_directories(DataModel BEFORE) -hk_add_tool(ReaderTool DataModel) -hk_add_tool(WriterTool DataModel) +#hk_add_tool(ReaderTool DataModel) +#hk_add_tool(WriterTool DataModel) hk_finalize_project() diff --git a/dependencies.cmake b/dependencies.cmake index 462d5f7..f091858 100644 --- a/dependencies.cmake +++ b/dependencies.cmake @@ -1,2 +1,2 @@ hk_package(ToolFrameworkCore *) -hk_package(ROOT *) \ No newline at end of file +#hk_package(ROOT *) \ No newline at end of file From a8dfaa1567b1c3c98e1f4d99c721a18d8aef9a13 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 26 Apr 2024 17:05:39 +0200 Subject: [PATCH 4/5] Comment TTree --- DataModel/DataModel.cpp | 40 ++++++++++++++++++++-------------------- DataModel/DataModel.h | 10 +++++----- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/DataModel/DataModel.cpp b/DataModel/DataModel.cpp index 9b54227..218bfb9 100644 --- a/DataModel/DataModel.cpp +++ b/DataModel/DataModel.cpp @@ -4,25 +4,25 @@ DataModel::DataModel() { Log = 0; } - -TTree* DataModel::GetTTree(std::string name){ - - return m_trees[name]; - -} - - -void DataModel::AddTTree(std::string name,TTree *tree){ - - m_trees[name]=tree; - -} - - -void DataModel::DeleteTTree(std::string name,TTree *tree){ - - m_trees.erase(name); - -} +// +//TTree* DataModel::GetTTree(std::string name){ +// +// return m_trees[name]; +// +//} +// +// +//void DataModel::AddTTree(std::string name,TTree *tree){ +// +// m_trees[name]=tree; +// +//} +// +// +//void DataModel::DeleteTTree(std::string name,TTree *tree){ +// +// m_trees.erase(name); +// +//} diff --git a/DataModel/DataModel.h b/DataModel/DataModel.h index 1e0f7a5..a975716 100644 --- a/DataModel/DataModel.h +++ b/DataModel/DataModel.h @@ -6,7 +6,7 @@ #include #include "Utilities.h" -#include "TTree.h" +//#include "TTree.h" #include "BStore.h" #include "Logging.h" @@ -31,9 +31,9 @@ class DataModel { DataModel(); ///< Simple constructor - TTree* GetTTree(std::string name); - void AddTTree(std::string name,TTree *tree); - void DeleteTTree(std::string name,TTree *tree); +// TTree* GetTTree(std::string name); +// void AddTTree(std::string name,TTree *tree); +// void DeleteTTree(std::string name,TTree *tree); Logging* Log; ///< Log class pointer for use in Tools, it can be used to send messages which can have ///< multiple error levels and destination end points @@ -50,7 +50,7 @@ class DataModel { private: - std::map m_trees; +// std::map m_trees; }; #endif From 8a7312d651aad7dceef19335021cc75c387f0320 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 26 Apr 2024 17:07:44 +0200 Subject: [PATCH 5/5] Use hk-pilot as docker base image --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 716e11a..20932b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/hyperk/toolframeworkcore:main +FROM ghcr.io/hyperk/hk-pilot:main COPY . /usr/local/hk/hk-DataModel @@ -6,4 +6,4 @@ RUN --mount=type=ssh mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh WORKDIR /usr/local/hk RUN --mount=type=ssh . /usr/local/hk/hk-pilot/setup.sh &&\ - hkp install -r -e hk-DataModel + hkp install -r hk-DataModel