Skip to content
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
3 changes: 2 additions & 1 deletion Framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ add_library(O2QualityControl
src/Calculators.cxx
src/DataSourceSpec.cxx
src/RootFileSink.cxx
src/RootFileSource.cxx)
src/RootFileSource.cxx
src/UpdatePolicyType.cxx)

target_include_directories(
O2QualityControl
Expand Down
5 changes: 3 additions & 2 deletions Framework/include/QualityControl/Aggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// QC
#include "QualityControl/QualityObject.h"
#include "QualityControl/CheckConfig.h"
#include "QualityObject.h"
#include "QualityControl/UpdatePolicyType.h"
// config
#include <boost/property_tree/ptree_fwd.hpp>

Expand All @@ -36,6 +36,7 @@ namespace o2::quality_control::checker

class AggregatorInterface;

// todo: it can be replaced DataSourceType
enum AggregatorSourceType { check,
aggregator };

Expand Down Expand Up @@ -73,7 +74,7 @@ class Aggregator
o2::quality_control::core::QualityObjectsType aggregate(core::QualityObjectsMapType& qoMap);

const std::string& getName() const;
std::string getPolicyName() const;
UpdatePolicyType getUpdatePolicyType() const;
std::vector<std::string> getObjectsNames() const;
bool getAllObjectsOption() const;
std::vector<AggregatorSource> getSources();
Expand Down
2 changes: 1 addition & 1 deletion Framework/include/QualityControl/AggregatorRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class AggregatorRunner : public framework::Task
* @param configurationSource Path to configuration
* @param checkRunnerOutputs List of checkRunners' output that it will take as inputs.
*/
AggregatorRunner(const std::string& configurationSource, const vector<framework::OutputSpec> checkRunnerOutputs);
AggregatorRunner(const std::string& configurationSource, const std::vector<framework::OutputSpec> checkRunnerOutputs);

/// Destructor
~AggregatorRunner() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AggregatorRunnerFactory
AggregatorRunnerFactory() = default;
virtual ~AggregatorRunnerFactory() = default;

static framework::DataProcessorSpec create(const vector<framework::OutputSpec>& checkerRunnerOutputs, const std::string& configurationSource);
static framework::DataProcessorSpec create(const std::vector<framework::OutputSpec>& checkerRunnerOutputs, const std::string& configurationSource);
static void customizeInfrastructure(std::vector<framework::CompletionPolicy>& policies);
};

Expand Down
26 changes: 10 additions & 16 deletions Framework/include/QualityControl/Check.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "QualityControl/CheckInterface.h"
#include "QualityControl/QcInfoLogger.h"
#include "QualityControl/CheckConfig.h"
#include "QualityControl/CommonSpec.h"
#include "QualityControl/CheckSpec.h"

