Skip to content
Open
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
11 changes: 6 additions & 5 deletions Framework/include/QualityControl/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,14 @@ class Actor
void init(framework::InitContext& ictx)
{
impl::handleExceptions("process", [&] {
// we set the fallback activity. fields might get overwritten once runtime values become available
mActivity = mServicesConfig.activity;
// we set the fallback activity and overwrite its fields with the runtime values which are already available.
// some fields (e.g. the run number) might get overwritten again at start.
mActivity = computeActivity(ictx.services(), mServicesConfig.activity);

initServices(ictx);
initDplCallbacks(ictx);

concreteActor().onInit(ictx);
concreteActor().onInit(ictx, mActivity);
});
}

Expand All @@ -157,7 +158,7 @@ class Actor

protected:
// mandatory methods to be implemented by concrete actor
void onInit(framework::InitContext&) = delete;
void onInit(framework::InitContext&, const Activity&) = delete;
void onProcess(framework::ProcessingContext&) = delete;

// mandatory methods to be implemented by concrete actor if specific features are enabled
Expand Down Expand Up @@ -210,7 +211,7 @@ class Actor
static_assert(std::derived_from<ConcreteActor, Actor<ConcreteActor>>);
// mandatory methods
static_assert(requires(ConcreteActor& actor, framework::ProcessingContext& pCtx) { { actor.onProcess(pCtx) } -> std::convertible_to<void>; });
static_assert(requires(ConcreteActor& actor, framework::InitContext& iCtx) { { actor.onInit(iCtx) } -> std::convertible_to<void>; });
static_assert(requires(ConcreteActor& actor, framework::InitContext& iCtx, const Activity& activity) { { actor.onInit(iCtx, activity) } -> std::convertible_to<void>; });

