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
4 changes: 3 additions & 1 deletion Framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ add_library(O2QualityControl
src/TaskInterface.cxx
src/RepositoryBenchmark.cxx
src/InfrastructureGenerator.cxx
src/InfrastructureSpecReader.cxx
src/Check.cxx
src/Aggregator.cxx
src/ServiceDiscovery.cxx
Expand All @@ -73,7 +74,8 @@ add_library(O2QualityControl
src/UpdatePolicyManager.cxx
src/AdvancedWorkflow.cxx
src/QualitiesToTRFCollectionConverter.cxx
src/Calculators.cxx)
src/Calculators.cxx
src/DataSourceSpec.cxx)

target_include_directories(
O2QualityControl
Expand Down
43 changes: 43 additions & 0 deletions Framework/include/QualityControl/CommonSpec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// 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_COMMONSPEC_H
#define QUALITYCONTROL_COMMONSPEC_H

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

#include <string>
#include <unordered_map>
#include <boost/property_tree/ptree_fwd.hpp>

namespace o2::quality_control::core
{

struct CommonSpec {
CommonSpec() = default;

std::unordered_map<std::string, std::string> database;
int activityNumber;
int activityType;
std::string monitoringUrl = "infologger:///debug?qc";
std::string consulUrl;
std::string conditionDBUrl = "http://ccdb-test.cern.ch:8080";
bool infologgerFilterDiscardDebug = false;
int infologgerDiscardLevel = 21;

std::string configurationSource;
};

} // namespace o2::quality_control::core

#endif //QUALITYCONTROL_COMMONSPEC_H
56 changes: 56 additions & 0 deletions Framework/include/QualityControl/DataSourceSpec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// 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_DATASOURCESPEC_H
#define QUALITYCONTROL_DATASOURCESPEC_H

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

#include <string>
#include <unordered_map>
#include <Framework/InputSpec.h>
#include <type_traits>

namespace o2::quality_control::core
{

enum class DataSourceType {
DataSamplingPolicy,
Direct,
Task,
Check,
Aggregator,
PostProcessingTask,
ExternalTask,
Invalid
};

// 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 = {});

// todo: use c++20 concepts when available
template <class... Args, class Enable = std::enable_if_t<(... && std::is_convertible_v<Args, DataSourceType>)>>
bool isOneOf(Args... dataSourceType) const
{
return (... || (dataSourceType == type));
}

DataSourceType type;
std::unordered_map<std::string, std::string> typeSpecificParams;
std::vector<framework::InputSpec> inputs;
};

} // namespace o2::quality_control::core

#endif //QUALITYCONTROL_DATASOURCESPEC_H
4 changes: 2 additions & 2 deletions Framework/include/QualityControl/InfrastructureGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class InfrastructureGenerator
/// configuration to be 'local'.
///
/// \param configurationSource - full path to configuration file, preceded with the backend (f.e. "json://")
/// \param host - name of the machine
/// \param targetHost - name of the machine
/// \return generated local QC workflow
static framework::WorkflowSpec generateLocalInfrastructure(std::string configurationSource, std::string host);
static framework::WorkflowSpec generateLocalInfrastructure(std::string configurationSource, std::string targetHost);

/// \brief Generates the local part of the QC infrastructure for a specified host.
///
Expand Down
35 changes: 35 additions & 0 deletions Framework/include/QualityControl/InfrastructureSpec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// 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_INFRASTRUCTURESPEC_H
#define QUALITYCONTROL_INFRASTRUCTURESPEC_H

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

#include "QualityControl/CommonSpec.h"
#include "QualityControl/TaskSpec.h"

#include <vector>

namespace o2::quality_control::core
{

struct InfrastructureSpec {
CommonSpec common;
std::vector<TaskSpec> tasks;
// todo: add other actors
};

} // namespace o2::quality_control::core

#endif //QUALITYCONTROL_INFRASTRUCTURESPEC_H
49 changes: 49 additions & 0 deletions Framework/include/QualityControl/InfrastructureSpecReader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// 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_INFRASTRUCTURESPECREADER_H
#define QUALITYCONTROL_INFRASTRUCTURESPECREADER_H

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

#include "QualityControl/InfrastructureSpec.h"
#include "QualityControl/TaskSpec.h"
#include "QualityControl/CommonSpec.h"
#include "QualityControl/DataSourceSpec.h"
#include <boost/property_tree/ptree_fwd.hpp>

namespace o2::quality_control::core
{

// If have to increase the performance of reading,
// we can probably improve it by writing a proper parser like for WorkflowSerializationHelpers in O2
// Also, move operators could be implemented.

class InfrastructureSpecReader
{
public:
/// \brief Reads the full QC configuration file.
// todo remove configurationSource when it is possible
static InfrastructureSpec readInfrastructureSpec(const boost::property_tree::ptree&, const std::string& configurationSource);

// readers for separate parts
static CommonSpec readCommonSpec(const boost::property_tree::ptree& config, const std::string& configurationSource);
static TaskSpec readTaskSpec(std::string taskName, const boost::property_tree::ptree& taskSpec, const std::string& configurationSource);
static DataSourceSpec readDataSourceSpec(const boost::property_tree::ptree& dataSourceSpec, const std::string& configurationSource);

static std::string validateDetectorName(std::string name);
};

} // namespace o2::quality_control::core

#endif //QUALITYCONTROL_INFRASTRUCTURESPECREADER_H
1 change: 0 additions & 1 deletion Framework/include/QualityControl/ObjectsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
// QC
#include "QualityControl/MonitorObject.h"
#include "QualityControl/MonitorObjectCollection.h"
#include "QualityControl/TaskConfig.h"
// stl
#include <string>
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions Framework/include/QualityControl/TaskFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// STL
#include <memory>
// QC
#include "QualityControl/TaskConfig.h"
#include "QualityControl/TaskRunnerConfig.h"
#include "QualityControl/TaskInterface.h"

