Skip to content

Commit 73ab873

Browse files
authored
[QC-304] TrendingTask - specify multiple data source objects under the same path (#352)
* TrendingTask - specify multiple data source objects under the same path * clang format
1 parent 290a06e commit 73ab873

4 files changed

Lines changed: 24 additions & 11 deletions

File tree

Framework/postprocessing.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@
4747
{
4848
"type": "repository",
4949
"path": "qc/TST/QcTask",
50-
"name": "example",
50+
"names": [ "example" ],
5151
"reductorName": "o2::quality_control_modules::common::TH1Reductor",
5252
"moduleName": "QcCommon"
5353
},
5454
{
5555
"type": "repository-quality",
5656
"path": "qc/checks",
57-
"name": "QcCheck",
57+
"names": [ "QcCheck" ],
5858
"reductorName": "o2::quality_control_modules::common::QualityReductor",
5959
"moduleName": "QcCommon"
6060
}

Framework/src/TrendingTaskConfig.cxx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,24 @@ TrendingTaskConfig::TrendingTaskConfig(std::string name, configuration::Configur
3030
plotConfig.second.get<std::string>("option", "") });
3131
}
3232
for (const auto& dataSourceConfig : config.getRecursive("qc.postprocessing." + name + ".dataSources")) {
33-
dataSources.push_back({ dataSourceConfig.second.get<std::string>("type", "repository"),
34-
dataSourceConfig.second.get<std::string>("path"),
35-
dataSourceConfig.second.get<std::string>("name"),
36-
dataSourceConfig.second.get<std::string>("reductorName", ""),
37-
dataSourceConfig.second.get<std::string>("moduleName", "") });
33+
if (const auto& sourceNames = dataSourceConfig.second.get_child_optional("names"); sourceNames.has_value()) {
34+
for (const auto& sourceName : sourceNames.value()) {
35+
dataSources.push_back({ dataSourceConfig.second.get<std::string>("type", "repository"),
36+
dataSourceConfig.second.get<std::string>("path"),
37+
sourceName.second.data(),
38+
dataSourceConfig.second.get<std::string>("reductorName"),
39+
dataSourceConfig.second.get<std::string>("moduleName") });
40+
}
41+
} else if (!dataSourceConfig.second.get<std::string>("name").empty()) {
42+
// "name" : [ "something" ] would return an empty string here
43+
dataSources.push_back({ dataSourceConfig.second.get<std::string>("type", "repository"),
44+
dataSourceConfig.second.get<std::string>("path"),
45+
dataSourceConfig.second.get<std::string>("name"),
46+
dataSourceConfig.second.get<std::string>("reductorName"),
47+
dataSourceConfig.second.get<std::string>("moduleName") });
48+
} else {
49+
throw std::runtime_error("No 'name' value or a 'names' vector in the path 'qc.postprocessing." + name + ".dataSources'");
50+
}
3851
}
3952
}
4053

Framework/test/testTrendingTask.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
{
4040
"type": "repository-quality",
4141
"path": "qc/checks/TST",
42-
"name": "testTrendingTaskCheck",
42+
"names": [ "testTrendingTaskCheck" ],
4343
"reductorName": "o2::quality_control_modules::common::QualityReductor",
4444
"moduleName": "QcCommon"
4545
}

doc/PostProcessing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ As this class is a post-processing task, it inherits also its configuration JSON
167167
}
168168
```
169169

170-
Data sources are defined by filling the corresponding structure, as in the example below. For the key `"type"` use the value `"repository"` if you access a Monitor Object and `"repository-quality"` if that should be a Quality (this will be unified in the future). The fields `"path"` and `"name"` should point to the object in the repository. The values of `"reductorName"` and `"moduleName"` should point to a full name of a data Reductor and a library where it is located. One can use the Reductors available in the `Common` module or write their own by inheriting the interface class.
170+
Data sources are defined by filling the corresponding structure, as in the example below. For the key `"type"` use the value `"repository"` if you access a Monitor Object and `"repository-quality"` if that should be a Quality (this will be unified in the future). The `"names"` array should point to one or more objects under a common `"path"` in the repository. The values of `"reductorName"` and `"moduleName"` should point to a full name of a data Reductor and a library where it is located. One can use the Reductors available in the `Common` module or write their own by inheriting the interface class.
171171

172172
``` json
173173
{
@@ -176,14 +176,14 @@ Data sources are defined by filling the corresponding structure, as in the examp
176176
{
177177
"type": "repository",
178178
"path": "qc/TST/QcTask",
179-
"name": "example",
179+
"names": [ "example" ],
180180
"reductorName": "o2::quality_control_modules::common::TH1Reductor",
181181
"moduleName": "QcCommon"
182182
},
183183
{
184184
"type": "repository-quality",
185185
"path": "qc/checks",
186-
"name": "QcCheck",
186+
"names": [ "QcCheck" ],
187187
"reductorName": "o2::quality_control_modules::common::QualityReductor",
188188
"moduleName": "QcCommon"
189189
}

0 commit comments

Comments
 (0)