namespace o2::quality_control::checker
{
Expand All @@ -49,7 +51,7 @@ class Check
* @param checkName Check name from the configuration
* @param configurationSource Path to configuration
*/
Check(std::string checkName, std::string configurationSource);
Check(CheckConfig config);

/**
* \brief Initialize the check state
Expand All @@ -68,36 +70,28 @@ class Check
void updateRevision(unsigned int revision);

const std::string& getName() const { return mCheckConfig.name; };
o2::framework::OutputSpec getOutputSpec() const { return mOutputSpec; };
o2::framework::Inputs getInputs() const { return mInputs; };
o2::framework::OutputSpec getOutputSpec() const { return mCheckConfig.qoSpec; };
o2::framework::Inputs getInputs() const { return mCheckConfig.inputSpecs; };

//TODO: Unique Input string
static o2::header::DataDescription createCheckerDataDescription(const std::string taskName);
static o2::header::DataDescription createCheckerDataDescription(const std::string& taskName);

// For testing purpose
void setCheckInterface(CheckInterface* checkInterface) { mCheckInterface = checkInterface; };

std::string getPolicyName() const;
UpdatePolicyType getUpdatePolicyType() const;
std::vector<std::string> getObjectsNames() const;
bool getAllObjectsOption() const;

private:
void initConfig(std::string checkName);
// todo: probably make CheckFactory
static CheckConfig extractConfig(const CommonSpec&, const CheckSpec&);

private:
void beautify(std::map<std::string, std::shared_ptr<MonitorObject>>& moMap, Quality quality);

std::string mConfigurationSource;
o2::quality_control::core::QcInfoLogger& mLogger;
CheckConfig mCheckConfig;
CheckInterface* mCheckInterface = nullptr;
size_t mNumberOfTaskSources;

// DPL information
o2::framework::Inputs mInputs;
std::vector<std::string> mInputsStringified;
o2::framework::OutputSpec mOutputSpec;

bool mBeautify = true;
};

} // namespace o2::quality_control::checker
Expand Down
10 changes: 8 additions & 2 deletions Framework/include/QualityControl/CheckConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <string>
#include <unordered_map>

#include <Framework/DataProcessorSpec.h>
#include "QualityControl/UpdatePolicyType.h"

namespace o2::quality_control::checker
{

Expand All @@ -30,9 +33,12 @@ struct CheckConfig {
std::string className;
std::string detectorName = "MISC"; // intended to be the 3 letters code;
std::unordered_map<std::string, std::string> customParameters = {};
std::string policyType = "OnAny";
std::vector<std::string> objectNames;
UpdatePolicyType policyType = UpdatePolicyType::OnAny;
std::vector<std::string> objectNames{}; // fixme: if object names are empty, allObjects are true, consider reducing to one var
Comment thread
knopers8 marked this conversation as resolved.
bool allObjects = false;
bool allowBeautify = false;
framework::Inputs inputSpecs{};
framework::OutputSpec qoSpec{ "XXX", "INVALID" };
};

} // namespace o2::quality_control::checker
Expand Down
23 changes: 10 additions & 13 deletions Framework/include/QualityControl/CheckRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "QualityControl/Check.h"
#include "QualityControl/UpdatePolicyManager.h"
#include "QualityControl/Activity.h"
#include "QualityControl/CheckRunnerConfig.h"

namespace o2::quality_control::core
{
Expand Down Expand Up @@ -83,22 +84,21 @@ class CheckRunner : public framework::Task
* Depending on the constructor, it can be a single check device or a group check device.
* Group check assumes that the input of the checks is the same!
*
* @param checkName Check name from the configuration
* @param checkNames List of check names, that operate on the same inputs.
* @param configurationSource Path to configuration
* @param checkRunnerConfig configuration of CheckRunner
* @param checkConfigs configuration of all Checks that should run in this data processor
*/
CheckRunner(std::vector<Check> checks, std::string configurationSource);
CheckRunner(CheckRunnerConfig, const std::vector<CheckConfig>& checkConfigs);

/**
* \brief CheckRunner constructor
*
* Create a sink for the Input. It is expected to receive Monitor Object to store.
* It will not run any checks on a given input.
*
* @param checkRunnerConfig configuration of CheckRunner
* @param input Monitor Object input spec.
* @param configSource Path to configuration
*/
CheckRunner(o2::framework::InputSpec input, std::string configurationSource);
CheckRunner(CheckRunnerConfig, o2::framework::InputSpec input);

/// Destructor
~CheckRunner() override;
Expand All @@ -116,11 +116,8 @@ class CheckRunner : public framework::Task
std::string getDeviceName() { return mDeviceName; };

/// \brief Unified DataDescription naming scheme for all checkers
static o2::header::DataDescription createCheckRunnerDataDescription(const std::string taskName);
static o2::framework::Inputs createInputSpec(const std::string checkName, const std::string configSource);

static std::string createCheckRunnerIdString() { return "QC-CHECK-RUNNER"; };
static std::string createCheckRunnerName(std::vector<Check> checks);
static std::string createCheckRunnerName(const std::vector<CheckConfig>& checks);
static std::string createSinkCheckRunnerName(o2::framework::InputSpec input);
static std::string createCheckRunnerFacility(std::string deviceName);

Expand Down Expand Up @@ -161,7 +158,7 @@ class CheckRunner : public framework::Task
*
* \param checks List of all checks
*/
static o2::framework::Outputs collectOutputs(const std::vector<Check>& checks);
static o2::framework::Outputs collectOutputs(const std::vector<CheckConfig>& checks);

inline void initDatabase();
inline void initMonitoring();
Expand All @@ -178,7 +175,7 @@ class CheckRunner : public framework::Task
*
* \param input_string String intended to be hashed
*/
static std::size_t hash(std::string input_string);
static std::size_t hash(const std::string& inputString);

/**
* \brief Massage/Prepare data from the Context and store it in the cache.
Expand Down Expand Up @@ -206,11 +203,11 @@ class CheckRunner : public framework::Task
std::string mDeviceName;
std::vector<Check> mChecks;
Activity mActivity;
CheckRunnerConfig mConfig;
o2::quality_control::core::QcInfoLogger& mLogger;
std::shared_ptr<o2::quality_control::repository::DatabaseInterface> mDatabase;
std::unordered_set<std::string> mInputStoreSet;
std::vector<std::shared_ptr<MonitorObject>> mMonitorObjectStoreVector;
std::shared_ptr<o2::configuration::ConfigurationInterface> mConfigFile;
UpdatePolicyManager updatePolicyManager;

// DPL
Expand Down
39 changes: 39 additions & 0 deletions Framework/include/QualityControl/CheckRunnerConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

///
/// \file CheckRunnerConfig.h
/// \author Piotr Konopka
///
#ifndef QUALITYCONTROL_CHECKRUNNERCONFIG_H
#define QUALITYCONTROL_CHECKRUNNERCONFIG_H

#include <string>
#include <unordered_map>

namespace o2::quality_control::checker
{

struct CheckRunnerConfig {
std::unordered_map<std::string, std::string> database;
std::string consulUrl{};
std::string monitoringUrl{};
bool infologgerFilterDiscardDebug = false;
int infologgerDiscardLevel = 21;
int fallbackRunNumber = 0;
std::string fallbackPeriodName{};
std::string fallbackPassName{};
std::string fallbackProvenance{};
};

} // namespace o2::quality_control::checker

#endif //QUALITYCONTROL_CHECKRUNNERCONFIG_H
7 changes: 5 additions & 2 deletions Framework/include/QualityControl/CheckRunnerFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Framework/DataProcessorSpec.h"
#include <Framework/CompletionPolicy.h>
#include "QualityControl/Check.h"
#include "QualityControl/CheckRunnerConfig.h"

namespace o2::framework
{
Expand All @@ -38,7 +39,7 @@ class CheckRunnerFactory
CheckRunnerFactory() = default;
virtual ~CheckRunnerFactory() = default;

framework::DataProcessorSpec create(std::vector<Check> checks, std::string configurationSource, std::vector<std::string> storeVector = {});
static framework::DataProcessorSpec create(CheckRunnerConfig checkRunnerConfig, std::vector<CheckConfig> checkConfigs, std::vector<std::string> storeVector = {});

/*
* \brief Create a CheckRunner sink DPL device.
Expand All @@ -48,7 +49,9 @@ class CheckRunnerFactory
* @param input InputSpec with the content to store
* @param configurationSource
*/
framework::DataProcessorSpec createSinkDevice(o2::framework::InputSpec input, std::string configurationSource);
static framework::DataProcessorSpec createSinkDevice(CheckRunnerConfig checkRunnerConfig, o2::framework::InputSpec input);

static CheckRunnerConfig extractConfig(const CommonSpec&);

static void customizeInfrastructure(std::vector<framework::CompletionPolicy>& policies);
};
Expand Down
59 changes: 59 additions & 0 deletions Framework/include/QualityControl/CheckSpec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef QUALITYCONTROL_CHECKSPEC_H
#define QUALITYCONTROL_CHECKSPEC_H

