Skip to content

Commit 97d1b30

Browse files
BarthelemyBarthelemy von Haller
andauthored
[QC-1083] Introduce a start/end of activity method in checkInterface … (#2082)
* [QC-1083] Introduce a start/end of activity method in checkInterface and aggregatorInterface * fix test * fix * fix * remove activity from interface * fix for detectors * fix * fix * format --------- Co-authored-by: Barthelemy von Haller <bvonhall@cern.ch>
1 parent 2455065 commit 97d1b30

19 files changed

Lines changed: 129 additions & 51 deletions

Framework/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ add_library(O2QualityControl
4646
src/CheckRunnerFactory.cxx
4747
src/AggregatorRunnerFactory.cxx
4848
src/CheckInterface.cxx
49+
src/AggregatorInterface.cxx
4950
src/DatabaseFactory.cxx
5051
src/CcdbDatabase.cxx
5152
src/QcInfoLogger.cxx

Framework/include/QualityControl/Aggregator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class Aggregator
7575
std::vector<AggregatorSource> getSources() const;
7676
std::vector<AggregatorSource> getSources(core::DataSourceType type);
7777
const std::string& getDetector() const { return mAggregatorConfig.detectorName; };
78-
void setActivity(std::shared_ptr<core::Activity> activity);
78+
void startOfActivity(const core::Activity& activity);
79+
void endOfActivity(const core::Activity& activity);
7980

8081
static AggregatorConfig extractConfig(const core::CommonSpec&, const AggregatorSpec&);
8182

Framework/include/QualityControl/AggregatorInterface.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
#ifndef QC_CHECKER_AGGREGATORINTERFACE_H
1818
#define QC_CHECKER_AGGREGATORINTERFACE_H
1919

20-
#include <unordered_map>
2120
#include <map>
2221

2322
#include "QualityControl/QualityObject.h"
2423
#include "QualityControl/UserCodeInterface.h"
2524
#include "QualityControl/Quality.h"
25+
#include "QualityControl/Activity.h"
2626

2727
namespace o2::quality_control::checker
2828
{
@@ -42,15 +42,12 @@ class AggregatorInterface : public o2::quality_control::core::UserCodeInterface
4242
///
4343
/// @param qoMap A map of the the QualityObjects to aggregate and their full names.
4444
/// @return The new qualities, associated with a name.
45-
virtual std::map<std::string, o2::quality_control::core::Quality> aggregate(std::map<std::string, std::shared_ptr<const o2::quality_control::core::QualityObject>>& qoMap) = 0;
45+
virtual std::map<std::string, core::Quality> aggregate(std::map<std::string, std::shared_ptr<const core::QualityObject>>& qoMap) = 0;
4646

47-
void setActivity(std::shared_ptr<core::Activity> activity) { mActivity = activity; }
48-
std::shared_ptr<const core::Activity> getActivity() const { return mActivity; }
47+
virtual void startOfActivity(const core::Activity& activity);
48+
virtual void endOfActivity(const core::Activity& activity);
4949

50-
private:
51-
std::shared_ptr<core::Activity> mActivity; // TODO should probably go to UserCodeInterface
52-
53-
ClassDef(AggregatorInterface, 3)
50+
ClassDef(AggregatorInterface, 4)
5451
};
5552

5653
} // namespace o2::quality_control::checker

Framework/include/QualityControl/Check.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class Check
6969
o2::framework::Inputs getInputs() const { return mCheckConfig.inputSpecs; };
7070
const std::string& getDetector() const { return mCheckConfig.detectorName; };
7171
const CheckConfig& getConfig() const { return mCheckConfig; };
72-
void setActivity(std::shared_ptr<core::Activity> activity);
72+
void startOfActivity(const core::Activity& activity);
73+
void endOfActivity(const core::Activity& activity);
7374

7475
//TODO: Unique Input string
7576
static o2::header::DataDescription createCheckDataDescription(const std::string& checkName);

Framework/include/QualityControl/CheckInterface.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
#include "QualityControl/Quality.h"
2121
#include "QualityControl/UserCodeInterface.h"
22+
#include "QualityControl/Activity.h"
2223

2324
namespace o2::quality_control::core
2425
{
2526
class Activity;
2627
class MonitorObject;
2728
}
2829

29-
// todo: do not expose other namespaces in headers
3030
using namespace o2::quality_control::core;
3131

3232
namespace o2::quality_control::checker
@@ -35,7 +35,7 @@ namespace o2::quality_control::checker
3535
/// \brief Skeleton of a check.
3636
///
3737
/// \author Barthelemy von Haller
38-
class CheckInterface : public UserCodeInterface
38+
class CheckInterface : public core::UserCodeInterface
3939
{
4040
public:
4141
/// Default constructor
@@ -47,7 +47,7 @@ class CheckInterface : public UserCodeInterface
4747
///
4848
/// @param moMap A map of the the MonitorObjects to check and their full names.
4949
/// @return The quality associated with these objects.
50-
virtual core::Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) = 0;
50+
virtual core::Quality check(std::map<std::string, std::shared_ptr<core::MonitorObject>>* moMap) = 0;
5151

5252
/// \brief Modify the aspect of the plot.
5353
///
@@ -76,20 +76,17 @@ class CheckInterface : public UserCodeInterface
7676
/// If the class does not override it, we return "TObject".
7777
virtual std::string getAcceptedType();
7878

79-
void setActivity(std::shared_ptr<core::Activity> activity) { mActivity = activity; }
80-
std::shared_ptr<const core::Activity> getActivity() const { return mActivity; }
81-
8279
bool isObjectCheckable(const std::shared_ptr<core::MonitorObject> mo);
8380
bool isObjectCheckable(const core::MonitorObject* mo);
8481

82+
virtual void startOfActivity(const core::Activity& activity); // not fully abstract because we don't want to change all the existing subclasses
83+
virtual void endOfActivity(const core::Activity& activity); // not fully abstract because we don't want to change all the existing subclasses
84+
8585
protected:
8686
/// \brief Called each time mCustomParameters is updated.
8787
virtual void configure() override;
8888

89-
private:
90-
std::shared_ptr<core::Activity> mActivity;
91-
92-
ClassDef(CheckInterface, 5)
89+
ClassDef(CheckInterface, 6)
9390
};
9491

