Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBFUtils: Optional throw on failed parsing of opt #13701

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Detectors/Raw/include/DetectorsRaw/HBFUtilsInitializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct HBFUtilsInitializer {
static o2::dataformats::IRFrame IRFrameSel; // IRFrame selected for the current TF

HBFUtilsInitializer(const o2::framework::ConfigContext& configcontext, o2::framework::WorkflowSpec& wf);
static HBFOpt getOptType(const std::string& optString);
static HBFOpt getOptType(const std::string& optString, bool throwOnFailure = true);
static std::vector<o2::dataformats::TFIDInfo> readTFIDInfoVector(const std::string& fname);
static void readIRFramesVector(const std::string& fname);
static void assignDataHeaderFromTFIDInfo(const std::vector<o2::dataformats::TFIDInfo>& tfinfoVec, o2::header::DataHeader& dh, o2::framework::DataProcessingHeader& dph);
Expand Down
8 changes: 3 additions & 5 deletions Detectors/Raw/src/HBFUtilsInitializer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ HBFUtilsInitializer::HBFUtilsInitializer(const o2f::ConfigContext& configcontext
upstream = true;
continue;
}
HBFOpt opt = getOptType(optStr);
HBFOpt opt = getOptType(optStr, !helpasked); // do not throw on unknown opt if help-opt was given
nopts++;
if ((opt == HBFOpt::INI || opt == HBFOpt::JSON) && !helpasked) {
o2::conf::ConfigurableParam::updateFromFile(optStr, "HBFUtils", true); // update only those values which were not touched yet (provenance == kCODE)
Expand All @@ -78,8 +78,6 @@ HBFUtilsInitializer::HBFUtilsInitializer(const o2f::ConfigContext& configcontext
hbfuInput = optStr;
} else if (opt == HBFOpt::ROOT) {
rootFileInput = optStr;
} else if (!helpasked) {
LOGP(fatal, "uknown hbfutils-config option {}", optStr);
}
}
if (!nopts && !helpasked) {
Expand Down Expand Up @@ -125,7 +123,7 @@ HBFUtilsInitializer::HBFUtilsInitializer(const o2f::ConfigContext& configcontext
}

//_________________________________________________________
HBFUtilsInitializer::HBFOpt HBFUtilsInitializer::getOptType(const std::string& optString)
HBFUtilsInitializer::HBFOpt HBFUtilsInitializer::getOptType(const std::string& optString, bool throwOnFailure)
{
// return type of the file provided via HBFConfOpt
HBFOpt opt = HBFOpt::NONE;
Expand All @@ -138,7 +136,7 @@ HBFUtilsInitializer::HBFOpt HBFUtilsInitializer::getOptType(const std::string& o
opt = HBFOpt::ROOT;
} else if (optString == HBFUSrc) {
opt = HBFOpt::HBFUTILS;
} else if (optString != "none") {
} else if (optString != "none" && throwOnFailure) {
throw std::runtime_error(fmt::format("invalid option {} for {}", optString, HBFConfOpt));
}
}
Expand Down
Loading