Skip to content

Commit 609224f

Browse files
authored
Add option to specify the config file from the command line for the basic workflow (#189)
1 parent 35d02d4 commit 609224f

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

Framework/src/runBasic.cxx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ void customize(std::vector<ChannelConfigurationPolicy>& policies)
5252

5353
void customize(std::vector<ConfigParamSpec>& workflowOptions)
5454
{
55+
workflowOptions.push_back(
56+
ConfigParamSpec{ "config-path", VariantType::String, "", { "Path to the config file. Overwrite the default paths. Do not use with no-data-sampling." } });
5557
workflowOptions.push_back(
5658
ConfigParamSpec{ "no-data-sampling", VariantType::Bool, false, { "Skips data sampling, connects directly the task to the producer." } });
5759
}
@@ -68,14 +70,15 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
6870
#include "runnerUtils.h"
6971
#include "ExamplePrinterSpec.h"
7072

73+
std::string getConfigPath(const ConfigContext& config);
74+
7175
using namespace o2::framework;
7276
using namespace o2::quality_control::checker;
7377
using namespace std::chrono;
7478

7579
WorkflowSpec defineDataProcessing(const ConfigContext& config)
7680
{
7781
WorkflowSpec specs;
78-
bool noDS = config.options().get<bool>("no-data-sampling");
7982

8083
// The producer to generate some data in the workflow
8184
DataProcessorSpec producer{
@@ -102,8 +105,8 @@ WorkflowSpec defineDataProcessing(const ConfigContext& config)
102105

103106
specs.push_back(producer);
104107

105-
std::string filename = !noDS ? "basic.json" : "basic-no-sampling.json";
106-
const std::string qcConfigurationSource = std::string("json://") + getenv("QUALITYCONTROL_ROOT") + "/etc/" + filename;
108+
// Path to the config file
109+
std::string qcConfigurationSource = getConfigPath(config);
107110
LOG(INFO) << "Using config file '" << qcConfigurationSource << "'";
108111

109112
// Generation of Data Sampling infrastructure
@@ -124,3 +127,17 @@ WorkflowSpec defineDataProcessing(const ConfigContext& config)
124127

125128
return specs;
126129
}
130+
131+
// TODO merge this with the one from runReadout.cxx
132+
std::string getConfigPath(const ConfigContext& config)
133+
{
134+
// Determine the default config file path and name (based on option no-data-sampling and the QC_ROOT path)
135+
bool noDS = config.options().get<bool>("no-data-sampling");
136+
std::string filename = !noDS ? "basic.json" : "basic-no-sampling.json";
137+
std::string defaultConfigPath = getenv("QUALITYCONTROL_ROOT") != nullptr ? std::string(getenv("QUALITYCONTROL_ROOT")) + "/etc/" + filename : "$QUALITYCONTROL_ROOT undefined";
138+
// The the optional one by the user
139+
auto userConfigPath = config.options().get<std::string>("config-path");
140+
// Finally build the config path based on the default or the user-base one
141+
std::string path = std::string("json:/") + (userConfigPath.empty() ? defaultConfigPath : userConfigPath);
142+
return path;
143+
}

0 commit comments

Comments
 (0)