Skip to content
Merged
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
4 changes: 0 additions & 4 deletions Framework/include/QualityControl/CcdbDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class CcdbDatabase : public DatabaseInterface
// storage
void storeMO(std::shared_ptr<const o2::quality_control::core::MonitorObject> q) override;
void storeQO(std::shared_ptr<const o2::quality_control::core::QualityObject> q) override;
void storeQCFC(std::shared_ptr<const o2::quality_control::QualityControlFlagCollection> qcfc) override;
void storeAny(const void* obj, std::type_info const& typeInfo, std::string const& path, std::map<std::string, std::string> const& metadata,
std::string const& detectorName, std::string const& taskName, long from = -1, long to = -1) override;

Expand All @@ -80,9 +79,6 @@ class CcdbDatabase : public DatabaseInterface
std::shared_ptr<o2::quality_control::core::MonitorObject> retrieveMO(std::string objectPath, std::string objectName, long timestamp = Timestamp::Current, const core::Activity& activity = {}) override;
// retrieval - QO - deprecated
std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string qoPath, long timestamp = Timestamp::Current, const core::Activity& activity = {}) override;
std::shared_ptr<o2::quality_control::QualityControlFlagCollection> retrieveQCFC(const std::string& name, const std::string& detector, int runNumber = 0,
const std::string& passName = "", const std::string& periodName = "",
const std::string& provenance = "", long timestamp = -1) override;

// retrieval - general
std::string retrieveJson(std::string path, long timestamp, const std::map<std::string, std::string>& metadata) override;
Expand Down
14 changes: 1 addition & 13 deletions Framework/include/QualityControl/DatabaseInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "QualityControl/QualityObject.h"
#include "QualityControl/MonitorObject.h"
#include "QualityControl/Activity.h"
#include <DataFormatsQualityControl/QualityControlFlagCollection.h>

namespace o2::quality_control::repository
{
Expand Down Expand Up @@ -127,11 +126,6 @@ class DatabaseInterface
*/
virtual void storeQO(std::shared_ptr<const o2::quality_control::core::QualityObject> qo) = 0;

/**
* Stores the serialized QualityControlFlagCollection in the database.
* @param qcfc The QualityControlFlagCollection to serialize and store. It should contain correct time validity inside the object.
*/
virtual void storeQCFC(std::shared_ptr<const o2::quality_control::QualityControlFlagCollection> qcfc) = 0;
/**
* \brief Look up a monitor object and return it.
* Look up a monitor object and return it if found or nullptr if not.
Expand All @@ -151,13 +145,7 @@ class DatabaseInterface
* @deprecated
*/
virtual std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string qoPath, long timestamp = Timestamp::Current, const core::Activity& activity = {}) = 0;
/**
* \brief Look up a QualityControlFlagCollection object and return it.
* Look up a QualityControlFlagCollection and return it if found or nullptr if not.
*/
virtual std::shared_ptr<o2::quality_control::QualityControlFlagCollection> retrieveQCFC(const std::string& name, const std::string& detector, int runNumber = 0,
const std::string& passName = "", const std::string& periodName = "",
const std::string& provenance = "", long timestamp = Timestamp::Current) = 0;

