From e7877f00cb36eaa82f45917d4837198c4f51c5b4 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Thu, 13 Jan 2022 17:06:29 +0100 Subject: [PATCH 1/6] [QC-310] Dump a property qcConfiguration for the QC devices Introduce a new label `qc-reconfigurable`. Dump a property in the qc tasks pointing to the file in consul to reconfigure the tasks. --- .../Core/include/Framework/O2ControlLabels.h | 4 ++ Framework/Core/src/O2ControlHelpers.cxx | 49 +++++++++++++++---- Framework/Core/src/O2ControlLabels.cxx | 2 + 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Framework/Core/include/Framework/O2ControlLabels.h b/Framework/Core/include/Framework/O2ControlLabels.h index eb05f156cf58d..2d4ea7c66cc3a 100644 --- a/Framework/Core/include/Framework/O2ControlLabels.h +++ b/Framework/Core/include/Framework/O2ControlLabels.h @@ -31,6 +31,10 @@ const extern DataProcessorLabel uniqueProxyLabel; // Thus, AliECS will not perform host and port allocation automatically. It takes priority over `uniqueProxyLabel`. const extern DataProcessorLabel preserveRawChannelsLabel; +// This label makes AliECS templates add the property `qcConfiguration` to the tasks, allowing them +// to reconfigure in init with a freshly templated config. +const extern DataProcessorLabel qcReconfigurable; + } // namespace ecs } // namespace o2::framework diff --git a/Framework/Core/src/O2ControlHelpers.cxx b/Framework/Core/src/O2ControlHelpers.cxx index d4aeec9b169cf..0352322ea8921 100644 --- a/Framework/Core/src/O2ControlHelpers.cxx +++ b/Framework/Core/src/O2ControlHelpers.cxx @@ -185,6 +185,43 @@ std::vector extractRawChannels(const DeviceSpec& spec, const DeviceE return rawChannels; } +bool isUniqueProxy(const DeviceSpec& spec) +{ + return std::find(spec.labels.begin(), spec.labels.end(), ecs::uniqueProxyLabel) != spec.labels.end(); +} + +bool shouldPreserveRawChannels(const DeviceSpec& spec) +{ + return std::find(spec.labels.begin(), spec.labels.end(), ecs::preserveRawChannelsLabel) != spec.labels.end(); +} + +bool isQcReconfigurable(const DeviceSpec& spec) +{ + return std::find(spec.labels.begin(), spec.labels.end(), ecs::qcReconfigurable) != spec.labels.end(); +} + +void dumpQcConfig(std::ostream& dumpOut, const DeviceExecution& execution, const DeviceSpec& spec, const std::string& indLevel) +{ + // get the argument `--config` + std::string configPath; + auto it = std::find_if (execution.args.begin(), execution.args.end(), [&](char * v) { if (v) return strcmp(v, "--config") == 0; else return false; }); + + // get the next argument and find `/o2/components/` in it, then take what comes after in the string. + if(it != execution.args.end()) { + std::string configParam = *(++it); + std::string prefix = "/o2/components/"; // keep only the path to the config file, i.e. stuff after "/o2/components/" + size_t pos = configParam.find(prefix); + if(pos != std::string::npos) { + configPath = configParam.substr(pos + prefix.length()); + } + } + + if(implementation::isQcReconfigurable(spec)) { + dumpOut << indLevel << "properties:\n"; + dumpOut << indLevel << indScheme << "qcConfiguration: " << configPath << "\n"; + } +} + void dumpCommand(std::ostream& dumpOut, const DeviceExecution& execution, std::string indLevel) { dumpOut << indLevel << "shell: true\n"; @@ -260,16 +297,6 @@ std::string findBinder(const std::vector& specs, const std::string& throw std::runtime_error("Could not find a device which binds the '" + channel + "' channel."); } -bool isUniqueProxy(const DeviceSpec& spec) -{ - return std::find(spec.labels.begin(), spec.labels.end(), ecs::uniqueProxyLabel) != spec.labels.end(); -} - -bool shouldPreserveRawChannels(const DeviceSpec& spec) -{ - return std::find(spec.labels.begin(), spec.labels.end(), ecs::preserveRawChannelsLabel) != spec.labels.end(); -} - void dumpRole(std::ostream& dumpOut, const std::string& taskName, const DeviceSpec& spec, const std::vector& allSpecs, const DeviceExecution& execution, const std::string indLevel) { dumpOut << indLevel << "- name: \"" << spec.id << "\"\n"; @@ -374,6 +401,8 @@ void dumpTask(std::ostream& dumpOut, const DeviceSpec& spec, const DeviceExecuti } } + implementation::dumpQcConfig(dumpOut, execution, spec, indLevel); + dumpOut << indLevel << "command:\n"; implementation::dumpCommand(dumpOut, execution, indLevel + indScheme); } diff --git a/Framework/Core/src/O2ControlLabels.cxx b/Framework/Core/src/O2ControlLabels.cxx index aa22d858f6e44..2e4f1754f2d82 100644 --- a/Framework/Core/src/O2ControlLabels.cxx +++ b/Framework/Core/src/O2ControlLabels.cxx @@ -16,4 +16,6 @@ namespace o2::framework::ecs const DataProcessorLabel uniqueProxyLabel = {"ecs-unique-proxy"}; const DataProcessorLabel preserveRawChannelsLabel = {"ecs-preserve-raw-channels"}; +const DataProcessorLabel qcReconfigurable = {"qc-reconfigurable"}; + } \ No newline at end of file From a7920945ccbd408267f487f05f6563a7bf0eeb95 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Fri, 14 Jan 2022 08:23:33 +0100 Subject: [PATCH 2/6] format --- Framework/Core/src/O2ControlHelpers.cxx | 8 ++++---- Framework/Core/src/O2ControlLabels.cxx | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Framework/Core/src/O2ControlHelpers.cxx b/Framework/Core/src/O2ControlHelpers.cxx index 0352322ea8921..f61ad917abe10 100644 --- a/Framework/Core/src/O2ControlHelpers.cxx +++ b/Framework/Core/src/O2ControlHelpers.cxx @@ -204,19 +204,19 @@ void dumpQcConfig(std::ostream& dumpOut, const DeviceExecution& execution, const { // get the argument `--config` std::string configPath; - auto it = std::find_if (execution.args.begin(), execution.args.end(), [&](char * v) { if (v) return strcmp(v, "--config") == 0; else return false; }); + auto it = std::find_if(execution.args.begin(), execution.args.end(), [&](char* v) { if (v) return strcmp(v, "--config") == 0; else return false; }); // get the next argument and find `/o2/components/` in it, then take what comes after in the string. - if(it != execution.args.end()) { + if (it != execution.args.end()) { std::string configParam = *(++it); std::string prefix = "/o2/components/"; // keep only the path to the config file, i.e. stuff after "/o2/components/" size_t pos = configParam.find(prefix); - if(pos != std::string::npos) { + if (pos != std::string::npos) { configPath = configParam.substr(pos + prefix.length()); } } - if(implementation::isQcReconfigurable(spec)) { + if (implementation::isQcReconfigurable(spec)) { dumpOut << indLevel << "properties:\n"; dumpOut << indLevel << indScheme << "qcConfiguration: " << configPath << "\n"; } diff --git a/Framework/Core/src/O2ControlLabels.cxx b/Framework/Core/src/O2ControlLabels.cxx index 2e4f1754f2d82..9c0b4dbd96d41 100644 --- a/Framework/Core/src/O2ControlLabels.cxx +++ b/Framework/Core/src/O2ControlLabels.cxx @@ -17,5 +17,4 @@ namespace o2::framework::ecs const DataProcessorLabel uniqueProxyLabel = {"ecs-unique-proxy"}; const DataProcessorLabel preserveRawChannelsLabel = {"ecs-preserve-raw-channels"}; const DataProcessorLabel qcReconfigurable = {"qc-reconfigurable"}; - } \ No newline at end of file From d64b7be2e4401abe1246156fb723cb2498522260 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Fri, 14 Jan 2022 11:19:37 +0100 Subject: [PATCH 3/6] Fix the formatting --- Framework/Core/src/O2ControlHelpers.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/Core/src/O2ControlHelpers.cxx b/Framework/Core/src/O2ControlHelpers.cxx index f61ad917abe10..827240c4a538c 100644 --- a/Framework/Core/src/O2ControlHelpers.cxx +++ b/Framework/Core/src/O2ControlHelpers.cxx @@ -204,7 +204,7 @@ void dumpQcConfig(std::ostream& dumpOut, const DeviceExecution& execution, const { // get the argument `--config` std::string configPath; - auto it = std::find_if(execution.args.begin(), execution.args.end(), [&](char* v) { if (v) return strcmp(v, "--config") == 0; else return false; }); + auto it = std::find_if(execution.args.begin(), execution.args.end(), [&](char* v) { if (v) { return strcmp(v, "--config") == 0;} else {return false;} }); // get the next argument and find `/o2/components/` in it, then take what comes after in the string. if (it != execution.args.end()) { From eb726c7a49f1af6c584a5773d6383d515e2e7972 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Mon, 17 Jan 2022 09:57:17 +0100 Subject: [PATCH 4/6] apply pr comments --- Framework/Core/src/O2ControlHelpers.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Framework/Core/src/O2ControlHelpers.cxx b/Framework/Core/src/O2ControlHelpers.cxx index 827240c4a538c..48600a36c37bd 100644 --- a/Framework/Core/src/O2ControlHelpers.cxx +++ b/Framework/Core/src/O2ControlHelpers.cxx @@ -200,11 +200,11 @@ bool isQcReconfigurable(const DeviceSpec& spec) return std::find(spec.labels.begin(), spec.labels.end(), ecs::qcReconfigurable) != spec.labels.end(); } -void dumpQcConfig(std::ostream& dumpOut, const DeviceExecution& execution, const DeviceSpec& spec, const std::string& indLevel) +void dumpProperties(std::ostream& dumpOut, const DeviceExecution& execution, const DeviceSpec& spec, const std::string& indLevel) { // get the argument `--config` std::string configPath; - auto it = std::find_if(execution.args.begin(), execution.args.end(), [&](char* v) { if (v) { return strcmp(v, "--config") == 0;} else {return false;} }); + auto it = std::find_if(execution.args.begin(), execution.args.end(), [](char* v) { return v != nullptr && strcmp(v, "--config") == 0; }); // get the next argument and find `/o2/components/` in it, then take what comes after in the string. if (it != execution.args.end()) { @@ -401,7 +401,7 @@ void dumpTask(std::ostream& dumpOut, const DeviceSpec& spec, const DeviceExecuti } } - implementation::dumpQcConfig(dumpOut, execution, spec, indLevel); + implementation::dumpProperties(dumpOut, execution, spec, indLevel); dumpOut << indLevel << "command:\n"; implementation::dumpCommand(dumpOut, execution, indLevel + indScheme); From 218b67d86949ad94afa1c06175b5c9d9724cfaa3 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Mon, 17 Jan 2022 15:26:50 +0100 Subject: [PATCH 5/6] Only dump Properties if qcReco is true --- Framework/Core/src/O2ControlHelpers.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Framework/Core/src/O2ControlHelpers.cxx b/Framework/Core/src/O2ControlHelpers.cxx index 48600a36c37bd..7952de24f3029 100644 --- a/Framework/Core/src/O2ControlHelpers.cxx +++ b/Framework/Core/src/O2ControlHelpers.cxx @@ -216,10 +216,8 @@ void dumpProperties(std::ostream& dumpOut, const DeviceExecution& execution, con } } - if (implementation::isQcReconfigurable(spec)) { - dumpOut << indLevel << "properties:\n"; - dumpOut << indLevel << indScheme << "qcConfiguration: " << configPath << "\n"; - } + dumpOut << indLevel << "properties:\n"; + dumpOut << indLevel << indScheme << "qcConfiguration: " << configPath << "\n"; } void dumpCommand(std::ostream& dumpOut, const DeviceExecution& execution, std::string indLevel) @@ -401,7 +399,9 @@ void dumpTask(std::ostream& dumpOut, const DeviceSpec& spec, const DeviceExecuti } } - implementation::dumpProperties(dumpOut, execution, spec, indLevel); + if(implementation::isQcReconfigurable(spec)) { + implementation::dumpProperties(dumpOut, execution, spec, indLevel); + } dumpOut << indLevel << "command:\n"; implementation::dumpCommand(dumpOut, execution, indLevel + indScheme); From e496817e038a9845c6b02490186fb217a14729bf Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 17 Jan 2022 14:27:51 +0000 Subject: [PATCH 6/6] Please consider the following formatting changes --- Framework/Core/src/O2ControlHelpers.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/Core/src/O2ControlHelpers.cxx b/Framework/Core/src/O2ControlHelpers.cxx index 7952de24f3029..e0f4858e36ed4 100644 --- a/Framework/Core/src/O2ControlHelpers.cxx +++ b/Framework/Core/src/O2ControlHelpers.cxx @@ -399,7 +399,7 @@ void dumpTask(std::ostream& dumpOut, const DeviceSpec& spec, const DeviceExecuti } } - if(implementation::isQcReconfigurable(spec)) { + if (implementation::isQcReconfigurable(spec)) { implementation::dumpProperties(dumpOut, execution, spec, indLevel); }