namespace o2::quality_control::core
Expand All @@ -43,7 +43,7 @@ class TaskFactory
/// The TaskInterface actual class is decided based on the parameters passed.
/// \todo make it static ?
/// \author Barthelemy von Haller
TaskInterface* create(TaskConfig& taskConfig, std::shared_ptr<ObjectsManager> objectsManager);
TaskInterface* create(TaskRunnerConfig& taskConfig, std::shared_ptr<ObjectsManager> objectsManager);
};

} // namespace o2::quality_control::core
Expand Down
31 changes: 7 additions & 24 deletions Framework/include/QualityControl/TaskRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#ifndef QC_CORE_TASKRUNNER_H
#define QC_CORE_TASKRUNNER_H

#include <boost/property_tree/ptree.hpp>

// O2
#include <Common/Timer.h>
#include <Framework/Task.h>
Expand All @@ -30,7 +28,7 @@
#include <Headers/DataHeader.h>
#include <Framework/InitContext.h>
// QC
#include "QualityControl/TaskConfig.h"
#include "QualityControl/TaskRunnerConfig.h"
#include "QualityControl/TaskInterface.h"

namespace o2::configuration
Expand Down Expand Up @@ -75,7 +73,7 @@ class TaskRunner : public framework::Task
/// \param taskName - name of the task, which exists in tasks list in the configuration file
/// \param configurationSource - absolute path to configuration file, preceded with backend (f.e. "json://")
/// \param id - subSpecification for taskRunner's OutputSpec, useful to avoid outputs collisions one more complex topologies
TaskRunner(const std::string& taskName, const std::string& configurationSource, size_t id = 0);
TaskRunner(const TaskRunnerConfig& config);
~TaskRunner() override = default;

/// \brief TaskRunner's init callback
Expand All @@ -86,13 +84,10 @@ class TaskRunner : public framework::Task
/// \brief TaskRunner's completion policy callback
static framework::CompletionPolicy::CompletionOp completionPolicyCallback(o2::framework::InputSpan const& inputs);

std::string getDeviceName() { return mDeviceName; };
const framework::Inputs& getInputsSpecs() { return mInputSpecs; };
const framework::OutputSpec getOutputSpec() { return mMonitorObjectsSpec; };
const framework::Options getOptions() { return mOptions; };

/// \brief Makes TaskRunner invoke TaskInterface::reset() each n cycles. n = 0 means never.
void setResetAfterCycles(size_t n = 0);
std::string getDeviceName() const { return mTaskConfig.deviceName; };
const framework::Inputs& getInputsSpecs() const { return mTaskConfig.inputSpecs; };
const framework::OutputSpec& getOutputSpec() const { return mTaskConfig.moSpec; };
const framework::Options& getOptions() const { return mTaskConfig.options; };

/// \brief ID string for all TaskRunner devices
static std::string createTaskRunnerIdString();
Expand All @@ -114,7 +109,6 @@ class TaskRunner : public framework::Task

std::tuple<bool /*data ready*/, bool /*timer ready*/> validateInputs(const framework::InputRecord&);
void loadTaskConfig();
void loadTopologyConfig();
void startOfActivity();
void endOfActivity();
void startCycle();
Expand All @@ -124,24 +118,13 @@ class TaskRunner : public framework::Task
void saveToFile();

private:
std::string mDeviceName;
TaskConfig mTaskConfig;
std::shared_ptr<configuration::ConfigurationInterface> mConfigFile; // used in init only
TaskRunnerConfig mTaskConfig;
std::shared_ptr<monitoring::Monitoring> mCollector;
std::shared_ptr<TaskInterface> mTask;
size_t mResetAfterCycles = 0;
std::shared_ptr<ObjectsManager> mObjectsManager;
int mRunNumber;

std::string validateDetectorName(std::string name) const;
boost::property_tree::ptree getTaskConfigTree() const;
void updateMonitoringStats(framework::ProcessingContext& pCtx);
void computeRunNumber(const framework::ServiceRegistry& services);

// consider moving these to TaskConfig
framework::Inputs mInputSpecs;
framework::OutputSpec mMonitorObjectsSpec;
framework::Options mOptions;

bool mCycleOn = false;
bool mNoMoreCycles = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// or submit itself to any jurisdiction.

///
/// \file TaskConfig.h
/// \file TaskRunnerConfig.h
/// \author Barthelemy von Haller
///

Expand All @@ -19,23 +19,37 @@

#include <string>
#include <unordered_map>
#include <vector>

#include <Framework/DataProcessorSpec.h>

namespace o2::quality_control::core
{

/// \brief Container for the configuration of a Task
struct TaskConfig {
struct TaskRunnerConfig {
std::string deviceName;
std::string taskName;
std::string moduleName;
std::string className;
int cycleDurationSeconds;
int maxNumberCycles;
std::string consulUrl;
std::string conditionUrl = "";
std::string consulUrl{};
std::string conditionUrl{};
std::string monitoringUrl{};
framework::Inputs inputSpecs{};
framework::OutputSpec moSpec{ "XXX", "INVALID" };
framework::Options options{};
std::unordered_map<std::string, std::string> customParameters = {};
std::string detectorName = "MISC"; // intended to be the 3 letters code
int parallelTaskID = 0; // ID to differentiate parallel local Tasks from one another. 0 means this is the only one.
std::string saveToFile = "";
std::string saveToFile{};
int resetAfterCycles = 0;
bool infologgerFilterDiscardDebug = false;
int infologgerDiscardLevel = 21;
int activityType = 0;
int defaultRunNumber = 0;
std::string configurationSource{};
};

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