Skip to content

Commit 891a040

Browse files
justonedev1Michal Tichák
andauthored
QC-1086 Replaying postprocessing with foreachobject trigger does not produce valid results (#2582)
* QC-1086 added cycles to MOs and QOs * fixup! QC-1086 added cycles to MOs and QOs * QC-1086 added cycle handling to Aggregators * fixup! QC-1086 added cycle handling to Aggregators --------- Co-authored-by: Michal Tichák <michal.tichak@cern.ch>
1 parent fad5075 commit 891a040

31 files changed

+385
-45
lines changed

Framework/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ configure_file("include/QualityControl/Version.h.in"
55
"${CMAKE_CURRENT_BINARY_DIR}/include/QualityControl/Version.h"
66
@ONLY)
77

8-
# ---- Library for IL ----
8+
# ---- Library for IL ----
99
add_library(O2QualityControlInfoLogger STATIC
1010
src/QcInfoLogger.cxx
1111
)
@@ -135,7 +135,8 @@ add_library(O2QualityControl
135135
src/RootFileStorage.cxx
136136
src/ReductorHelpers.cxx
137137
src/KafkaPoller.cxx
138-
src/FlagHelpers.cxx)
138+
src/FlagHelpers.cxx
139+
src/ObjectMetadataHelpers.cxx)
139140

140141
target_include_directories(
141142
O2QualityControl
@@ -263,7 +264,7 @@ endforeach()
263264

264265
# ---- Tests ----
265266

266-
add_executable(o2-qc-test-core
267+
add_executable(o2-qc-test-core
267268
test/testActivity.cxx
268269
test/testActivityHelpers.cxx
269270
test/testAggregatorInterface.cxx
@@ -353,7 +354,7 @@ foreach(i RANGE ${count})
353354
get_filename_component(test_name ${test} NAME)
354355
string(REGEX REPLACE ".cxx" "" test_name ${test_name})
355356
string(REPLACE " " ";" arg "${arg}") # make list of string (arguments) out of
356-
# one string
357+
# one string
357358

358359
add_executable(${test_name} ${test})
359360
set_property(TARGET ${test_name}

Framework/include/QualityControl/CcdbDatabase.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,14 @@ class CcdbDatabase : public DatabaseInterface
7676
const std::string& createdNotAfter = "", const std::string& createdNotBefore = "") override;
7777

7878
// retrieval - MO - deprecated
79-
std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string objectPath, std::string objectName, long timestamp = Timestamp::Current, const core::Activity& activity = {}) override;
79+
std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string objectPath, std::string objectName,
80+
long timestamp = Timestamp::Current,
81+
const core::Activity& activity = {},
82+
const std::map<std::string, std::string>& metadata = {}) override;
8083
// retrieval - QO - deprecated
81-
std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string qoPath, long timestamp = Timestamp::Current, const core::Activity& activity = {}) override;
84+
std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string qoPath, long timestamp = Timestamp::Current,
85+
const core::Activity& activity = {},
86+
const std::map<std::string, std::string>& metadata = {}) override;
8287

8388
// retrieval - general
8489
std::string retrieveJson(std::string path, long timestamp, const std::map<std::string, std::string>& metadata) override;
@@ -91,10 +96,10 @@ class CcdbDatabase : public DatabaseInterface
9196
static long getCurrentTimestamp();
9297
static long getFutureTimestamp(int secondsInFuture);
9398
/**
94-
* Return the listing of folder and/or objects in the subpath.
95-
* @param subpath The folder we want to list the children of.
96-
* @return The listing of folder and/or objects at the subpath.
97-
*/
99+
* Return the listing of folder and/or objects in the subpath.
100+
* @param subpath The folder we want to list the children of.
101+
* @return The listing of folder and/or objects at the subpath.
102+
*/
98103
std::vector<std::string> getListing(const std::string& subpath = "");
99104