9592
} // namespace o2::quality_control::checker

Framework/src/Aggregator.cxx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,21 @@ AggregatorConfig Aggregator::extractConfig(const core::CommonSpec& commonSpec, c
224224
};
225225
}
226226

227-
void Aggregator::setActivity(std::shared_ptr<core::Activity> activity)
227+
void Aggregator::startOfActivity(const core::Activity& activity)
228228
{
229229
if (mAggregatorInterface) {
230-
mAggregatorInterface->setActivity(std::move(activity));
230+
mAggregatorInterface->startOfActivity(activity);
231231
} else {
232-
throw std::runtime_error("Trying to set Activity on an empty AggregatorInterface '" + mAggregatorConfig.name + "'");
232+
throw std::runtime_error("Trying to start an Activity on an empty AggregatorInterface '" + mAggregatorConfig.name + "'");
233+
}
234+
}
235+
236+
void Aggregator::endOfActivity(const core::Activity& activity)
237+
{
238+
if (mAggregatorInterface) {
239+
mAggregatorInterface->endOfActivity(activity);
240+
} else {
241+
throw std::runtime_error("Trying to end an Activity on an empty AggregatorInterface '" + mAggregatorConfig.name + "'");
233242
}
234243
}
235244

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
///
13+
/// \file AggregatorInterface.cxx
14+
/// \author Barthelemy von Haller
15+
///
16+
17+
#include "QualityControl/AggregatorInterface.h"
18+
19+
using namespace std;
20+
using namespace o2::quality_control::core;
21+
22+
namespace o2::quality_control::checker
23+
{
24+
25+
void AggregatorInterface::startOfActivity(const Activity& activity)
26+
{
27+
// noop, override it if you want.
28+
}
29+
30+
void AggregatorInterface::endOfActivity(const Activity& activity)
31+
{
32+
// noop, override it if you want.
33+
}
34+
35+
} // namespace o2::quality_control::checker

Framework/src/AggregatorRunner.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ void AggregatorRunner::start(ServiceRegistryRef services)
400400
QcInfoLogger::setPartition(mActivity->mPartitionName);
401401
ILOG(Info, Support) << "Starting run " << mActivity->mId << ENDM;
402402
for (auto& aggregator : mAggregators) {
403-
aggregator->setActivity(mActivity);
403+
aggregator->startOfActivity(*mActivity);
404404
}
405405

406406
// register ourselves to the BK
@@ -417,6 +417,9 @@ void AggregatorRunner::start(ServiceRegistryRef services)
417417
void AggregatorRunner::stop()
418418
{
419419
ILOG(Info, Support) << "Stopping run " << mActivity->mId << ENDM;
420+
for (auto& aggregator : mAggregators) {
421+
aggregator->endOfActivity(*mActivity);
422+
}
420423
}
421424

422425
void AggregatorRunner::reset()

Framework/src/Check.cxx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "QualityControl/QcInfoLogger.h"
3131
#include "QualityControl/Quality.h"
3232

33+
#include <QualityControl/AggregatorRunner.h>
34+
3335
using namespace AliceO2::Common;
3436
using namespace AliceO2::InfoLogger;
3537

@@ -268,12 +270,21 @@ framework::OutputSpec Check::createOutputSpec(const std::string& checkName)
268270
return { "QC", createCheckDataDescription(checkName), 0, framework::Lifetime::Sporadic };
269271
}
270272

271-
void Check::setActivity(std::shared_ptr<core::Activity> activity)
273+
void Check::startOfActivity(const core::Activity& activity)
274+
{
275+
if (mCheckInterface) {
276+
mCheckInterface->startOfActivity(activity);
277+
} else {
278+
throw std::runtime_error("Trying to start an Activity on an empty CheckInterface '" + mCheckConfig.name + "'");
279+
}
280+
}
281+
282+
void Check::endOfActivity(const core::Activity& activity)
272283
{
273284
if (mCheckInterface) {
274-
mCheckInterface->setActivity(std::move(activity));
285+
mCheckInterface->endOfActivity(activity);
275286
} else {
276-
throw std::runtime_error("Trying to set Activity on an empty CheckInterface '" + mCheckConfig.name + "'");
287+
throw std::runtime_error("Trying to stop an Activity on an empty CheckInterface '" + mCheckConfig.name + "'");
277288
}
278289
}
279290

Framework/src/CheckInterface.cxx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919

2020
#include <TClass.h>
2121

22-
ClassImp(o2::quality_control::checker::CheckInterface)
23-
24-
using namespace std;
22+
using namespace std;
23+
using namespace o2::quality_control::core;
2524

2625
namespace o2::quality_control::checker
2726
{
@@ -50,4 +49,14 @@ void CheckInterface::reset()
5049
// noop, override it if you want.
5150
}
5251

52+
void CheckInterface::startOfActivity(const Activity& activity)
53+
{
54+
// noop, override it if you want.
55+
}
56+
57+
void CheckInterface::endOfActivity(const Activity& activity)
58+
{
59+
// noop, override it if you want.
60+
}
61+
5362
} // namespace o2::quality_control::checker

0 commit comments

Comments
 (0)