// mandatory if specific features are enabled
if constexpr (traits::sDetectorSpecific) {
Expand Down
2 changes: 1 addition & 1 deletion Framework/include/QualityControl/Aggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Aggregator
/**
* \brief Initialize the aggregator
*/
void init();
void init(const core::Activity& activity);

o2::quality_control::core::QualityObjectsType aggregate(core::QualityObjectsMapType& qoMap, const core::Activity& defaultActivity = {});

Expand Down
10 changes: 10 additions & 0 deletions Framework/include/QualityControl/AggregatorInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ class AggregatorInterface : public o2::quality_control::core::UserCodeInterface
/// @return The new qualities, associated with a name.
virtual std::map<std::string, core::Quality> aggregate(const core::QCInputs& data);

/// \brief Configure the object, called each time mCustomParameters is updated (including the first time).
///
/// This is the recommended method to override. The activity (e.g. run type and beam type) is provided so that
/// the custom parameters for the right run and beam type can be selected, e.g. with mCustomParameters.at("key", activity).
virtual void configure(const core::Activity& activity) override;

/// \brief Legacy variant of configure(const Activity&), which does not receive the activity.
/// It is still called by the default implementation of configure(const Activity&), so existing code keeps working.
virtual void configure() override;

virtual void startOfActivity(const core::Activity& activity);
virtual void endOfActivity(const core::Activity& activity);

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 @@ -142,7 +142,7 @@ class AggregatorRunner : public framework::Task
void initDatabase();
void initMonitoring();
void initLibraries();
void initAggregators();
void initAggregators(const core::Activity& activity);

/**
* Reorder the aggregators stored in mAggregators.
Expand Down
2 changes: 1 addition & 1 deletion Framework/include/QualityControl/Check.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Check
* \brief Initialize the check state
* Expected to run in the init phase of the FairDevice
*/
void init();
void init(const core::Activity& activity);
void reset();

core::QualityObjectsType check(std::map<std::string, std::shared_ptr<o2::quality_control::core::MonitorObject>>& moMap);
Expand Down
9 changes: 8 additions & 1 deletion Framework/include/QualityControl/CheckInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ class CheckInterface : public core::UserCodeInterface
virtual void endOfActivity(const core::Activity& activity); // not fully abstract because we don't want to change all the existing subclasses

protected:
/// \brief Called each time mCustomParameters is updated.
/// \brief Configure the object, called each time mCustomParameters is updated (including the first time).
///
/// This is the recommended method to override. The activity (e.g. run type and beam type) is provided so that
/// the custom parameters for the right run and beam type can be selected, e.g. with mCustomParameters.at("key", activity).
virtual void configure(const core::Activity& activity) override;

/// \brief Legacy variant of configure(const Activity&), which does not receive the activity.
/// It is still called by the default implementation of configure(const Activity&), so existing code keeps working.
virtual void configure() override;

/// \brief Retrieve a reference plot at the provided path, matching the give activity and for the provided run.
Expand Down
3 changes: 1 addition & 2 deletions Framework/include/QualityControl/LateTaskFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ class LateTaskFactory
{
auto* result = root_class_factory::create<LateTaskInterface>(taskConfig.moduleName, taskConfig.className);
result->setName(taskConfig.name);
result->setObjectsManager(objectsManager);
result->setCustomParameters(taskConfig.customParameters);
result->setObjectsManager(objectsManager); // fixme: we do it twice, here and in LateTaskRunner. pick one
result->setCcdbUrl(taskConfig.ccdbUrl);

return result;
Expand Down
9 changes: 8 additions & 1 deletion Framework/include/QualityControl/LateTaskInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,14 @@ class LateTaskInterface : public UserCodeInterface
/// Invoked at the reset() transition in synchronous mode and during workflow cleanup in asynchronous mode
virtual void reset() = 0;

/// \brief Called each time mCustomParameters is updated.
/// \brief Configure the object, called each time mCustomParameters is updated (including the first time).
///
/// This is the recommended method to override. The activity (e.g. run type and beam type) is provided so that
/// the custom parameters for the right run and beam type can be selected, e.g. with mCustomParameters.at("key", activity).
virtual void configure(const Activity& activity) override;

/// \brief Legacy variant of configure(const Activity&), which does not receive the activity.
/// It is still called by the default implementation of configure(const Activity&), so existing code keeps working.
virtual void configure() override;

// Setters and getters
Expand Down
2 changes: 1 addition & 1 deletion Framework/include/QualityControl/LateTaskRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class LateTaskRunner : public Actor<LateTaskRunner>

void onStart(framework::ServiceRegistryRef services, const Activity& activity);
void onStop(framework::ServiceRegistryRef services, const Activity& activity);
void onInit(framework::InitContext& iCtx);
void onInit(framework::InitContext& iCtx, const Activity& activity);
void onProcess(framework::ProcessingContext& pCtx);
void onEndOfStream(framework::EndOfStreamContext& eosContext, const Activity& activity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ class PostProcessingInterface : public core::UserCodeInterface

/// \brief Configure the task with custom parameters, optional for PostProcessingInterface
///
/// Users can use this method to configure their task with custom parameters
/// This is the recommended method to override. The activity (e.g. run type and beam type) is provided so that
/// the custom parameters for the right run and beam type can be selected, e.g. with mCustomParameters.at("key", activity).
/// For tasks running outside of DPL, the activity comes from the configuration file.
/// It is called each time mCustomParameters is updated, including the first time it is read.
virtual void configure(const core::Activity& activity) override;

/// \brief Legacy variant of configure(const Activity&), which does not receive the activity.
/// It is still called by the default implementation of configure(const Activity&), so existing code keeps working.
virtual void configure() override;

/// \brief Configuration of a post-processing task.
Expand Down
9 changes: 8 additions & 1 deletion Framework/include/QualityControl/TaskInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ class TaskInterface : public UserCodeInterface

virtual void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj);

/// \brief Called each time mCustomParameters is updated.
/// \brief Configure the object, called each time mCustomParameters is updated (including the first time).
///
/// This is the recommended method to override. The activity (e.g. run type and beam type) is provided so that
/// the custom parameters for the right run and beam type can be selected, e.g. with mCustomParameters.at("key", activity).
virtual void configure(const Activity& activity) override;

/// \brief Legacy variant of configure(const Activity&), which does not receive the activity.
/// It is still called by the default implementation of configure(const Activity&), so existing code keeps working.
virtual void configure() override;

// Setters and getters
Expand Down
19 changes: 18 additions & 1 deletion Framework/include/QualityControl/UserCodeInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <map>
#include <Rtypes.h>

#include "QualityControl/Activity.h"
#include "QualityControl/ConditionAccess.h"
#include "QualityControl/CustomParameters.h"
#include "QualityControl/DatabaseInterface.h"
Expand All @@ -39,14 +40,30 @@ class UserCodeInterface : public ConditionAccess
/// Destructor
virtual ~UserCodeInterface() = default;

void setCustomParameters(const CustomParameters& parameters);
/// \brief Set the custom parameters and configure the object.
///
/// Stores the parameters and calls configure(const Activity&).
/// \param parameters the custom parameters, which may differ depending on the run type and beam type
/// \param activity the activity known at a given time (e.g. providing run type and beam type for CustomParameters)
void setCustomParameters(const CustomParameters& parameters, const Activity& activity);

/// \brief Configure the object.
///
/// Users can use this method to configure their object.
/// It is called each time mCustomParameters is updated, including the first time it is read.
/// If the user needs the run type, the beam type or other activity fields to choose the right custom parameters,
/// they should override configure(const Activity&) instead.
virtual void configure() = 0;

/// \brief Configure the object, knowing the Activity.
///
/// Users can override this method to configure their object using the Activity which is known at initialization,
/// e.g. to retrieve values from mCustomParameters for the actual run type and beam type with
/// mCustomParameters.at("key", activity).
/// It is called each time mCustomParameters is updated, including the first time it is read.
/// The default implementation calls configure(), so overriding configure() alone remains valid.
virtual void configure(const Activity& activity);

const std::string& getName() const;
void setName(const std::string& name);
void setDatabase(std::unordered_map<std::string, std::string> dbConfig);
Expand Down
4 changes: 2 additions & 2 deletions Framework/src/Aggregator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ Aggregator::Aggregator(AggregatorConfig configuration) : mAggregatorConfig(std::
{
}

void Aggregator::init()
void Aggregator::init(const core::Activity& activity)
{
try {
ILOG(Info, Devel) << "Instantiating the user code for aggregator " << mAggregatorConfig.name
<< " (" << mAggregatorConfig.moduleName << ", " << mAggregatorConfig.className << ")" << ENDM;
mAggregatorInterface =
root_class_factory::create<AggregatorInterface>(mAggregatorConfig.moduleName, mAggregatorConfig.className);
mAggregatorInterface->setName(mAggregatorConfig.name);
mAggregatorInterface->setCustomParameters(mAggregatorConfig.customParameters);
mAggregatorInterface->setCustomParameters(mAggregatorConfig.customParameters, activity);
mAggregatorInterface->setCcdbUrl(mAggregatorConfig.ccdbUrl);
mAggregatorInterface->setDatabase(mAggregatorConfig.repository);
mAggregatorInterface->configure();
Expand Down
11 changes: 11 additions & 0 deletions Framework/src/AggregatorInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ std::map<std::string, core::Quality> AggregatorInterface::aggregate(const core::
return {};
}

void AggregatorInterface::configure(const Activity& activity)
{
// calls the legacy variant, so that user code overriding only that one keeps working
configure();
}

void AggregatorInterface::configure()
{
// noop, override it if you want.
}

void AggregatorInterface::startOfActivity(const Activity& activity)
{
// noop, override it if you want.
Expand Down
7 changes: 4 additions & 3 deletions Framework/src/AggregatorRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,15 @@ void AggregatorRunner::init(framework::InitContext& iCtx)
Bookkeeping::getInstance().init(mRunnerConfig.bookkeepingUrl);

try {
const auto activity = computeActivity(iCtx.services(), mRunnerConfig.fallbackActivity);
initLibraries(); // we have to load libraries before we load ConfigurableParams, otherwise the corresponding ROOT dictionaries won't be found
// load config params
if (!ConfigParamGlo::keyValues.empty()) {
conf::ConfigurableParam::updateFromString(ConfigParamGlo::keyValues);
}
initDatabase();
initMonitoring();
initAggregators();
initAggregators(activity);
} catch (...) {
ILOG(Fatal) << "Unexpected exception during initialization: "
<< current_diagnostic(true) << ENDM;
Expand Down Expand Up @@ -240,7 +241,7 @@ void AggregatorRunner::initMonitoring()
mTimer.reset(1000000); // 10 s.
}

void AggregatorRunner::initAggregators()
void AggregatorRunner::initAggregators(const core::Activity& activity)
{
ILOG(Info, Devel) << "Initialization of the aggregators" << ENDM;

Expand All @@ -249,7 +250,7 @@ void AggregatorRunner::initAggregators()
ILOG(Info, Devel) << ">> Aggregator name : " << aggregatorConfig.name << ENDM;
try {
auto aggregator = make_shared<Aggregator>(aggregatorConfig);
aggregator->init();
aggregator->init(activity);
mUpdatePolicyManager.addPolicy(aggregator->getName(),
aggregator->getUpdatePolicyType(),
aggregator->getObjectsNames(),
Expand Down
4 changes: 2 additions & 2 deletions Framework/src/Check.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ Check::Check(CheckConfig config)
{
}

void Check::init()
void Check::init(const core::Activity& activity)
{
try {
mCheckInterface = root_class_factory::create<CheckInterface>(mCheckConfig.moduleName, mCheckConfig.className);
mCheckInterface->setName(mCheckConfig.name);
mCheckInterface->setDatabase(mCheckConfig.repository);
mCheckInterface->setCustomParameters(mCheckConfig.customParameters);
mCheckInterface->setCustomParameters(mCheckConfig.customParameters, activity);
mCheckInterface->setCcdbUrl(mCheckConfig.ccdbUrl);
} catch (...) {
std::string diagnostic = boost::current_exception_diagnostic_information();
Expand Down
6 changes: 6 additions & 0 deletions Framework/src/CheckInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ core::Quality CheckInterface::check(const core::QCInputs& data)
return core::Quality{};
};

void CheckInterface::configure(const core::Activity& activity)
{
// calls the legacy variant, so that user code overriding only that one keeps working
configure();
}

void CheckInterface::configure()
{
// noop, override it if you want.
Expand Down
4 changes: 3 additions & 1 deletion Framework/src/CheckRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ void CheckRunner::init(framework::InitContext& iCtx)
iCtx.services().get<CallbackService>().set<CallbackService::Id::Reset>([this]() { reset(); });
iCtx.services().get<CallbackService>().set<CallbackService::Id::Stop>([this]() { stop(); });

const auto activity = computeActivity(iCtx.services(), mConfig.fallbackActivity);

updatePolicyManager.reset();
for (auto& [checkName, check] : mChecks) {
check.init();
check.init(activity);
updatePolicyManager.addPolicy(check.getName(), check.getUpdatePolicyType(), check.getObjectsNames(), check.getAllObjectsOption(), false);
}
} catch (...) {
Expand Down
6 changes: 6 additions & 0 deletions Framework/src/LateTaskInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ void LateTaskInterface::finaliseCCDB(framework::ConcreteDataMatcher& matcher, vo
{
}
*/
void LateTaskInterface::configure(const Activity& activity)
{
// calls the legacy variant, so that user code overriding only that one keeps working
configure();
}

void LateTaskInterface::configure()
{
// noop, override it if you want.
Expand Down
3 changes: 2 additions & 1 deletion Framework/src/LateTaskRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ LateTaskRunner::LateTaskRunner(const ServicesConfig& servicesConfig, const LateT
{
}

void LateTaskRunner::onInit(InitContext& iCtx)
void LateTaskRunner::onInit(InitContext& iCtx, const Activity& activity)
{
// setup publisher
mObjectsManager = std::make_shared<ObjectsManager>(mTaskConfig.name, mTaskConfig.className, mTaskConfig.detectorName, 0);
Expand All @@ -56,6 +56,7 @@ void LateTaskRunner::onInit(InitContext& iCtx)

// init user's task
mTask->setObjectsManager(mObjectsManager);
mTask->setCustomParameters(mTaskConfig.customParameters, activity);
mTask->initialize(iCtx);
}

Expand Down
1 change: 0 additions & 1 deletion Framework/src/PostProcessingFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace o2::quality_control::postprocessing
PostProcessingInterface* PostProcessingFactory::create(const PostProcessingConfig& config)
{
auto* result = root_class_factory::create<PostProcessingInterface>(config.moduleName, config.className);
result->setCustomParameters(config.customParameters);
result->setDatabase(config.repository);
return result;
}
Expand Down
6 changes: 6 additions & 0 deletions Framework/src/PostProcessingInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ void PostProcessingInterface::configure(const boost::property_tree::ptree& confi
{
}

void PostProcessingInterface::configure(const core::Activity& activity)
{
// calls the legacy variant, so that user code overriding only that one keeps working
configure();
}

void PostProcessingInterface::configure()
{
}
Expand Down
2 changes: 1 addition & 1 deletion Framework/src/PostProcessingRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void PostProcessingRunner::init(const PostProcessingRunnerConfig& runnerConfig,
mTask->setObjectsManager(mObjectManager);
mTask->setID(mTaskConfig.id);
mTask->setName(mTaskConfig.taskName);
mTask->setCustomParameters(mTaskConfig.customParameters);
mTask->setCustomParameters(mTaskConfig.customParameters, mTaskConfig.activity);
mTask->setCcdbUrl(mTaskConfig.ccdbUrl);
mTask->configure(mRunnerConfig.configTree);
} else {
Expand Down
1 change: 0 additions & 1 deletion Framework/src/TaskFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ TaskInterface* TaskFactory::create(const TaskRunnerConfig& taskConfig, std::shar
auto* result = root_class_factory::create<TaskInterface>(taskConfig.moduleName, taskConfig.className);
result->setName(taskConfig.name);
result->setObjectsManager(objectsManager);
result->setCustomParameters(taskConfig.customParameters);
result->setCcdbUrl(taskConfig.ccdbUrl);

return result;
Expand Down
6 changes: 6 additions & 0 deletions Framework/src/TaskInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ void TaskInterface::finaliseCCDB(framework::ConcreteDataMatcher& matcher, void*
{
}

void TaskInterface::configure(const Activity& activity)
{
// calls the legacy variant, so that user code overriding only that one keeps working
configure();
}

void TaskInterface::configure()
{
// noop, override it if you want.
Expand Down
Loading
Loading