100105
/**

Framework/include/QualityControl/DatabaseInterface.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,24 @@ class DatabaseInterface
133133
* @param objectName Name of the object
134134
* @param timestamp Timestamp of the object in ms since epoch
135135
* @param activity Activity of the object
136+
* @param metadata additional metadata to filter objects during retrieval
136137
* @deprecated
137138
*/
138-
virtual std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string objectPath, std::string objectName, long timestamp = Timestamp::Current, const core::Activity& activity = {}) = 0;
139+
virtual std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string objectPath, std::string objectName,
140+
long timestamp = Timestamp::Current, const core::Activity& activity = {},
141+
const std::map<std::string, std::string>& metadata = {}) = 0;
139142
/**
140143
* \brief Look up a quality object and return it.
141144
* Look up a quality object and return it if found or nullptr if not.
142145
* @param qoPath Path of the object without the provenance prefix
143146
* @param timestamp Timestamp of the object in ms since epoch
144147
* @param activity Activity of the object
148+
* @param metadata additional metadata to filter objects during retrieval
145149
* @deprecated
146150
*/
147-
virtual std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string qoPath, long timestamp = Timestamp::Current, const core::Activity& activity = {}) = 0;
151+
virtual std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string qoPath, long timestamp = Timestamp::Current,
152+
const core::Activity& activity = {},
153+
const std::map<std::string, std::string>& metadata = {}) = 0;
148154

149155
/**
150156
* \brief Look up an object and return it.

Framework/include/QualityControl/DummyDatabase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class DummyDatabase : public DatabaseInterface
3535
std::string const& detectorName, std::string const& taskName, long from = -1, long to = -1) override;
3636
// MonitorObject
3737
void storeMO(std::shared_ptr<const o2::quality_control::core::MonitorObject> q) override;
38-
std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string taskName, std::string objectName, long timestamp = -1, const core::Activity& activity = {}) override;
38+
std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string taskName, std::string objectName, long timestamp = -1, const core::Activity& activity = {}, const std::map<std::string, std::string>& metadata = {}) override;
3939
// QualityObject
4040
void storeQO(std::shared_ptr<const o2::quality_control::core::QualityObject> q) override;
41-
std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string checkerName, long timestamp = -1, const core::Activity& activity = {}) override;
41+
std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string checkerName, long timestamp = -1, const core::Activity& activity = {}, const std::map<std::string, std::string>& metadata = {}) override;
4242

4343
// General
4444
void* retrieveAny(std::type_info const& tinfo, std::string const& path,

Framework/include/QualityControl/MonitorObject.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define QC_CORE_MONITOROBJECT_H
1919

2020
// std
21+
#include <optional>
2122
#include <string>
2223
#include <map>
2324
// ROOT
@@ -113,6 +114,8 @@ class MonitorObject : public TObject
113114
const std::map<std::string, std::string>& getMetadataMap() const;
114115
/// \brief Update the value of metadata or add it if it does not exist yet.
115116
void addOrUpdateMetadata(std::string key, std::string value);
117+
/// \brief Get metadata value of given key, returns std::nullopt if none exists;
118+
std::optional<std::string> getMetadata(const std::string& key);
116119

117120
void Draw(Option_t* option) override;
118121
TObject* DrawClone(Option_t* option) const override;
@@ -146,7 +149,7 @@ class MonitorObject : public TObject
146149
void releaseObject();
147150
void cloneAndSetObject(const MonitorObject&);
148151

149-
ClassDefOverride(MonitorObject, 13);
152+
ClassDefOverride(MonitorObject, 14);
150153
};
151154

152155
} // namespace o2::quality_control::core

Framework/include/QualityControl/MonitorObjectCollection.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ class MonitorObjectCollection : public TObjArray, public mergers::MergeInterface
4040
void setTaskName(const std::string&);
4141
const std::string& getTaskName() const;
4242

43+
void addOrUpdateMetadata(const std::string& key, const std::string& value);
44+
4345
MergeInterface* cloneMovingWindow() const override;
4446

4547
private:
4648
std::string mDetector = "TST";
4749
std::string mTaskName = "Test";
4850

49-
ClassDefOverride(MonitorObjectCollection, 2);
51+
ClassDefOverride(MonitorObjectCollection, 3);
5052
};
5153

5254
} // namespace o2::quality_control::core
5355

54-
#endif //QUALITYCONTROL_MONITOROBJECTCOLLECTION_H
56+
#endif // QUALITYCONTROL_MONITOROBJECTCOLLECTION_H
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2025 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 ObjectMetadataHelpers.h
14+
/// \author Michal Tichak
15+
///
16+
17+
#ifndef QUALITYCONTROL_OBJECTMETADATAHELPERS_H
18+
#define QUALITYCONTROL_OBJECTMETADATAHELPERS_H
19+
20+
#include <optional>
21+
#include <string>
22+
23+
namespace o2::quality_control::repository
24+
{
25+
/**
26+
* \brief Parses metadata value stored under metadata_keys::cycle
27+
* @param cycleStr string expecting unsigned number
28+
* @return if parsing fails (eg. too big of a number, string wasn't a number) it returns nullopt
29+
*
30+
*/
31+
std::optional<unsigned long> parseCycle(const std::string& cycleStr);
32+
} // namespace o2::quality_control::repository
33+
34+
#endif