/**
* \brief Look up an object and return it.
* Look up an object and return it if found or nullptr if not. It is a raw pointer because we might need it to build a MO.
Expand Down
6 changes: 1 addition & 5 deletions Framework/include/QualityControl/DummyDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ class DummyDatabase : public DatabaseInterface
// QualityObject
void storeQO(std::shared_ptr<const o2::quality_control::core::QualityObject> q) override;
std::shared_ptr<o2::quality_control::core::QualityObject> retrieveQO(std::string checkerName, long timestamp = -1, const core::Activity& activity = {}) override;
// QCFC
void storeQCFC(std::shared_ptr<const o2::quality_control::QualityControlFlagCollection> qcfc) override;
std::shared_ptr<o2::quality_control::QualityControlFlagCollection> retrieveQCFC(const std::string& name, const std::string& detector, int runNumber = 0,
const std::string& passName = "", const std::string& periodName = "",
const std::string& provenance = "", long timestamp = -1) override;

// General
void* retrieveAny(std::type_info const& tinfo, std::string const& path,
std::map<std::string, std::string> const& metadata, long timestamp = -1,
Expand Down
1 change: 0 additions & 1 deletion Framework/include/QualityControl/ObjectMetadataKeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ constexpr auto qcTaskName = "qc_task_name";
constexpr auto qcTaskClass = "qc_task_class";
constexpr auto qcQuality = "qc_quality";
constexpr auto qcCheckName = "qc_check_name";
constexpr auto qcQCFCName = "qc_qcfc_name";
constexpr auto qcAdjustableEOV = "adjustableEOV"; // this is a keyword for the CCDB
// QC Activity
constexpr auto runType = "RunType";
Expand Down
20 changes: 0 additions & 20 deletions Framework/include/QualityControl/RepoPathUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "QualityControl/MonitorObject.h"
#include "QualityControl/QualityObject.h"
#include <Common/Exceptions.h>
#include <DataFormatsQualityControl/QualityControlFlagCollection.h>

namespace o2::quality_control::core
{
Expand Down Expand Up @@ -107,25 +106,6 @@ class RepoPathUtils
includeProvenance);
}

/**
* Compute and return the path to the FlagCollection.
* Current algorithm does <provenance(qc)>/<detectorCode>/QCFC/<qcfcName>
* @param detectorCode
* @param qcfcName
* @param provenance
* @return the path to the QCFCollection
*/
static std::string getQcfcPath(const std::string& detectorCode,
const std::string& qcfcName,
const std::string& provenance = "qc");
/**
* Compute and return the path to the QCFCollection.
* Current algorithm does <provenance(qc)>/<detectorCode>/QCFC/<qcfcName>
* @param qcfc
* @return the path to the QCFCollection
*/
static std::string getQcfcPath(const QualityControlFlagCollection* qcfc);

static constexpr auto allowedProvenancesMessage = R"(Allowed provenances are "qc" (real data processed synchronously), "qc_async" (real data processed asynchronously) and "qc_mc" (simulated data).)";
static bool isProvenanceAllowed(const std::string& provenance);

Expand Down
83 changes: 0 additions & 83 deletions Framework/src/CcdbDatabase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -270,33 +270,6 @@ void CcdbDatabase::storeQO(std::shared_ptr<const o2::quality_control::core::Qual
handleStorageError(path, result);
}

void CcdbDatabase::storeQCFC(std::shared_ptr<const o2::quality_control::QualityControlFlagCollection> qcfc)
{
// metadata
map<string, string> metadata;
metadata[metadata_keys::runNumber] = std::to_string(qcfc->getRunNumber());
metadata[metadata_keys::periodName] = qcfc->getPeriodName();
metadata[metadata_keys::passName] = qcfc->getPassName();
// QC metadata (prefix qc_)
addFrameworkMetadata(metadata, qcfc->getDetector(), qcfc->IsA()->GetName());
metadata[metadata_keys::qcQCFCName] = qcfc->getName();

// other attributes
string path = RepoPathUtils::getQcfcPath(qcfc.get());
auto from = qcfc->getStart();
auto to = qcfc->getEnd();
if (from > to) {
ILOG(Error, Support) << "QCFC '" + qcfc->getName() + "' cannot be stored in CCDB, because it has invalid validity range (" + std::to_string(from) + ", " + std::to_string(to) + ")." << ENDM;
}
std::stringstream buffer;
qcfc->streamTo(buffer);
ILOG(Debug, Support) << "Storing QualityControlFlagCollection at " << path << " (" << qcfc->getName() << ")" << ENDM;
auto result = ccdbApi->storeAsBinaryFile(buffer.str().c_str(), buffer.str().size(), qcfc->getName(), qcfc->IsA()->GetName(), path, metadata, from, to);
if (result != 0) {
ILOG(Error, Support) << "QCFC '" + qcfc->getName() + "' could not be stored in CCDB, error: " + std::to_string(result) << ENDM;
}
}

