|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | + |
| 11 | +/// |
| 12 | +/// \file runQC.cxx |
| 13 | +/// \author Piotr Konopka |
| 14 | +/// |
| 15 | +/// \brief This is an executable which generates a QC topology given a configuration file. |
| 16 | +/// |
| 17 | +/// This is an executable which generates a QC topology given a configuration file. It can be attached to any other |
| 18 | +/// topology which can provide data to Data Sampling and QC. This also means that cannot work on its own, as it would |
| 19 | +/// lack input data. A typical usage would be: |
| 20 | +/// \code{.sh} |
| 21 | +/// o2-qc-run-producer | o2-qc-run-qc --config json://${QUALITYCONTROL_ROOT}/etc/basic.json |
| 22 | +/// \endcode |
| 23 | +/// Please refer to Framework/example-default.json and Framework/basic.json to see how to configure a QC topology. |
| 24 | +/// To generate only the local part of the topology (which would run on main processing servers) use the '--local' flag. |
| 25 | +/// Similarly, to generate only the remote part (running on QC servers) add '--remote'. By default, the executable |
| 26 | +/// generates both local and remote topologies, as it is the usual use-case for local development. |
| 27 | + |
| 28 | +#include "Framework/DataSampling.h" |
| 29 | +using namespace o2::framework; |
| 30 | + |
| 31 | +void customize(std::vector<ConfigParamSpec>& workflowOptions) |
| 32 | +{ |
| 33 | + workflowOptions.push_back( |
| 34 | + ConfigParamSpec{ "config", VariantType::String, "", { "Path to QC and Data Sampling configuration file." } }); |
| 35 | + |
| 36 | + workflowOptions.push_back( |
| 37 | + ConfigParamSpec{ "local", VariantType::Bool, false, { "Creates only the local part of the QC topology." } }); |
| 38 | + workflowOptions.push_back( |
| 39 | + ConfigParamSpec{ "host", VariantType::String, "", { "Name of the host of the local part of the QC topology." |
| 40 | + "Necessary to specify when creating topologies on multiple" |
| 41 | + " machines, can be omitted for the local development" } }); |
| 42 | + workflowOptions.push_back( |
| 43 | + ConfigParamSpec{ "remote", VariantType::Bool, false, { "Creates only the remote part of the QC topology." } }); |
| 44 | +} |
| 45 | + |
| 46 | +#include <FairLogger.h> |
| 47 | +#include <TH1F.h> |
| 48 | +#include <memory> |
| 49 | +#include <random> |
| 50 | + |
| 51 | +#include "Framework/runDataProcessing.h" |
| 52 | + |
| 53 | +#include "QualityControl/Checker.h" |
| 54 | +#include "QualityControl/InfrastructureGenerator.h" |
| 55 | + |
| 56 | +using namespace o2; |
| 57 | +using namespace o2::framework; |
| 58 | +using namespace o2::quality_control::checker; |
| 59 | +using namespace std::chrono; |
| 60 | + |
| 61 | +WorkflowSpec defineDataProcessing(const ConfigContext& config) |
| 62 | +{ |
| 63 | + WorkflowSpec specs; |
| 64 | + |
| 65 | + const std::string qcConfigurationSource = config.options().get<std::string>("config"); |
| 66 | + LOG(INFO) << "Using config file '" << qcConfigurationSource << "'"; |
| 67 | + |
| 68 | + // The QC infrastructure is divided into two parts: |
| 69 | + // - local - QC tasks which are on the same machines as the main processing. We also put Data Sampling there. |
| 70 | + // - remote - QC tasks, mergers and checkers that reside on QC servers |
| 71 | + // |
| 72 | + // The user can specify to create either one of these parts by selecting corresponding option, |
| 73 | + // or both of them, which is the default option (no flags needed). |
| 74 | + |
| 75 | + if (config.options().get<bool>("local") && config.options().get<bool>("remote")) { |
| 76 | + LOG(INFO) << "To create both local and remote QC topologies, one does not have to add any of '--local' or '--remote' flags."; |
| 77 | + } |
| 78 | + |
| 79 | + if (config.options().get<bool>("local") || !config.options().get<bool>("remote")) { |
| 80 | + |
| 81 | + // Generation of Data Sampling infrastructure |
| 82 | + DataSampling::GenerateInfrastructure(specs, qcConfigurationSource); |
| 83 | + |
| 84 | + // Generation of the local QC topology (local QC tasks) |
| 85 | + quality_control::generateLocalInfrastructure(specs, qcConfigurationSource, config.options().get<std::string>("host")); |
| 86 | + } |
| 87 | + if (config.options().get<bool>("remote") || !config.options().get<bool>("local")) { |
| 88 | + |
| 89 | + // Generation of the remote QC topology (task for QC servers, mergers and all checkers) |
| 90 | + quality_control::generateRemoteInfrastructure(specs, qcConfigurationSource); |
| 91 | + } |
| 92 | + |
| 93 | + return specs; |
| 94 | +} |
0 commit comments