Framework/include/QualityControl/ObjectMetadataKeys.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ constexpr auto created = "Created";
2828
constexpr auto md5sum = "Content-MD5";
2929
constexpr auto objectType = "ObjectType";
3030
constexpr auto lastModified = "lastModified";
31+
3132
// General QC framework
3233
constexpr auto qcVersion = "qc_version";
3334
constexpr auto qcDetectorCode = "qc_detector_name";
@@ -36,6 +37,8 @@ constexpr auto qcTaskClass = "qc_task_class";
3637
constexpr auto qcQuality = "qc_quality";
3738
constexpr auto qcCheckName = "qc_check_name";
3839
constexpr auto qcAdjustableEOV = "adjustableEOV"; // this is a keyword for the CCDB
40+
constexpr auto cycleNumber = "CycleNumber";
41+
3942
// QC Activity
4043
constexpr auto runType = "RunType";
4144
constexpr auto runNumber = "RunNumber";

Framework/include/QualityControl/Quality.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define QC_CORE_QUALITY_H
1919

2020
#include <Rtypes.h>
21+
#include <optional>
2122
#include <string>
2223
#include <map>
2324
#include <vector>
@@ -105,6 +106,9 @@ class Quality
105106
/// \brief Get metadata
106107
/// \return the value corresponding to the key if it was found, default value otherwise
107108
std::string getMetadata(const std::string& key, const std::string& defaultValue) const;
109+
/// \brief Get metadata
110+
/// \return the value corresponding to the key if it was found, nulopt otherwise
111+
std::optional<std::string> getMetadataOpt(const std::string&) const;
108112

109113
/// \brief Associate the Quality with a new flag and an optional comment
110114
/// \return reference to *this
@@ -121,7 +125,7 @@ class Quality
121125
std::map<std::string, std::string> mUserMetadata;
122126
std::vector<std::pair<FlagType, std::string>> mFlags;
123127

124-
ClassDef(Quality, 2);
128+
ClassDef(Quality, 3);
125129
};
126130

127131
} // namespace o2::quality_control::core

Framework/include/QualityControl/QualityObject.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
// std
1616
#include <map>
17+
#include <optional>
1718
#include <string>
1819
#include <vector>
1920
// ROOT
@@ -107,6 +108,9 @@ class QualityObject : public TObject
107108
/// \brief Get a metadata
108109
/// \return the value corresponding to the key if it was found, default value otherwise
109110
std::string getMetadata(std::string key, std::string defaultValue) const;
111+
/// \brief Get a metadata
112+
/// \return the value corresponding to the key if it was found, nullopt otherwise
113+
std::optional<std::string> getMetadataOpt(const std::string& key) const;
110114

111115
/// \brief Build the path to this object.
112116
/// Build the path to this object as it will appear in the GUI.
@@ -145,7 +149,7 @@ class QualityObject : public TObject
145149
std::vector<std::string> mMonitorObjectsNames;
146150
Activity mActivity;
147151

148-
ClassDefOverride(QualityObject, 6);
152+
ClassDefOverride(QualityObject, 7);
149153
};
150154

151155
using QualityObjectsType = std::vector<std::shared_ptr<QualityObject>>;

0 commit comments

Comments
 (0)