From b036988e37050730df1cf40322e3fe9baa816069 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Tue, 22 Oct 2024 15:15:14 +0200 Subject: [PATCH 1/6] [QC-1206] Make the database available to the UserCodeInterface + refactor *Config to extract common part - needed for the CTP Scalers - it required adding the database param to all the *Config.h I decided to extract the common part to a new interface `UserCodeConfig`. # Conflicts: # Framework/src/PostProcessingConfig.cxx --- .../include/QualityControl/AggregatorConfig.h | 9 +---- Framework/include/QualityControl/Check.h | 5 --- .../include/QualityControl/CheckConfig.h | 9 +---- .../include/QualityControl/CheckInterface.h | 8 ---- .../QualityControl/PostProcessingConfig.h | 12 +----- .../include/QualityControl/TaskRunnerConfig.h | 10 +---- .../include/QualityControl/UserCodeConfig.h | 39 +++++++++++++++++++ .../QualityControl/UserCodeInterface.h | 5 ++- Framework/src/Aggregator.cxx | 9 +++-- Framework/src/Check.cxx | 8 +++- Framework/src/CheckRunner.cxx | 1 - Framework/src/PostProcessingConfig.cxx | 16 +++++--- Framework/src/PostProcessingFactory.cxx | 1 + Framework/src/PostProcessingRunner.cxx | 2 +- Framework/src/TaskRunner.cxx | 2 + Framework/src/TaskRunnerFactory.cxx | 15 +++---- Framework/src/TriggerHelpers.cxx | 6 +-- Framework/src/UserCodeInterface.cxx | 24 +++++++++++- Framework/test/testCheck.cxx | 10 +++-- Framework/test/testCheckWorkflow.cxx | 4 +- Framework/test/testTaskInterface.cxx | 9 ++++- Framework/test/testTriggerHelpers.cxx | 4 +- 22 files changed, 129 insertions(+), 79 deletions(-) create mode 100644 Framework/include/QualityControl/UserCodeConfig.h diff --git a/Framework/include/QualityControl/AggregatorConfig.h b/Framework/include/QualityControl/AggregatorConfig.h index 2ec3c56b66..83230948bc 100644 --- a/Framework/include/QualityControl/AggregatorConfig.h +++ b/Framework/include/QualityControl/AggregatorConfig.h @@ -24,25 +24,20 @@ #include #include "QualityControl/UpdatePolicyType.h" #include "QualityControl/AggregatorSource.h" -#include "QualityControl/CustomParameters.h" +#include "QualityControl/UserCodeConfig.h" namespace o2::quality_control::checker { /// \brief Container for the configuration of an Aggregator. -struct AggregatorConfig { +struct AggregatorConfig : public o2::quality_control::core::UserCodeConfig { std::string name; - std::string moduleName; - std::string className; - std::string detectorName = "MISC"; // intended to be the 3 letters code; - core::CustomParameters customParameters; UpdatePolicyType policyType = UpdatePolicyType::OnAny; std::vector objectNames{}; // fixme: if object names are empty, allObjects are true, consider reducing to one var // fixme: duplicates "sources" bool allObjects = false; framework::Inputs inputSpecs{}; framework::OutputSpec qoSpec{ "XXX", "INVALID" }; std::vector sources; - std::string conditionUrl{}; }; } // namespace o2::quality_control::checker diff --git a/Framework/include/QualityControl/Check.h b/Framework/include/QualityControl/Check.h index 2d9b969c29..147b45ccd5 100644 --- a/Framework/include/QualityControl/Check.h +++ b/Framework/include/QualityControl/Check.h @@ -94,11 +94,6 @@ class Check static CheckConfig extractConfig(const core::CommonSpec&, const CheckSpec&); static framework::OutputSpec createOutputSpec(const std::string& detector, const std::string& checkName); - void setDatabase(std::shared_ptr database) - { - mCheckInterface->setDatabase(database); - } - private: void beautify(std::map>& moMap, const core::Quality& quality); diff --git a/Framework/include/QualityControl/CheckConfig.h b/Framework/include/QualityControl/CheckConfig.h index 7524f462d4..1b70dfae77 100644 --- a/Framework/include/QualityControl/CheckConfig.h +++ b/Framework/include/QualityControl/CheckConfig.h @@ -22,25 +22,20 @@ #include #include "QualityControl/UpdatePolicyType.h" -#include "QualityControl/CustomParameters.h" +#include "QualityControl/UserCodeConfig.h" namespace o2::quality_control::checker { /// \brief Container for the configuration of a Check. -struct CheckConfig { +struct CheckConfig : public o2::quality_control::core::UserCodeConfig { std::string name; - std::string moduleName; - std::string className; - std::string detectorName = "MISC"; // intended to be the 3 letters code; - core::CustomParameters customParameters; UpdatePolicyType policyType = UpdatePolicyType::OnAny; std::vector objectNames{}; // fixme: if object names are empty, allObjects are true, consider reducing to one var bool allObjects = false; bool allowBeautify = false; framework::Inputs inputSpecs{}; framework::OutputSpec qoSpec{ "XXX", "INVALID" }; - std::string conditionUrl{}; }; } // namespace o2::quality_control::checker diff --git a/Framework/include/QualityControl/CheckInterface.h b/Framework/include/QualityControl/CheckInterface.h index b1bb206167..ce19d1ff97 100644 --- a/Framework/include/QualityControl/CheckInterface.h +++ b/Framework/include/QualityControl/CheckInterface.h @@ -83,11 +83,6 @@ class CheckInterface : public core::UserCodeInterface virtual void startOfActivity(const core::Activity& activity); // not fully abstract because we don't want to change all the existing subclasses virtual void endOfActivity(const core::Activity& activity); // not fully abstract because we don't want to change all the existing subclasses - void setDatabase(std::shared_ptr database) - { - mDatabase = database; - } - protected: /// \brief Called each time mCustomParameters is updated. virtual void configure() override; @@ -100,9 +95,6 @@ class CheckInterface : public core::UserCodeInterface /// \return std::shared_ptr retrieveReference(std::string path, Activity referenceActivity); - private: - std::shared_ptr mDatabase; - ClassDef(CheckInterface, 6) }; diff --git a/Framework/include/QualityControl/PostProcessingConfig.h b/Framework/include/QualityControl/PostProcessingConfig.h index b1532fa68b..88a13d2e62 100644 --- a/Framework/include/QualityControl/PostProcessingConfig.h +++ b/Framework/include/QualityControl/PostProcessingConfig.h @@ -17,12 +17,11 @@ #ifndef QUALITYCONTROL_POSTPROCESSINGCONFIG_H #define QUALITYCONTROL_POSTPROCESSINGCONFIG_H -#include "QualityControl/CustomParameters.h" - #include #include #include #include "QualityControl/Activity.h" +#include "QualityControl/UserCodeConfig.h" namespace o2::quality_control::postprocessing { @@ -30,27 +29,20 @@ namespace o2::quality_control::postprocessing // todo pretty print /// \brief Post-processing configuration structure -struct PostProcessingConfig { +struct PostProcessingConfig : public o2::quality_control::core::UserCodeConfig { PostProcessingConfig() = default; PostProcessingConfig(const std::string& id, const boost::property_tree::ptree& config); ~PostProcessingConfig() = default; std::string id; std::string taskName; - std::string moduleName; - std::string className; - std::string detectorName = "MISC"; std::vector initTriggers = {}; std::vector updateTriggers = {}; std::vector stopTriggers = {}; - std::string qcdbUrl; - std::string ccdbUrl; - std::string consulUrl; std::string kafkaBrokersUrl; std::string kafkaTopic; core::Activity activity; bool matchAnyRunNumber = false; bool critical; - core::CustomParameters customParameters; }; } // namespace o2::quality_control::postprocessing diff --git a/Framework/include/QualityControl/TaskRunnerConfig.h b/Framework/include/QualityControl/TaskRunnerConfig.h index 3411cefb3a..eefb5f88d2 100644 --- a/Framework/include/QualityControl/TaskRunnerConfig.h +++ b/Framework/include/QualityControl/TaskRunnerConfig.h @@ -24,7 +24,7 @@ #include #include "QualityControl/Activity.h" #include "QualityControl/LogDiscardParameters.h" -#include "QualityControl/CustomParameters.h" +#include "QualityControl/UserCodeConfig.h" namespace o2::base { @@ -40,23 +40,17 @@ namespace o2::quality_control::core { /// \brief Container for the configuration of a Task -struct TaskRunnerConfig { +struct TaskRunnerConfig : public UserCodeConfig { std::string deviceName; std::string taskName; - std::string moduleName; - std::string className; std::vector> cycleDurations = {}; int maxNumberCycles; bool critical; - std::string consulUrl{}; - std::string conditionUrl{}; std::string monitoringUrl{}; std::string bookkeepingUrl{}; framework::Inputs inputSpecs{}; framework::OutputSpec moSpec{ "XXX", "INVALID" }; framework::Options options{}; - CustomParameters customParameters; - std::string detectorName = "MISC"; // intended to be the 3 letters code int parallelTaskID = 0; // ID to differentiate parallel local Tasks from one another. 0 means this is the only one. std::string saveToFile{}; int resetAfterCycles = 0; diff --git a/Framework/include/QualityControl/UserCodeConfig.h b/Framework/include/QualityControl/UserCodeConfig.h new file mode 100644 index 0000000000..b829dd53e2 --- /dev/null +++ b/Framework/include/QualityControl/UserCodeConfig.h @@ -0,0 +1,39 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// +/// \file UserCodeConfig.h +/// \author Barthelemy von Haller +/// + +#ifndef QUALITYCONTROL_USERCODECONFIG_H +#define QUALITYCONTROL_USERCODECONFIG_H + +#include "QualityControl/CustomParameters.h" +#include "QualityControl/stringUtils.h" + +namespace o2::quality_control::core +{ + +/// \brief Container for the configuration of a Task +struct UserCodeConfig { + std::string moduleName; + std::string className; + std::string detectorName = "MISC"; // intended to be the 3 letters code; + std::string consulUrl; + CustomParameters customParameters; + std::string conditionUrl{}; + std::unordered_map database; +}; + +} // namespace o2::quality_control::core + +#endif // QUALITYCONTROL_USERCODECONFIG_H diff --git a/Framework/include/QualityControl/UserCodeInterface.h b/Framework/include/QualityControl/UserCodeInterface.h index 42dacb5c04..8cd26dd310 100644 --- a/Framework/include/QualityControl/UserCodeInterface.h +++ b/Framework/include/QualityControl/UserCodeInterface.h @@ -23,6 +23,7 @@ #include "QualityControl/ConditionAccess.h" #include "QualityControl/CustomParameters.h" +#include "QualityControl/DatabaseInterface.h" namespace o2::quality_control::core { @@ -48,12 +49,14 @@ class UserCodeInterface : public ConditionAccess const std::string& getName() const; void setName(const std::string& name); + void setDatabase(std::unordered_map dbConfig); protected: CustomParameters mCustomParameters; std::string mName; + std::shared_ptr mDatabase; - ClassDef(UserCodeInterface, 3) + ClassDef(UserCodeInterface, 4) }; } // namespace o2::quality_control::core diff --git a/Framework/src/Aggregator.cxx b/Framework/src/Aggregator.cxx index c5269c00cb..5c0c25ce7d 100644 --- a/Framework/src/Aggregator.cxx +++ b/Framework/src/Aggregator.cxx @@ -52,6 +52,7 @@ void Aggregator::init() mAggregatorInterface->setName(mAggregatorConfig.name); mAggregatorInterface->setCustomParameters(mAggregatorConfig.customParameters); mAggregatorInterface->setCcdbUrl(mAggregatorConfig.conditionUrl); + mAggregatorInterface->setDatabase(mAggregatorConfig.database); mAggregatorInterface->configure(); } catch (...) { std::string diagnostic = boost::current_exception_diagnostic_information(); @@ -217,18 +218,20 @@ AggregatorConfig Aggregator::extractConfig(const core::CommonSpec& commonSpec, c } return { - aggregatorSpec.aggregatorName, aggregatorSpec.moduleName, aggregatorSpec.className, aggregatorSpec.detectorName, + commonSpec.consulUrl, aggregatorSpec.customParameters, + commonSpec.conditionDBUrl, + commonSpec.database, + aggregatorSpec.aggregatorName, updatePolicy, std::move(objectNames), checkAllObjects, std::move(inputs), createOutputSpec(aggregatorSpec.detectorName, aggregatorSpec.aggregatorName), - sources, - commonSpec.conditionDBUrl + sources }; } diff --git a/Framework/src/Check.cxx b/Framework/src/Check.cxx index 9b232deae1..042d5a1609 100644 --- a/Framework/src/Check.cxx +++ b/Framework/src/Check.cxx @@ -28,6 +28,7 @@ #include "QualityControl/QcInfoLogger.h" #include "QualityControl/Quality.h" #include "QualityControl/HashDataDescription.h" +#include "QualityControl/runnerUtils.h" #include @@ -70,6 +71,7 @@ void Check::init() try { mCheckInterface = root_class_factory::create(mCheckConfig.moduleName, mCheckConfig.className); mCheckInterface->setName(mCheckConfig.name); + mCheckInterface->setDatabase(mCheckConfig.database); mCheckInterface->setCustomParameters(mCheckConfig.customParameters); mCheckInterface->setCcdbUrl(mCheckConfig.conditionUrl); } catch (...) { @@ -250,18 +252,20 @@ CheckConfig Check::extractConfig(const CommonSpec& commonSpec, const CheckSpec& } return { - checkSpec.checkName, checkSpec.moduleName, checkSpec.className, checkSpec.detectorName, + commonSpec.consulUrl, checkSpec.customParameters, + commonSpec.conditionDBUrl, + commonSpec.database, + checkSpec.checkName, updatePolicy, std::move(objectNames), checkAllObjects, allowBeautify, std::move(inputs), createOutputSpec(checkSpec.detectorName, checkSpec.checkName), - commonSpec.conditionDBUrl }; } diff --git a/Framework/src/CheckRunner.cxx b/Framework/src/CheckRunner.cxx index ac96a12a65..b677294e5e 100644 --- a/Framework/src/CheckRunner.cxx +++ b/Framework/src/CheckRunner.cxx @@ -190,7 +190,6 @@ void CheckRunner::init(framework::InitContext& iCtx) updatePolicyManager.reset(); for (auto& [checkName, check] : mChecks) { check.init(); - check.setDatabase(mDatabase); updatePolicyManager.addPolicy(check.getName(), check.getUpdatePolicyType(), check.getObjectsNames(), check.getAllObjectsOption(), false); } } catch (...) { diff --git a/Framework/src/PostProcessingConfig.cxx b/Framework/src/PostProcessingConfig.cxx index 197507f11f..77157a09c8 100644 --- a/Framework/src/PostProcessingConfig.cxx +++ b/Framework/src/PostProcessingConfig.cxx @@ -24,11 +24,6 @@ namespace o2::quality_control::postprocessing PostProcessingConfig::PostProcessingConfig(const std::string& id, const boost::property_tree::ptree& config) // : id(id), taskName(config.get("qc.postprocessing." + id + ".taskName", id)), - moduleName(config.get("qc.postprocessing." + id + ".moduleName")), - className(config.get("qc.postprocessing." + id + ".className")), - detectorName(config.get("qc.postprocessing." + id + ".detectorName", "MISC")), - ccdbUrl(config.get("qc.config.conditionDB.url", "")), - consulUrl(config.get("qc.config.consul.url", "")), activity(config.get("qc.config.Activity.number", 0), config.get("qc.config.Activity.type", "NONE"), config.get("qc.config.Activity.periodName", ""), @@ -39,6 +34,17 @@ PostProcessingConfig::PostProcessingConfig(const std::string& id, const boost::p matchAnyRunNumber(config.get("qc.config.postprocessing.matchAnyRunNumber", false)), critical(true) { + moduleName = config.get("qc.postprocessing." + id + ".moduleName"); + className = config.get("qc.postprocessing." + id + ".className"); + detectorName = config.get("qc.postprocessing." + id + ".detectorName", "MISC"); + consulUrl = config.get("qc.config.consul.url", ""); + conditionUrl = config.get("qc.config.conditionDB.url", ""); + std::unordered_map dbConfig { + {"implementation", config.get("qc.config.database.implementation")}, + {"host", config.get("qc.config.database.host")} + }; + database = dbConfig; + // if available, use the source repo as defined in the postprocessing task, otherwise the general QCDB auto sourceRepo = config.get_child_optional("qc.postprocessing." + id + ".sourceRepo"); auto databasePath = sourceRepo ? "qc.postprocessing." + id + ".sourceRepo" : "qc.config.database"; diff --git a/Framework/src/PostProcessingFactory.cxx b/Framework/src/PostProcessingFactory.cxx index 600e6cc10a..dbe1f376fd 100644 --- a/Framework/src/PostProcessingFactory.cxx +++ b/Framework/src/PostProcessingFactory.cxx @@ -29,6 +29,7 @@ PostProcessingInterface* PostProcessingFactory::create(const PostProcessingConfi { auto* result = root_class_factory::create(config.moduleName, config.className); result->setCustomParameters(config.customParameters); + result->setDatabase(config.database); return result; } diff --git a/Framework/src/PostProcessingRunner.cxx b/Framework/src/PostProcessingRunner.cxx index b2a7636c82..4a192c0802 100644 --- a/Framework/src/PostProcessingRunner.cxx +++ b/Framework/src/PostProcessingRunner.cxx @@ -114,7 +114,7 @@ void PostProcessingRunner::init(const PostProcessingRunnerConfig& runnerConfig, mTask->setID(mTaskConfig.id); mTask->setName(mTaskConfig.taskName); mTask->setCustomParameters(mTaskConfig.customParameters); - mTask->setCcdbUrl(mTaskConfig.ccdbUrl); + mTask->setCcdbUrl(mTaskConfig.conditionUrl); mTask->configure(mRunnerConfig.configTree); } else { throw std::runtime_error("Failed to create the task '" + mTaskConfig.taskName + "' (det " + mTaskConfig.detectorName + ")"); diff --git a/Framework/src/TaskRunner.cxx b/Framework/src/TaskRunner.cxx index ef7f108383..45ce878953 100644 --- a/Framework/src/TaskRunner.cxx +++ b/Framework/src/TaskRunner.cxx @@ -49,6 +49,7 @@ #include "QualityControl/ActivityHelpers.h" #include "QualityControl/WorkflowType.h" #include "QualityControl/HashDataDescription.h" +#include "QualityControl/runnerUtils.h" #include #include @@ -122,6 +123,7 @@ void TaskRunner::init(InitContext& iCtx) mTask.reset(TaskFactory::create(mTaskConfig, mObjectsManager)); mTask->setMonitoring(mCollector); mTask->setGlobalTrackingDataRequest(mTaskConfig.globalTrackingDataRequest); + mTask->setDatabase(mTaskConfig.database); // load config params if (!ConfigParamGlo::keyValues.empty()) { diff --git a/Framework/src/TaskRunnerFactory.cxx b/Framework/src/TaskRunnerFactory.cxx index b562e0ab39..654dcb1bae 100644 --- a/Framework/src/TaskRunnerFactory.cxx +++ b/Framework/src/TaskRunnerFactory.cxx @@ -168,22 +168,23 @@ TaskRunnerConfig TaskRunnerFactory::extractConfig(const CommonSpec& globalConfig o2::globaltracking::RecoContainer rd; return { - deviceName, - taskSpec.taskName, taskSpec.moduleName, taskSpec.className, + InfrastructureSpecReader::validateDetectorName(taskSpec.detectorName), + globalConfig.consulUrl, + taskSpec.customParameters, + globalConfig.conditionDBUrl, + globalConfig.database, + deviceName, + taskSpec.taskName, multipleCycleDurations, taskSpec.maxNumberCycles, taskSpec.critical, - globalConfig.consulUrl, - globalConfig.conditionDBUrl, globalConfig.monitoringUrl, globalConfig.bookkeepingUrl, inputs, monitorObjectsSpec, options, - taskSpec.customParameters, - InfrastructureSpecReader::validateDetectorName(taskSpec.detectorName), parallelTaskID, taskSpec.saveObjectsToFile, resetAfterCycles.value_or(taskSpec.resetAfterCycles), @@ -192,7 +193,7 @@ TaskRunnerConfig TaskRunnerFactory::extractConfig(const CommonSpec& globalConfig grpGeomRequest, globalTrackingDataRequest, taskSpec.movingWindows, - taskSpec.disableLastCycle + taskSpec.disableLastCycle, }; } diff --git a/Framework/src/TriggerHelpers.cxx b/Framework/src/TriggerHelpers.cxx index 22cd309c80..d1c4f14df2 100644 --- a/Framework/src/TriggerHelpers.cxx +++ b/Framework/src/TriggerHelpers.cxx @@ -104,15 +104,15 @@ TriggerFcn triggerFactory(const std::string& trigger, const PostProcessingConfig return triggers::EndOfFill(activity); } else if (triggerLowerCase.find("newobject") != std::string::npos) { const auto [db, objectPath] = parseDbTriggers(trigger, "newobject"); - const std::string& dbUrl = db == "qcdb" ? config.qcdbUrl : config.ccdbUrl; + const std::string& dbUrl = db == "qcdb" ? config.database.at("host") : config.conditionUrl; return triggers::NewObject(dbUrl, db, objectPath, activity, trigger); } else if (triggerLowerCase.find("foreachobject") != std::string::npos) { const auto [db, objectPath] = parseDbTriggers(trigger, "foreachobject"); - const std::string& dbUrl = db == "qcdb" ? config.qcdbUrl : config.ccdbUrl; + const std::string& dbUrl = db == "qcdb" ? config.database.at("host") : config.conditionUrl; return triggers::ForEachObject(dbUrl, db, objectPath, activity, trigger); } else if (triggerLowerCase.find("foreachlatest") != std::string::npos) { const auto [db, objectPath] = parseDbTriggers(trigger, "foreachlatest"); - const std::string& dbUrl = db == "qcdb" ? config.qcdbUrl : config.ccdbUrl; + const std::string& dbUrl = db == "qcdb" ? config.database.at("host") : config.conditionUrl; return triggers::ForEachLatest(dbUrl, db, objectPath, activity, trigger); } else if (auto seconds = string2Seconds(triggerLowerCase); seconds.has_value()) { if (seconds.value() < 0) { diff --git a/Framework/src/UserCodeInterface.cxx b/Framework/src/UserCodeInterface.cxx index 977a13f53c..565716ab2a 100644 --- a/Framework/src/UserCodeInterface.cxx +++ b/Framework/src/UserCodeInterface.cxx @@ -15,8 +15,12 @@ /// #include "QualityControl/UserCodeInterface.h" +#include +#include "QualityControl/QcInfoLogger.h" +#include "QualityControl/DatabaseFactory.h" using namespace o2::ccdb; +using namespace std; namespace o2::quality_control::core { @@ -27,8 +31,24 @@ void UserCodeInterface::setCustomParameters(const CustomParameters& parameters) configure(); } -const std::string& UserCodeInterface::getName() const { return mName; } +const std::string& UserCodeInterface::getName() const { + return mName; +} + +void UserCodeInterface::setName(const std::string& name) { + mName = name; +} -void UserCodeInterface::setName(const std::string& name) { mName = name; } +void UserCodeInterface::setDatabase(std::unordered_map dbConfig) +{ + if(dbConfig.count("implementation") == 0 || dbConfig.count("host") == 0) { + ILOG(Error, Devel) << "dbConfig is incomplete, we don't build the user code database instance" << ENDM; + throw std::invalid_argument("Cannot set database in UserCodeInterface"); + } + + mDatabase = repository::DatabaseFactory::create(dbConfig.at("implementation")); + mDatabase->connect(dbConfig); + ILOG(Debug, Devel) << "Database that is going to be used > Implementation : " << dbConfig.at("implementation") << " / Host : " << dbConfig.at("host") << ENDM; +} } // namespace o2::quality_control::core \ No newline at end of file diff --git a/Framework/test/testCheck.cxx b/Framework/test/testCheck.cxx index 806fca9f7d..3fe74db26d 100644 --- a/Framework/test/testCheck.cxx +++ b/Framework/test/testCheck.cxx @@ -144,14 +144,18 @@ TEST_CASE("test_check_postprocessing") TEST_CASE("test_check_activity") { - Check check({ "test", - "QcSkeleton", + Check check({ "QcSkeleton", "o2::quality_control_modules::skeleton::SkeletonCheck", "TST", + "", {}, + "", + {}, + "test", UpdatePolicyType::OnAny, {}, - true }); + true } + ); std::map> moMap{ { "abcTask/test1", dummyMO("test1") }, diff --git a/Framework/test/testCheckWorkflow.cxx b/Framework/test/testCheckWorkflow.cxx index 03ea526ca1..8a769cbc27 100644 --- a/Framework/test/testCheckWorkflow.cxx +++ b/Framework/test/testCheckWorkflow.cxx @@ -62,7 +62,7 @@ using namespace o2::configuration; * It is expected to terminate as soon as all task publish for the first time. */ -class Receiver : public framework::Task +class Receiver : public o2::framework::Task { public: Receiver(std::string configurationSource) @@ -78,7 +78,7 @@ class Receiver : public framework::Task ~Receiver() override{}; /// \brief Receiver process callback - void run(framework::ProcessingContext& pctx) override + void run(o2::framework::ProcessingContext& pctx) override { std::vector namesToErase; diff --git a/Framework/test/testTaskInterface.cxx b/Framework/test/testTaskInterface.cxx index 77cbc1de19..7b93b3ad21 100644 --- a/Framework/test/testTaskInterface.cxx +++ b/Framework/test/testTaskInterface.cxx @@ -167,10 +167,15 @@ TEST_CASE("test_invoke_all_TaskRunnerConfig_methods") TEST_CASE("test_task_factory") { TaskRunnerConfig config{ - "SkeletonTaskRunner", - "skeletonTask", "QcSkeleton", "o2::quality_control_modules::skeleton::SkeletonTask", + "TST", + "", + {}, + "", + {}, + "SkeletonTaskRunner", + "skeletonTask", { { 10, 1 } }, -1, true, diff --git a/Framework/test/testTriggerHelpers.cxx b/Framework/test/testTriggerHelpers.cxx index a8552eca0c..7d21eba536 100644 --- a/Framework/test/testTriggerHelpers.cxx +++ b/Framework/test/testTriggerHelpers.cxx @@ -63,8 +63,8 @@ TEST_CASE("test_factory") // generating new object trigger PostProcessingConfig configWithDBs; - configWithDBs.qcdbUrl = CCDB_ENDPOINT; - configWithDBs.ccdbUrl = CCDB_ENDPOINT; + configWithDBs.database["host"] = CCDB_ENDPOINT; + configWithDBs.conditionUrl = CCDB_ENDPOINT; CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:qcdb:qc/asdf/vcxz", configWithDBs)); CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:ccdb:qc/asdf/vcxz", configWithDBs)); CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:QCDB:qc/asdf/vcxz", configWithDBs)); From f35201ebc4e93cd2cb21138b420e29a387dc288d Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Tue, 22 Oct 2024 15:18:58 +0200 Subject: [PATCH 2/6] Format --- Framework/src/PostProcessingConfig.cxx | 6 +++--- Framework/src/UserCodeInterface.cxx | 8 +++++--- Framework/test/testCheck.cxx | 5 ++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Framework/src/PostProcessingConfig.cxx b/Framework/src/PostProcessingConfig.cxx index 77157a09c8..6c5b646061 100644 --- a/Framework/src/PostProcessingConfig.cxx +++ b/Framework/src/PostProcessingConfig.cxx @@ -39,9 +39,9 @@ PostProcessingConfig::PostProcessingConfig(const std::string& id, const boost::p detectorName = config.get("qc.postprocessing." + id + ".detectorName", "MISC"); consulUrl = config.get("qc.config.consul.url", ""); conditionUrl = config.get("qc.config.conditionDB.url", ""); - std::unordered_map dbConfig { - {"implementation", config.get("qc.config.database.implementation")}, - {"host", config.get("qc.config.database.host")} + std::unordered_map dbConfig{ + { "implementation", config.get("qc.config.database.implementation") }, + { "host", config.get("qc.config.database.host") } }; database = dbConfig; diff --git a/Framework/src/UserCodeInterface.cxx b/Framework/src/UserCodeInterface.cxx index 565716ab2a..96ee5bcdb3 100644 --- a/Framework/src/UserCodeInterface.cxx +++ b/Framework/src/UserCodeInterface.cxx @@ -31,17 +31,19 @@ void UserCodeInterface::setCustomParameters(const CustomParameters& parameters) configure(); } -const std::string& UserCodeInterface::getName() const { +const std::string& UserCodeInterface::getName() const +{ return mName; } -void UserCodeInterface::setName(const std::string& name) { +void UserCodeInterface::setName(const std::string& name) +{ mName = name; } void UserCodeInterface::setDatabase(std::unordered_map dbConfig) { - if(dbConfig.count("implementation") == 0 || dbConfig.count("host") == 0) { + if (dbConfig.count("implementation") == 0 || dbConfig.count("host") == 0) { ILOG(Error, Devel) << "dbConfig is incomplete, we don't build the user code database instance" << ENDM; throw std::invalid_argument("Cannot set database in UserCodeInterface"); } diff --git a/Framework/test/testCheck.cxx b/Framework/test/testCheck.cxx index 3fe74db26d..a4d336affe 100644 --- a/Framework/test/testCheck.cxx +++ b/Framework/test/testCheck.cxx @@ -144,7 +144,7 @@ TEST_CASE("test_check_postprocessing") TEST_CASE("test_check_activity") { - Check check({ "QcSkeleton", + Check check({ "QcSkeleton", "o2::quality_control_modules::skeleton::SkeletonCheck", "TST", "", @@ -154,8 +154,7 @@ TEST_CASE("test_check_activity") "test", UpdatePolicyType::OnAny, {}, - true } - ); + true }); std::map> moMap{ { "abcTask/test1", dummyMO("test1") }, From 36915d174dd91572cbc6c594e9ec271d488103a6 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Wed, 12 Mar 2025 14:23:51 +0100 Subject: [PATCH 3/6] merge --- Framework/include/QualityControl/UserCodeConfig.h | 4 ++-- Framework/src/Aggregator.cxx | 4 ++-- Framework/src/Check.cxx | 4 ++-- Framework/src/PostProcessingConfig.cxx | 15 +++++++-------- Framework/src/PostProcessingFactory.cxx | 2 +- Framework/src/PostProcessingRunner.cxx | 2 +- Framework/src/TaskFactory.cxx | 2 +- Framework/src/TaskRunner.cxx | 2 +- Framework/src/TriggerHelpers.cxx | 6 +++--- Framework/test/testTriggerHelpers.cxx | 4 ++-- 10 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Framework/include/QualityControl/UserCodeConfig.h b/Framework/include/QualityControl/UserCodeConfig.h index b829dd53e2..b57241fdad 100644 --- a/Framework/include/QualityControl/UserCodeConfig.h +++ b/Framework/include/QualityControl/UserCodeConfig.h @@ -30,8 +30,8 @@ struct UserCodeConfig { std::string detectorName = "MISC"; // intended to be the 3 letters code; std::string consulUrl; CustomParameters customParameters; - std::string conditionUrl{}; - std::unordered_map database; + std::string ccdbUrl; + std::unordered_map repository; // we need the full config of the database to build the database in the subclasses }; } // namespace o2::quality_control::core diff --git a/Framework/src/Aggregator.cxx b/Framework/src/Aggregator.cxx index 5c0c25ce7d..ac76398dfd 100644 --- a/Framework/src/Aggregator.cxx +++ b/Framework/src/Aggregator.cxx @@ -51,8 +51,8 @@ void Aggregator::init() root_class_factory::create(mAggregatorConfig.moduleName, mAggregatorConfig.className); mAggregatorInterface->setName(mAggregatorConfig.name); mAggregatorInterface->setCustomParameters(mAggregatorConfig.customParameters); - mAggregatorInterface->setCcdbUrl(mAggregatorConfig.conditionUrl); - mAggregatorInterface->setDatabase(mAggregatorConfig.database); + mAggregatorInterface->setCcdbUrl(mAggregatorConfig.ccdbUrl); + mAggregatorInterface->setDatabase(mAggregatorConfig.repository); mAggregatorInterface->configure(); } catch (...) { std::string diagnostic = boost::current_exception_diagnostic_information(); diff --git a/Framework/src/Check.cxx b/Framework/src/Check.cxx index 042d5a1609..1e07661c0e 100644 --- a/Framework/src/Check.cxx +++ b/Framework/src/Check.cxx @@ -71,9 +71,9 @@ void Check::init() try { mCheckInterface = root_class_factory::create(mCheckConfig.moduleName, mCheckConfig.className); mCheckInterface->setName(mCheckConfig.name); - mCheckInterface->setDatabase(mCheckConfig.database); + mCheckInterface->setDatabase(mCheckConfig.repository); mCheckInterface->setCustomParameters(mCheckConfig.customParameters); - mCheckInterface->setCcdbUrl(mCheckConfig.conditionUrl); + mCheckInterface->setCcdbUrl(mCheckConfig.ccdbUrl); } catch (...) { std::string diagnostic = boost::current_exception_diagnostic_information(); ILOG(Fatal, Ops) << "Unexpected exception, diagnostic information follows: " diff --git a/Framework/src/PostProcessingConfig.cxx b/Framework/src/PostProcessingConfig.cxx index 6c5b646061..e164ac5f3e 100644 --- a/Framework/src/PostProcessingConfig.cxx +++ b/Framework/src/PostProcessingConfig.cxx @@ -38,17 +38,16 @@ PostProcessingConfig::PostProcessingConfig(const std::string& id, const boost::p className = config.get("qc.postprocessing." + id + ".className"); detectorName = config.get("qc.postprocessing." + id + ".detectorName", "MISC"); consulUrl = config.get("qc.config.consul.url", ""); - conditionUrl = config.get("qc.config.conditionDB.url", ""); - std::unordered_map dbConfig{ - { "implementation", config.get("qc.config.database.implementation") }, - { "host", config.get("qc.config.database.host") } - }; - database = dbConfig; - // if available, use the source repo as defined in the postprocessing task, otherwise the general QCDB auto sourceRepo = config.get_child_optional("qc.postprocessing." + id + ".sourceRepo"); auto databasePath = sourceRepo ? "qc.postprocessing." + id + ".sourceRepo" : "qc.config.database"; - qcdbUrl = config.get(databasePath + ".implementation") == "CCDB" ? config.get(databasePath + ".host") : ""; + auto qcdbUrl = config.get(databasePath + ".implementation") == "CCDB" ? config.get(databasePath + ".host") : ""; + // build the config of the qcdb + std::unordered_map dbConfig{ + { "implementation", config.get("qc.config.database.implementation") }, + { "host", qcdbUrl } + }; + repository = dbConfig; for (const auto& initTrigger : config.get_child("qc.postprocessing." + id + ".initTrigger")) { initTriggers.push_back(initTrigger.second.get_value()); diff --git a/Framework/src/PostProcessingFactory.cxx b/Framework/src/PostProcessingFactory.cxx index dbe1f376fd..7b7e2e9348 100644 --- a/Framework/src/PostProcessingFactory.cxx +++ b/Framework/src/PostProcessingFactory.cxx @@ -29,7 +29,7 @@ PostProcessingInterface* PostProcessingFactory::create(const PostProcessingConfi { auto* result = root_class_factory::create(config.moduleName, config.className); result->setCustomParameters(config.customParameters); - result->setDatabase(config.database); + result->setDatabase(config.repository); return result; } diff --git a/Framework/src/PostProcessingRunner.cxx b/Framework/src/PostProcessingRunner.cxx index 4a192c0802..b2a7636c82 100644 --- a/Framework/src/PostProcessingRunner.cxx +++ b/Framework/src/PostProcessingRunner.cxx @@ -114,7 +114,7 @@ void PostProcessingRunner::init(const PostProcessingRunnerConfig& runnerConfig, mTask->setID(mTaskConfig.id); mTask->setName(mTaskConfig.taskName); mTask->setCustomParameters(mTaskConfig.customParameters); - mTask->setCcdbUrl(mTaskConfig.conditionUrl); + mTask->setCcdbUrl(mTaskConfig.ccdbUrl); mTask->configure(mRunnerConfig.configTree); } else { throw std::runtime_error("Failed to create the task '" + mTaskConfig.taskName + "' (det " + mTaskConfig.detectorName + ")"); diff --git a/Framework/src/TaskFactory.cxx b/Framework/src/TaskFactory.cxx index 899ec0637f..ea77ca5356 100644 --- a/Framework/src/TaskFactory.cxx +++ b/Framework/src/TaskFactory.cxx @@ -27,7 +27,7 @@ TaskInterface* TaskFactory::create(const TaskRunnerConfig& taskConfig, std::shar result->setName(taskConfig.taskName); result->setObjectsManager(objectsManager); result->setCustomParameters(taskConfig.customParameters); - result->setCcdbUrl(taskConfig.conditionUrl); + result->setCcdbUrl(taskConfig.ccdbUrl); return result; } diff --git a/Framework/src/TaskRunner.cxx b/Framework/src/TaskRunner.cxx index 45ce878953..8450c7f580 100644 --- a/Framework/src/TaskRunner.cxx +++ b/Framework/src/TaskRunner.cxx @@ -123,7 +123,7 @@ void TaskRunner::init(InitContext& iCtx) mTask.reset(TaskFactory::create(mTaskConfig, mObjectsManager)); mTask->setMonitoring(mCollector); mTask->setGlobalTrackingDataRequest(mTaskConfig.globalTrackingDataRequest); - mTask->setDatabase(mTaskConfig.database); + mTask->setDatabase(mTaskConfig.repository); // load config params if (!ConfigParamGlo::keyValues.empty()) { diff --git a/Framework/src/TriggerHelpers.cxx b/Framework/src/TriggerHelpers.cxx index d1c4f14df2..42708a9c11 100644 --- a/Framework/src/TriggerHelpers.cxx +++ b/Framework/src/TriggerHelpers.cxx @@ -104,15 +104,15 @@ TriggerFcn triggerFactory(const std::string& trigger, const PostProcessingConfig return triggers::EndOfFill(activity); } else if (triggerLowerCase.find("newobject") != std::string::npos) { const auto [db, objectPath] = parseDbTriggers(trigger, "newobject"); - const std::string& dbUrl = db == "qcdb" ? config.database.at("host") : config.conditionUrl; + const std::string& dbUrl = db == "qcdb" ? config.repository.at("host") : config.ccdbUrl; return triggers::NewObject(dbUrl, db, objectPath, activity, trigger); } else if (triggerLowerCase.find("foreachobject") != std::string::npos) { const auto [db, objectPath] = parseDbTriggers(trigger, "foreachobject"); - const std::string& dbUrl = db == "qcdb" ? config.database.at("host") : config.conditionUrl; + const std::string& dbUrl = db == "qcdb" ? config.repository.at("host") : config.ccdbUrl; return triggers::ForEachObject(dbUrl, db, objectPath, activity, trigger); } else if (triggerLowerCase.find("foreachlatest") != std::string::npos) { const auto [db, objectPath] = parseDbTriggers(trigger, "foreachlatest"); - const std::string& dbUrl = db == "qcdb" ? config.database.at("host") : config.conditionUrl; + const std::string& dbUrl = db == "qcdb" ? config.repository.at("host") : config.ccdbUrl; return triggers::ForEachLatest(dbUrl, db, objectPath, activity, trigger); } else if (auto seconds = string2Seconds(triggerLowerCase); seconds.has_value()) { if (seconds.value() < 0) { diff --git a/Framework/test/testTriggerHelpers.cxx b/Framework/test/testTriggerHelpers.cxx index 7d21eba536..67f3c7a906 100644 --- a/Framework/test/testTriggerHelpers.cxx +++ b/Framework/test/testTriggerHelpers.cxx @@ -63,8 +63,8 @@ TEST_CASE("test_factory") // generating new object trigger PostProcessingConfig configWithDBs; - configWithDBs.database["host"] = CCDB_ENDPOINT; - configWithDBs.conditionUrl = CCDB_ENDPOINT; + configWithDBs.repository["host"] = CCDB_ENDPOINT; + configWithDBs.ccdbUrl = CCDB_ENDPOINT; CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:qcdb:qc/asdf/vcxz", configWithDBs)); CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:ccdb:qc/asdf/vcxz", configWithDBs)); CHECK_NOTHROW(trigger_helpers::triggerFactory("newobject:QCDB:qc/asdf/vcxz", configWithDBs)); From 08d748c6855b1624983a1401642fc8784af66dbe Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Wed, 12 Mar 2025 14:24:30 +0100 Subject: [PATCH 4/6] format --- Framework/src/PostProcessingConfig.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/src/PostProcessingConfig.cxx b/Framework/src/PostProcessingConfig.cxx index e164ac5f3e..086726b24a 100644 --- a/Framework/src/PostProcessingConfig.cxx +++ b/Framework/src/PostProcessingConfig.cxx @@ -44,8 +44,8 @@ PostProcessingConfig::PostProcessingConfig(const std::string& id, const boost::p auto qcdbUrl = config.get(databasePath + ".implementation") == "CCDB" ? config.get(databasePath + ".host") : ""; // build the config of the qcdb std::unordered_map dbConfig{ - { "implementation", config.get("qc.config.database.implementation") }, - { "host", qcdbUrl } + { "implementation", config.get("qc.config.database.implementation") }, + { "host", qcdbUrl } }; repository = dbConfig; From 3c93e8db6a18f181de3aaee06841686597a79431 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Wed, 12 Mar 2025 14:47:32 +0100 Subject: [PATCH 5/6] fix the test --- Framework/test/testCheck.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/test/testCheck.cxx b/Framework/test/testCheck.cxx index a4d336affe..53aae5ac14 100644 --- a/Framework/test/testCheck.cxx +++ b/Framework/test/testCheck.cxx @@ -150,7 +150,7 @@ TEST_CASE("test_check_activity") "", {}, "", - {}, + {{ "implementation", "CCDB" },{ "host", "" }}, "test", UpdatePolicyType::OnAny, {}, From c19ab465e7d1621d151cb3a1b6d283990d96ffb4 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Wed, 12 Mar 2025 14:47:54 +0100 Subject: [PATCH 6/6] format --- Framework/test/testCheck.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/test/testCheck.cxx b/Framework/test/testCheck.cxx index 53aae5ac14..06a74f8bf8 100644 --- a/Framework/test/testCheck.cxx +++ b/Framework/test/testCheck.cxx @@ -150,7 +150,7 @@ TEST_CASE("test_check_activity") "", {}, "", - {{ "implementation", "CCDB" },{ "host", "" }}, + { { "implementation", "CCDB" }, { "host", "" } }, "test", UpdatePolicyType::OnAny, {},