From 72c4ba7d3fa60199ce3aa9fd6b12bb572e35943d Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 24 Apr 2026 13:43:26 +0200 Subject: [PATCH] DPL: streamline option building - Avoid too nested if conditions - Do not propagate --ccdb-fetchers for backward compatibility in the on-the-fly generators - Avoid some copying --- Framework/Core/src/DeviceSpecHelpers.cxx | 104 +++++++++++++---------- Framework/Core/src/runDataProcessing.cxx | 1 - 2 files changed, 61 insertions(+), 44 deletions(-) diff --git a/Framework/Core/src/DeviceSpecHelpers.cxx b/Framework/Core/src/DeviceSpecHelpers.cxx index 88e5269482ebd..1fe0a900af46f 100644 --- a/Framework/Core/src/DeviceSpecHelpers.cxx +++ b/Framework/Core/src/DeviceSpecHelpers.cxx @@ -1596,53 +1596,71 @@ void DeviceSpecHelpers::prepareArguments(bool defaultQuiet, bool defaultStopped, } }; - for (const auto varit : varmap) { + for (const auto& varit : varmap) { // find the option belonging to key, add if the option has been parsed // and is not defaulted const auto* description = odesc.find_nothrow(varit.first, false); - if (description && varmap.count(varit.first)) { - // check the semantics of the value - auto semantic = description->semantic(); - const char* optarg = ""; - if (semantic) { - // the value semantics allows different properties like - // multitoken, zero_token and composing - // currently only the simple case is supported - assert(semantic->min_tokens() <= 1); - // assert(semantic->max_tokens() && semantic->min_tokens()); - if (semantic->min_tokens() > 0) { - std::string stringRep; - if (auto v = boost::any_cast(&varit.second.value())) { - stringRep = *v; - } else if (auto v = boost::any_cast(&varit.second.value())) { - std::stringstream tmp; - tmp << *v; - stringRep = fmt::format("{}", tmp.str()); - } - if (varit.first == "channel-config") { - // FIXME: the parameter to channel-config can be a list of configurations separated - // by semicolon. The individual configurations will be separated and added individually. - // The device arguments can then contaoin multiple channel-config entries, but only - // one for the last configuration is added to control.options - processRawChannelConfig(stringRep); - optarg = tmpArgs.back().c_str(); - } else { - std::string key(fmt::format("--{}", varit.first)); - if (stringRep.length() == 0) { - // in order to identify options without parameter we add a string - // with one blank for the 'blank' parameter, it is filtered out - // further down and a zero-length string is added to argument list - stringRep = " "; - } - updateDeviceArguments(key, stringRep); - optarg = uniqueDeviceArgs[key].c_str(); - } - } else if (semantic->min_tokens() == 0 && varit.second.as()) { - updateDeviceArguments(fmt::format("--{}", varit.first), ""); + if (description == nullptr || varmap.count(varit.first) == 0) { + continue; + } + + if ((varit.first == "ccdb-fetchers" || varit.first == "spawners") && varit.second.defaulted()) { + continue; + } + + // check the semantics of the value + auto semantic = description->semantic(); + const char* optarg = ""; + if (!semantic) { + control.options.insert(std::make_pair(varit.first, optarg)); + continue; + } + + if (semantic->min_tokens() == 0 && varit.second.as()) { + updateDeviceArguments(fmt::format("--{}", varit.first), ""); + control.options.insert(std::make_pair(varit.first, optarg)); + continue; + } + + // the value semantics allows different properties like + // multitoken, zero_token and composing + // currently only the simple case is supported + assert(semantic->min_tokens() <= 1); + // assert(semantic->max_tokens() && semantic->min_tokens()); + if (semantic->min_tokens() == 0) { + control.options.insert(std::make_pair(varit.first, optarg)); + continue; + } + + if (semantic->min_tokens() > 0) { + std::string stringRep; + if (auto v = boost::any_cast(&varit.second.value())) { + stringRep = *v; + } else if (auto v = boost::any_cast(&varit.second.value())) { + std::stringstream tmp; + tmp << *v; + stringRep = fmt::format("{}", tmp.str()); + } + if (varit.first == "channel-config") { + // FIXME: the parameter to channel-config can be a list of configurations separated + // by semicolon. The individual configurations will be separated and added individually. + // The device arguments can then contaoin multiple channel-config entries, but only + // one for the last configuration is added to control.options + processRawChannelConfig(stringRep); + optarg = tmpArgs.back().c_str(); + } else { + std::string key(fmt::format("--{}", varit.first)); + if (stringRep.length() == 0) { + // in order to identify options without parameter we add a string + // with one blank for the 'blank' parameter, it is filtered out + // further down and a zero-length string is added to argument list + stringRep = " "; } + updateDeviceArguments(key, stringRep); + optarg = uniqueDeviceArgs[key].c_str(); } - control.options.insert(std::make_pair(varit.first, optarg)); } + control.options.insert(std::make_pair(varit.first, optarg)); } }; @@ -1653,11 +1671,11 @@ void DeviceSpecHelpers::prepareArguments(bool defaultQuiet, bool defaultStopped, // Add the channel configuration for (auto& channel : spec.outputChannels) { - tmpArgs.emplace_back(std::string("--channel-config")); + tmpArgs.emplace_back("--channel-config"); tmpArgs.emplace_back(outputChannel2String(channel)); } for (auto& channel : spec.inputChannels) { - tmpArgs.emplace_back(std::string("--channel-config")); + tmpArgs.emplace_back("--channel-config"); tmpArgs.emplace_back(inputChannel2String(channel)); } diff --git a/Framework/Core/src/runDataProcessing.cxx b/Framework/Core/src/runDataProcessing.cxx index 03cef9a034144..dcc6caa8d7c4b 100644 --- a/Framework/Core/src/runDataProcessing.cxx +++ b/Framework/Core/src/runDataProcessing.cxx @@ -2055,7 +2055,6 @@ int runStateMachine(DataProcessorSpecs const& workflow, "--driver-client-backend", "--fairmq-ipc-prefix", "--readers", - "--ccdb-fetchers", "--resources-monitoring", "--resources-monitoring-file", "--resources-monitoring-dump-interval",