Skip to content

Commit

Permalink
Merge branch 'AliceO2Group:master' into 1pcut
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-zugravel authored Dec 4, 2024
2 parents 9abbd30 + 2603c31 commit fd37aec
Show file tree
Hide file tree
Showing 70 changed files with 3,183 additions and 448 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include(GNUInstallDirs)
# ---- Project ----

project(QualityControl
VERSION 1.162.0
VERSION 1.164.0
DESCRIPTION "O2 Data Quality Control Framework"
LANGUAGES C CXX)

Expand Down
25 changes: 20 additions & 5 deletions Framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,22 @@ configure_file("include/QualityControl/Version.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/include/QualityControl/Version.h"
@ONLY)

# ---- Library for the types ----
# ---- Library for IL ----
add_library(O2QualityControlInfoLogger STATIC
src/QcInfoLogger.cxx
)

target_include_directories(O2QualityControlInfoLogger
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

target_link_libraries(O2QualityControlInfoLogger
PUBLIC
AliceO2::InfoLogger
)

# ---- Library for the types ----
add_library(O2QualityControlTypes
src/MonitorObject.cxx
src/QualityObject.cxx
Expand All @@ -21,11 +35,13 @@ target_include_directories(
)

target_link_libraries(O2QualityControlTypes
PRIVATE
O2QualityControlInfoLogger
PUBLIC
ROOT::Hist
AliceO2::BookkeepingApi
AliceO2::Common
O2::DataFormatsQualityControl
AliceO2::BookkeepingApi
ROOT::Hist
)

add_root_dictionary(O2QualityControlTypes
Expand Down Expand Up @@ -70,7 +86,6 @@ add_library(O2QualityControl
src/AggregatorInterface.cxx
src/DatabaseFactory.cxx
src/CcdbDatabase.cxx
src/QcInfoLogger.cxx
src/TaskFactory.cxx
src/TaskRunner.cxx
src/TaskRunnerFactory.cxx
Expand Down Expand Up @@ -141,7 +156,6 @@ target_link_libraries(O2QualityControl
ROOT::Hist
ROOT::TreePlayer
AliceO2::Common
AliceO2::InfoLogger
AliceO2::Monitoring
AliceO2::Configuration
AliceO2::Occ
Expand All @@ -159,6 +173,7 @@ target_link_libraries(O2QualityControl
${RDKAFKA_LIB}
PRIVATE Boost::system
CURL::libcurl
O2QualityControlInfoLogger
)

add_root_dictionary(O2QualityControl
Expand Down
33 changes: 19 additions & 14 deletions Framework/include/QualityControl/MonitorObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ class MonitorObject : public TObject
/// Destructor
~MonitorObject() override;

/// Copy constructor
MonitorObject(const MonitorObject& other) = default;
// /// Copy constructor
MonitorObject(const MonitorObject& other);
/// Move constructor
MonitorObject(MonitorObject&& other) /*noexcept*/ = default;
/// Copy assignment operator
MonitorObject& operator=(const MonitorObject& other) = default;
MonitorObject& operator=(const MonitorObject& other);
/// Move assignment operator
MonitorObject& operator=(MonitorObject&& other) /*noexcept*/ = default;

Expand All @@ -69,19 +69,19 @@ class MonitorObject : public TObject

/// \brief Return joined task name and name of the encapsulated object (if any).
/// @return The name as "{getTaskName()}/{getName())}.
const std::string getFullName() const { return getTaskName() + "/" + getName(); }
std::string getFullName() const;

TObject* getObject() const { return mObject; }
void setObject(TObject* object) { mObject = object; }
TObject* getObject() const;
void setObject(TObject* object);

bool isIsOwner() const { return mIsOwner; }
void setIsOwner(bool isOwner) { mIsOwner = isOwner; }
bool isIsOwner() const;
void setIsOwner(bool isOwner);

const std::string& getTaskName() const { return mTaskName; }
void setTaskName(const std::string& taskName) { mTaskName = taskName; }
const std::string& getTaskName() const;
void setTaskName(const std::string& taskName);

const std::string& getDetectorName() const { return mDetectorName; }
void setDetectorName(const std::string& detectorName) { mDetectorName = detectorName; }
const std::string& getDetectorName() const;
void setDetectorName(const std::string& detectorName);

const std::string& getTaskClass() const;
void setTaskClass(const std::string& taskClass);
Expand Down Expand Up @@ -117,6 +117,8 @@ class MonitorObject : public TObject
void Draw(Option_t* option) override;
TObject* DrawClone(Option_t* option) const override;

void Copy(TObject& object) const override;

/// \brief Build the path to this object.
/// Build the path to this object as it will appear in the GUI.
/// \return A string containing the path.
Expand All @@ -126,7 +128,7 @@ class MonitorObject : public TObject
void setDescription(const std::string& description);

private:
TObject* mObject;
std::unique_ptr<TObject> mObject;
std::string mTaskName;
std::string mTaskClass;
std::string mDetectorName;
Expand All @@ -141,7 +143,10 @@ class MonitorObject : public TObject
// tells Merger to create an object with data from the last cycle only on the side of the complete object
bool mCreateMovingWindow = false;

ClassDefOverride(MonitorObject, 12);
void releaseObject();
void cloneAndSetObject(const MonitorObject&);

ClassDefOverride(MonitorObject, 13);
};

} // namespace o2::quality_control::core
Expand Down
24 changes: 22 additions & 2 deletions Framework/include/QualityControl/ObjectsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
#include "QualityControl/Activity.h"
#include "QualityControl/MonitorObject.h"
#include "QualityControl/MonitorObjectCollection.h"
#include <Mergers/Mergeable.h>
// stl
#include <concepts>
#include <string>
#include <memory>
#include <type_traits>

class TObject;
class TObjArray;

namespace o2::quality_control::core
{
Expand Down Expand Up @@ -76,10 +78,26 @@ class ObjectsManager
/**
* Start publishing the object obj, i.e. it will be pushed forward in the workflow at regular intervals.
* The ownership remains to the caller.
* @param IgnoreMergeable if you want to ignore static_assert check for Mergeable
* @param T type of object that we want to publish.
* @param obj The object to publish.
* @throws DuplicateObjectError
*/
void startPublishing(TObject* obj, PublicationPolicy = PublicationPolicy::Forever);
template <bool IgnoreMergeable = false, typename T>
void startPublishing(T obj, PublicationPolicy policy = PublicationPolicy::Forever)
{
// We don't want to do this compile time check in PostProcessing, and we want to turn off runtime check as well
bool ignoreMergeableRuntime = IgnoreMergeable;
#ifndef QUALITYCONTROL_POSTPROCESSINTERFACE_H
static_assert(std::same_as<std::remove_pointer_t<T>, TObject> ||
IgnoreMergeable || mergers::Mergeable<T>,
"you are trying to startPublishing object that is not mergeable."
" If you know what you are doing use startPublishing<true>(...)");
#else
ignoreMergeableRuntime = true;
#endif
startPublishingImpl(obj, policy, ignoreMergeableRuntime);
}

/**
* Stop publishing this object
Expand Down Expand Up @@ -223,6 +241,8 @@ class ObjectsManager
bool mUpdateServiceDiscovery;
Activity mActivity;
std::vector<std::string> mMovingWindowsList;

void startPublishingImpl(TObject* obj, PublicationPolicy, bool ignoreMergeableWarning);
};

} // namespace o2::quality_control::core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class QualitiesToFlagCollectionConverter

size_t getQOsIncluded() const;
size_t getWorseThanGoodQOs() const;
int getRunNumber() const;

/// Sets the provided validity interval, trims affected flags and fills extensions with UnknownQuality
void updateValidityInterval(const ValidityInterval validityInterval);
Expand Down
2 changes: 1 addition & 1 deletion Framework/include/QualityControl/Quality.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Quality
{
public:
/// Default constructor
Quality(unsigned int level = Quality::NullLevel, std::string name = "");
explicit Quality(unsigned int level = Quality::NullLevel, std::string name = "");

/// Destructor
virtual ~Quality() = default;
Expand Down
28 changes: 18 additions & 10 deletions Framework/script/RepoCleaner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,26 @@ There can be any number of these rules. The order is important as we use the fir

The configuration for ccdb-test is described [here](../../../doc/DevelopersTips.md).

## Setup virtual environment for development and test (venv)

1. cd Framework/script/RepoCleaner
2. python3 -m venv env
3. source env/bin/activate
4. python -m pip install -r requirements.txt
5. python3 -m pip install .
6. You can execute and work. Next time just do "activate" and then you are good to go

## Unit Tests
`cd QualityControl/Framework/script/RepoCleaner ; python3 -m unittest discover`

and to test only one of them: `python3 -m unittest tests/test_NewProduction.py -k test_2_runs`
```
cd Framework/script/RepoCleaner
source env/bin/activate
# Run a test:
python -m unittest tests.test_Ccdb.TestCcdb.test_getObjectsList
```

`cd QualityControl/Framework/script/RepoCleaner ; python3 -m unittest discover`

In particular there is a test for the `production` rule that is pretty extensive. It hits the ccdb though and it needs the following path to be truncated:
`
Expand Down Expand Up @@ -75,11 +91,3 @@ Create new version
2. `python3 setup.py sdist bdist_wheel`
3. `python3 -m twine upload --repository pypi dist/*`

## Use venv

1. cd Framework/script/RepoCleaner
2. python3 -m venv env
3. source env/bin/activate
4. python -m pip install -r requirements.txt
5. python3 -m pip install .
6. You can execute and work. Next time just do "activate" and then you are good to go
4 changes: 3 additions & 1 deletion Framework/script/RepoCleaner/qcrepocleaner/Ccdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(self, path: str, validFrom, validTo, createdAt, uuid=None, metadata
:param uuid: unique id of the object
:param validFrom: validity range smaller limit (in ms)
:param validTo: validity range bigger limit (in ms)
:param createdAt: creation timestamp of the object
'''
self.path = path
self.uuid = uuid
Expand Down Expand Up @@ -72,7 +73,8 @@ def getObjectsList(self, added_since: int = 0, path: str = "", no_wildcard: bool
:return A list of strings, each containing a path to an object in the CCDB.
'''
url_for_all_obj = self.url + '/latest/' + path
url_for_all_obj += '/' if no_wildcard else '/.*'
url_for_all_obj += '/' if path else ''
url_for_all_obj += '' if no_wildcard else '.*'
logger.debug(f"Ccdb::getObjectsList -> {url_for_all_obj}")
headers = {'Accept': 'application/json', 'If-Not-Before':str(added_since)}
r = requests.get(url_for_all_obj, headers=headers)
Expand Down
12 changes: 12 additions & 0 deletions Framework/script/RepoCleaner/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
certifi==2024.7.4
chardet==5.2.0
charset-normalizer==3.3.2
dryable==1.2.0
idna==3.7
psutil==6.1.0
python-consul==1.1.0
PyYAML==6.0.1
requests==2.32.2
responses==0.25.0
six==1.16.0
urllib3==2.2.2
Loading

0 comments on commit fd37aec

Please sign in to comment.