Skip to content

Commit 0106452

Browse files
committed
[QC-740] Fix inconsistencies between retrieveMO and retrieveQO
- undeprecate retrieveMO and retrieveQO as they are massively used. - add one method for the common code of these two methods.
1 parent 306c973 commit 0106452

3 files changed

Lines changed: 36 additions & 17 deletions

File tree

‎Framework/include/QualityControl/CcdbDatabase.h‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <boost/property_tree/ptree_fwd.hpp>
2323
#include <memory>
2424
#include <string>
25+
#include <utility>
2526

2627
namespace o2::ccdb
2728
{
@@ -75,12 +76,12 @@ class CcdbDatabase : public DatabaseInterface
7576
std::map<std::string, std::string>* headers = nullptr,
7677
const std::string& createdNotAfter = "", const std::string& createdNotBefore = "") override;
7778

78-
// retrieval - MO - deprecated
79+
// retrieval - MO
7980
std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string objectPath, std::string objectName,
8081
long timestamp = Timestamp::Current,
8182
const core::Activity& activity = {},
8283
const std::map<std::string, std::string>& metadata = {}) override;
83-
// retrieval - QO - deprecated
84+
// retrieval - QO
8485
std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string qoPath, long timestamp = Timestamp::Current,
8586
const core::Activity& activity = {},
8687
const std::map<std::string, std::string>& metadata = {}) override;
@@ -163,6 +164,22 @@ class CcdbDatabase : public DatabaseInterface
163164
*/
164165
static void addFrameworkMetadata(std::map<std::string, std::string>& fullMetadata, std::string detectorName, std::string className);
165166

167+
/**
168+
* Retrieve a QC object (MO or QO payload) given its path without the provenance prefix.
169+
* The provenance prefix is taken from the activity, and the activity is converted into metadata filters
170+
* and merged with the additional metadata.
171+
* @param pathWithoutProvenance the path of the object, without the provenance prefix
172+
* @param timestamp the timestamp to query the object
173+
* @param activity activity used to build the full path and the metadata filters
174+
* @param extraMetadata additional metadata to filter objects during retrieval
175+
* @param headers populated with the headers received from the database
176+
* @return the full path of the object (with provenance) and the retrieved object, or nullptr if not found
177+
*/
178+
std::pair<std::string, TObject*> retrieveQcObject(const std::string& pathWithoutProvenance, long timestamp,
179+
const core::Activity& activity,
180+
const std::map<std::string, std::string>& extraMetadata,
181+
std::map<std::string, std::string>& headers);
182+
166183
std::unique_ptr<o2::ccdb::CcdbApi> ccdbApi;
167184
std::string mUrl;
168185
size_t mMaxObjectSize = 2097152; // 2MB by default

‎Framework/include/QualityControl/DatabaseInterface.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ class DatabaseInterface
134134
* @param timestamp Timestamp of the object in ms since epoch
135135
* @param activity Activity of the object
136136
* @param metadata additional metadata to filter objects during retrieval
137-
* @deprecated
138137
*/
139138
virtual std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string objectPath, std::string objectName,
140139
long timestamp = Timestamp::Current, const core::Activity& activity = {},
@@ -146,7 +145,6 @@ class DatabaseInterface
146145
* @param timestamp Timestamp of the object in ms since epoch
147146
* @param activity Activity of the object
148147
* @param metadata additional metadata to filter objects during retrieval
149-
* @deprecated
150148
*/
151149
virtual std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string qoPath, long timestamp = Timestamp::Current,
152150
const core::Activity& activity = {},

‎Framework/src/CcdbDatabase.cxx‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,21 +311,28 @@ void* CcdbDatabase::retrieveAny(const type_info& tinfo, const string& path, cons
311311
return object;
312312
}
313313

314+
std::pair<std::string, TObject*> CcdbDatabase::retrieveQcObject(const std::string& pathWithoutProvenance, long timestamp,
315+
const core::Activity& activity,
316+
const std::map<std::string, std::string>& extraMetadata,
317+
std::map<std::string, std::string>& headers)
318+
{
319+
string fullPath = activity.mProvenance + "/" + pathWithoutProvenance;
320+
map<string, string> metadata = activity_helpers::asDatabaseMetadata(activity, false);
321+
metadata.insert(extraMetadata.begin(), extraMetadata.end());
322+
TObject* obj = retrieveTObject(fullPath, metadata, timestamp, &headers);
323+
if (obj == nullptr && headers.count("Error") > 0) {
324+
ILOG(Error, Support) << headers["Error"] << ENDM;
325+
}
326+
return { fullPath, obj };
327+
}
328+
314329
std::shared_ptr<o2::quality_control::core::MonitorObject> CcdbDatabase::retrieveMO(std::string objectPath, std::string objectName,
315330
long timestamp, const core::Activity& activity,
316331
const std::map<std::string, std::string>& metadataToRetrieve)
317332
{
318-
string fullPath = activity.mProvenance + "/" + objectPath + "/" + objectName;
319333
map<string, string> headers;
320-
map<string, string> metadata = activity_helpers::asDatabaseMetadata(activity, false);
321-
metadata.insert(metadataToRetrieve.begin(), metadataToRetrieve.end());
322-
TObject* obj = retrieveTObject(fullPath, metadata, timestamp, &headers);
323-
324-
// no object found
334+
auto [fullPath, obj] = retrieveQcObject(objectPath + "/" + objectName, timestamp, activity, metadataToRetrieve, headers);
325335
if (obj == nullptr) {
326-
if (headers.count("Error") > 0) {
327-
ILOG(Error, Support) << headers["Error"] << ENDM;
328-
}
329336
return nullptr;
330337
}
331338

@@ -360,10 +367,7 @@ std::shared_ptr<o2::quality_control::core::QualityObject> CcdbDatabase::retrieve
360367
const std::map<std::string, std::string>& metadataToRetrieve)
361368
{
362369
map<string, string> headers;
363-
map<string, string> metadata = activity_helpers::asDatabaseMetadata(activity, false);
364-
metadata.insert(metadataToRetrieve.begin(), metadataToRetrieve.end());
365-
auto fullPath = activity.mProvenance + "/" + qoPath;
366-
TObject* obj = retrieveTObject(fullPath, metadata, timestamp, &headers);
370+
auto [fullPath, obj] = retrieveQcObject(qoPath, timestamp, activity, metadataToRetrieve, headers);
367371
if (obj == nullptr) {
368372
return nullptr;
369373
}

0 commit comments

Comments
 (0)