forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QC-47 * Added dependency on O2 (alidist will need to be updated as well - i will create PR shortly) * Created TaskDataProcessor class, which executes user modules similarly to TaskDevice, but using DPL and O2 Data Model. * Created TaskDataProcessorFactory, which generates DataProcessorSpec of QC task. * Created TaskInterfaceDPL, similar to TaskInterface, to be inherited by user modules. * Moved Activity class to separate file, because it is used by two different classes from now on. * Moved implementation of TaskFactory.create to header and made it a template - now it can be used to get both TaskInterface or TaskInterfaceDPL children. * Created TaskDPL - exemplary workflow using QC/DPL Task * Created SkeletonDPL - exemplary user module
- Loading branch information
1 parent
15c4ad4
commit b20df41
Showing
27 changed files
with
1,195 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/// | ||
/// \file Activity.h | ||
/// \author Barthelemy von Haller | ||
/// | ||
|
||
#ifndef QUALITYCONTROL_CORE_ACTIVITY_H | ||
#define QUALITYCONTROL_CORE_ACTIVITY_H | ||
|
||
namespace o2 { | ||
namespace quality_control { | ||
namespace core { | ||
|
||
/// \brief Dummy class that should be removed when there is the official one. | ||
/// This corresponds to a Run1/2 "run". | ||
/// \author Barthelemy von Haller | ||
class Activity | ||
{ | ||
public: | ||
Activity() = default; | ||
Activity(int id, int type) : mId(id), mType(type) | ||
{} | ||
/// Copy constructor | ||
Activity (const Activity& other) = default; | ||
/// Move constructor | ||
Activity (Activity&& other) noexcept = default; | ||
/// Copy assignment operator | ||
Activity& operator= (const Activity& other) = default; | ||
/// Move assignment operator | ||
Activity& operator= (Activity&& other) noexcept = default; | ||
|
||
virtual ~Activity() = default; | ||
|
||
int mId{0}; | ||
int mType{0}; | ||
}; | ||
|
||
} // namespace core | ||
} // namespace QualityControl | ||
} // namespace o2 | ||
|
||
#endif // QUALITYCONTROL_CORE_ACTIVITY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/// | ||
/// \file TaskDataProcessor.h | ||
/// \author Piotr Konopka | ||
/// | ||
|
||
#ifndef TASKDATAPROCESSOR_H | ||
#define TASKDATAPROCESSOR_H | ||
|
||
#include <thread> | ||
#include <mutex> | ||
// boost (should be first but then it makes errors in fairmq) | ||
#include <boost/serialization/array_wrapper.hpp> | ||
#include <boost/accumulators/accumulators.hpp> | ||
#include <boost/accumulators/statistics.hpp> | ||
#include <boost/asio.hpp> | ||
// O2 | ||
#include "Common/Timer.h" | ||
#include "Configuration/ConfigurationInterface.h" | ||
#include "Framework/DataProcessorSpec.h" | ||
#include "Monitoring/MonitoringFactory.h" | ||
// QC | ||
#include "QualityControl/TaskInterfaceDPL.h" | ||
#include "QualityControl/TaskConfig.h" | ||
|
||
namespace ba = boost::accumulators; | ||
|
||
namespace o2 { | ||
namespace quality_control { | ||
namespace core { | ||
|
||
using namespace o2::framework; | ||
using namespace std::chrono; | ||
|
||
/// \brief A class driving the execution of a QC task inside DPL. | ||
/// | ||
/// TaskDataProcessor is a port of TaskDevice class, adapted for usage inside Data Processing Layer. | ||
/// It is responsible for retrieving details about the task via the Configuration system and the Task (indirectly). | ||
/// It then steers the execution of the task and provides it with O2 Data Model data, provided by framework. | ||
/// It finally publishes the MonitorObjects owned and filled by the QC task and managed by the ObjectsManager. | ||
/// Usage: | ||
/// \code{.cxx} | ||
/// auto qcTask = std::make_shared<TaskDataProcessor>(taskName, configurationSource); | ||
/// DataProcessorSpec newTask{ | ||
/// taskName, | ||
/// qcTask->getInputsSpecs(), | ||
/// Outputs{ qcTask->getOutputSpec() }, | ||
/// AlgorithmSpec{ | ||
/// (AlgorithmSpec::InitCallback) [qcTask = std::move(qcTask)](InitContext& initContext) { | ||
/// | ||
/// qcTask->initCallback(initContext); | ||
/// | ||
/// return (AlgorithmSpec::ProcessCallback) [qcTask = std::move(qcTask)] (ProcessingContext &processingContext) { | ||
/// qcTask->processCallback(processingContext); | ||
/// }; | ||
/// } | ||
/// } | ||
/// }; | ||
/// \endcode | ||
/// | ||
/// \author Piotr Konopka | ||
/// \author Barthelemy von Haller | ||
class TaskDataProcessor { | ||
public: | ||
TaskDataProcessor(std::string taskName, std::string configurationSource); | ||
~TaskDataProcessor(); | ||
|
||
/// \brief To be invoked during initialization of Data Processor | ||
void initCallback(InitContext& iCtx); | ||
/// \brief To be invoked inside Data Processor's main ProcessCallback | ||
void processCallback(ProcessingContext& pCtx); | ||
/// \brief To be invoked inside Data Processor's TimerCallback | ||
void timerCallback(ProcessingContext& pCtx); | ||
|
||
const Inputs& getInputsSpecs() { return mInputSpecs; }; | ||
const OutputSpec getOutputSpec() { return mMonitorObjectsSpec; }; | ||
|
||
private: | ||
void populateConfig(std::string taskName); | ||
void startOfActivity(); | ||
void endOfActivity(); | ||
void finishCycle(DataAllocator& outputs); | ||
unsigned long publish(DataAllocator& outputs); | ||
static void CustomCleanupTMessage(void* data, void* object); | ||
|
||
private: | ||
std::string mTaskName; | ||
TaskConfig mTaskConfig; | ||
std::shared_ptr<o2::configuration::ConfigurationInterface> mConfigFile; // used in init only | ||
std::shared_ptr<o2::monitoring::Monitoring> mCollector; | ||
TaskInterfaceDPL* mTask; | ||
std::shared_ptr<ObjectsManager> mObjectsManager; | ||
std::recursive_mutex mTaskMutex; // \todo should be plain mutex, when timer callback is implemented in dpl | ||
|
||
// consider moving these two to TaskConfig | ||
Inputs mInputSpecs; | ||
OutputSpec mMonitorObjectsSpec; | ||
|
||
int mNumberBlocks; | ||
int mLastNumberObjects; | ||
bool mCycleOn; | ||
int mCycleNumber; | ||
|
||
// stats | ||
AliceO2::Common::Timer mStatsTimer; | ||
int mTotalNumberObjectsPublished; | ||
AliceO2::Common::Timer mTimerTotalDurationActivity; | ||
ba::accumulator_set<double, ba::features<ba::tag::mean, ba::tag::variance>> mPCpus; | ||
ba::accumulator_set<double, ba::features<ba::tag::mean, ba::tag::variance>> mPMems; | ||
}; | ||
|
||
} | ||
} | ||
} | ||
|
||
#endif // TASKDATAPROCESSOR_H |
29 changes: 29 additions & 0 deletions
29
Framework/include/QualityControl/TaskDataProcessorFactory.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/// | ||
/// \file TaskDataProcessorFactory.h | ||
/// \author Piotr Konopka | ||
/// | ||
|
||
#ifndef PROJECT_TASKDATAPROCESSORFACTORY_H | ||
#define PROJECT_TASKDATAPROCESSORFACTORY_H | ||
|
||
#include "Framework/DataProcessorSpec.h" | ||
|
||
namespace o2 { | ||
namespace quality_control { | ||
namespace core { | ||
|
||
/// \brief Factory in charge of creating DataProcessorSpec of QC task | ||
class TaskDataProcessorFactory | ||
{ | ||
public: | ||
TaskDataProcessorFactory(); | ||
virtual ~TaskDataProcessorFactory(); | ||
|
||
o2::framework::DataProcessorSpec create(std::string taskName, std::string configurationSource); | ||
}; | ||
|
||
} // namespace core | ||
} // namespace QualityControl | ||
} // namespace o2 | ||
|
||
#endif //PROJECT_TASKDATAPROCESSORFACTORY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.