///
/// \file CheckSpec.h
/// \author Piotr Konopka
///

#include <string>

#include "QualityControl/DataSourceSpec.h"
#include "QualityControl/UpdatePolicyType.h"

namespace o2::quality_control::checker
{

/// \brief Specification of a Check, which should map the JSON configuration structure.
struct CheckSpec {
// default, invalid spec
CheckSpec() = default;

// minimal valid spec
CheckSpec(std::string checkName, std::string className, std::string moduleName, std::string detectorName,
std::vector<core::DataSourceSpec> dataSources, UpdatePolicyType updatePolicySpec)
: checkName(std::move(checkName)),
className(std::move(className)),
moduleName(std::move(moduleName)),
detectorName(std::move(detectorName)),
dataSources(std::move(dataSources)),
updatePolicy(updatePolicySpec)
{
}

// basic
std::string checkName = "Invalid";
std::string className = "Invalid";
std::string moduleName = "Invalid";
std::string detectorName = "DET";
std::vector<core::DataSourceSpec> dataSources;
UpdatePolicyType updatePolicy = UpdatePolicyType::OnAny;
// advanced
bool active = true;
std::unordered_map<std::string, std::string> customParameters = {};
};

} // namespace o2::quality_control::checker

#endif //QUALITYCONTROL_CHECKSPEC_H
5 changes: 3 additions & 2 deletions Framework/include/QualityControl/DataSourceSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum class DataSourceType {

// this should allow us to represent all data sources which come from DPL (and maybe CCDB).
struct DataSourceSpec {
explicit DataSourceSpec(DataSourceType type = DataSourceType::Invalid, std::unordered_map<std::string, std::string> params = {});
explicit DataSourceSpec(DataSourceType type = DataSourceType::Invalid);

// todo: use c++20 concepts when available
template <class... Args, class Enable = std::enable_if_t<(... && std::is_convertible_v<Args, DataSourceType>)>>
Expand All @@ -47,8 +47,9 @@ struct DataSourceSpec {
}

DataSourceType type;
std::unordered_map<std::string, std::string> typeSpecificParams;
std::string name;
std::vector<framework::InputSpec> inputs;
std::vector<std::string> subInputs; // can be MO or QO names
};

} // namespace o2::quality_control::core
Expand Down
Loading