TObject* CcdbDatabase::retrieveTObject(std::string path, std::map<std::string, std::string> const& metadata, long timestamp, std::map<std::string, std::string>* headers)
{
if (timestamp == Timestamp::Latest) {
Expand Down Expand Up @@ -396,62 +369,6 @@ std::shared_ptr<o2::quality_control::core::QualityObject> CcdbDatabase::retrieve
return qo;
}

std::shared_ptr<o2::quality_control::QualityControlFlagCollection> CcdbDatabase::retrieveQCFC(const std::string& qcfcName, const std::string& detector, int runNumber, const string& passName, const string& periodName, const std::string& provenance, long timestamp)
{
map<string, string> headers;
map<string, string> metadata;
if (runNumber != 0) {
metadata[metadata_keys::runNumber] = std::to_string(runNumber);
}
if (!passName.empty()) {
metadata[metadata_keys::passName] = passName;
}
if (!periodName.empty()) {
metadata[metadata_keys::periodName] = periodName;
}
const auto qcfcPath = RepoPathUtils::getQcfcPath(detector, qcfcName, provenance);
const std::string localFileDir = "/tmp";
const std::string localFileName = "qcfc_" + qcfcName + std::to_string(time_point_cast<nanoseconds>(system_clock::now()).time_since_epoch().count());
const std::string localFilePath = localFileDir + std::filesystem::path::preferred_separator + localFileName;
if (localFilePath.find("..") != std::string::npos || localFilePath.find('~') != std::string::npos) {
ILOG(Error, Support) << "The path '" << localFilePath << "' looks hacky, will not download any files there." << ENDM;
return nullptr;
}

auto resultMetadata = ccdbApi->retrieveHeaders(qcfcPath, metadata, timestamp);
if (resultMetadata.empty()) {
ILOG(Error, Support) << "Could not extract headers of QCFC at '" << qcfcPath << "' with the metadata: " << ENDM; // TODO
ILOG(Error, Support) << " - RunNumber : " << metadata[metadata_keys::runNumber] << ENDM;
ILOG(Error, Support) << " - PassName : " << metadata[metadata_keys::passName] << ENDM;
ILOG(Error, Support) << " - PeriodName : " << metadata[metadata_keys::periodName] << ENDM;
return nullptr;
}

auto success = ccdbApi->retrieveBlob(qcfcPath, localFileDir, metadata, timestamp, false, localFileName);
if (!success) {
ILOG(Error, Support) << "Could not retrieve the QCFC at '" << qcfcPath << "' with the metadata: " << ENDM; // TODO
ILOG(Error, Support) << " - RunNumber : " << metadata[metadata_keys::runNumber] << ENDM;
ILOG(Error, Support) << " - PassName : " << metadata[metadata_keys::passName] << ENDM;
ILOG(Error, Support) << " - PeriodName : " << metadata[metadata_keys::periodName] << ENDM;
return nullptr;
}

std::ifstream localFile(localFilePath);
if (!localFile.is_open()) {
ILOG(Error, Support) << "Could not open a file at '" << localFilePath << "'" << ENDM;
std::filesystem::remove(localFilePath);
return nullptr;
}

QualityControlFlagCollection::RangeInterval validity{ std::stoull(resultMetadata[metadata_keys::validFrom]), std::stoull(resultMetadata[metadata_keys::validUntil]) };
auto qcfc = std::make_shared<QualityControlFlagCollection>(qcfcName, detector, validity, runNumber, periodName, passName, provenance);
qcfc->streamFrom(localFile);
localFile.close();
std::filesystem::remove(localFilePath);

return qcfc;
}

std::string CcdbDatabase::retrieveJson(std::string path, long timestamp, const std::map<std::string, std::string>& metadata)
{
map<string, string> headers;
Expand Down
8 changes: 0 additions & 8 deletions Framework/src/DummyDatabase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ void DummyDatabase::storeQO(std::shared_ptr<const o2::quality_control::core::Qua
{
}

void DummyDatabase::storeQCFC(std::shared_ptr<const o2::quality_control::QualityControlFlagCollection> qcfc)
{
}

std::shared_ptr<o2::quality_control::core::QualityObject> DummyDatabase::retrieveQO(std::string, long, const core::Activity& activity)
{
return {};
Expand Down Expand Up @@ -87,10 +83,6 @@ void* DummyDatabase::retrieveAny(const std::type_info&, const std::string&, cons
{
return nullptr;
}
std::shared_ptr<o2::quality_control::QualityControlFlagCollection> DummyDatabase::retrieveQCFC(const std::string& name, const std::string& detector, int runNumber, const std::string& passName, const std::string& periodName, const std::string& provenance, long timestamp)
{
return nullptr;
}

void DummyDatabase::setMaxObjectSize(size_t maxObjectSize)
{
Expand Down
12 changes: 0 additions & 12 deletions Framework/src/RepoPathUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@
namespace o2::quality_control::core
{

std::string RepoPathUtils::getQcfcPath(const std::string& detectorCode,
const std::string& qcfcName,
const std::string& provenance)
{
return provenance + "/" + detectorCode + "/QCFC/" + qcfcName;
}

std::string RepoPathUtils::getQcfcPath(const QualityControlFlagCollection* qcfc)
{
return getQcfcPath(qcfc->getDetector(), qcfc->getName(), qcfc->getProvenance());
}

bool RepoPathUtils::isProvenanceAllowed(const std::string& provenance)
{
return provenance == "qc" || provenance == "qc_async" || provenance == "qc_mc";
Expand Down
25 changes: 0 additions & 25 deletions Framework/test/testCcdbDatabase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -417,30 +417,5 @@ BOOST_AUTO_TEST_CASE(ccdb_store_retrieve_latest)
BOOST_CHECK_EQUAL(h1Back->GetEntries(), 20000);
}

BOOST_AUTO_TEST_CASE(ccdb_qcfc)
{
test_fixture f;
const std::string pid = std::to_string(getpid());
const std::string qcfcName = "Test_pid" + pid; // TODO we can use a 'Test' directory once https://github.com/AliceO2Group/AliceO2/pull/8195 is merged

std::shared_ptr<QualityControlFlagCollection> qcfc1{ new QualityControlFlagCollection{ qcfcName, "TST", { 45, 500000 }, 42, "LHC42x", "spass", "qc" } };
qcfc1->insert({ 50, 77, FlagTypeFactory::Invalid(), "a comment", "a source" });
qcfc1->insert({ 51, 77, FlagTypeFactory::Invalid() });
qcfc1->insert({ 1234, 3434, FlagTypeFactory::BadPID() });
qcfc1->insert({ 50, 77, FlagTypeFactory::BadPID() });
qcfc1->insert({ 43434, 63421, FlagTypeFactory::Good() });

f.backend->storeQCFC(qcfc1);

auto qcfc2 = f.backend->retrieveQCFC(qcfc1->getName(), qcfc1->getDetector(), qcfc1->getRunNumber(),
qcfc1->getPassName(), qcfc1->getPeriodName(), qcfc1->getProvenance(), 400000);
BOOST_REQUIRE(qcfc2 != nullptr);

BOOST_REQUIRE_EQUAL(qcfc1->size(), qcfc2->size());
for (auto it1 = qcfc1->begin(), it2 = qcfc2->begin(); it1 != qcfc1->end() && it2 != qcfc2->end(); ++it1, ++it2) {
BOOST_CHECK_EQUAL(*it1, *it2);
}
}

} // namespace
} // namespace o2::quality_control::core
6 changes: 0 additions & 6 deletions Modules/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ add_library(O2QcCommon)
target_sources(O2QcCommon
PRIVATE src/IncreasingEntries.cxx
src/WorstOfAllAggregator.cxx
src/FlagCollectionTask.cxx
src/FlagCollectionTaskConfig.cxx
src/QualityTask.cxx
src/QualityTaskConfig.cxx
src/BigScreenCanvas.cxx
Expand Down Expand Up @@ -60,7 +58,6 @@ install(TARGETS O2QcCommon
add_root_dictionary(O2QcCommon
HEADERS include/Common/NonEmpty.h
include/Common/WorstOfAllAggregator.h
include/Common/FlagCollectionTask.h
include/Common/QualityTask.h
include/Common/BigScreen.h
include/Common/CcdbInspectorTask.h
Expand All @@ -87,9 +84,6 @@ add_root_dictionary(O2QcCommon
include/Common/LHCClockPhaseReductor.h
LINKDEF include/Common/LinkDef.h)

install(FILES etc/flagcollection-example.json
DESTINATION Modules/Common)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/Common
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/QualityControl")

Expand Down
43 changes: 0 additions & 43 deletions Modules/Common/etc/flagcollection-example.json

This file was deleted.

Loading