Skip to content

Commit

Permalink
Add option to specify the config file from the command line for the b…
Browse files Browse the repository at this point in the history
…asic workflow (#189)
  • Loading branch information
Barthelemy authored Jun 18, 2019
1 parent 35d02d4 commit 609224f
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Framework/src/runBasic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ void customize(std::vector<ChannelConfigurationPolicy>& policies)

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

std::string getConfigPath(const ConfigContext& config);

using namespace o2::framework;
using namespace o2::quality_control::checker;
using namespace std::chrono;

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

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

specs.push_back(producer);

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

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

return specs;
}

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

0 comments on commit 609224f

Please sign in to comment.