Skip to content

Commit 90cbdfa

Browse files
shahor02davidrohr
authored andcommitted
Add extra checks for Populator, fix option/readme
1 parent 819e54d commit 90cbdfa

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

Detectors/Calibration/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ o2-calibration-ccdb-populator-workflow --sspec-min 0 --sspec-max 1 -b
102102
then the `ObjA` will be uploaded only to the default server (`http://alice-ccdb.cern.ch`), `ObjB` will be uploaded to both default and `local` server and
103103
`ObjC` will be uploaded to the `local` server only.
104104
105-
But default the ccdb-populator-workflow will produce `fatal` on failed upload. To avoid this a switch `--no-fatal-on-failure` can be used.
105+
By default the ccdb-populator-workflow will not produce `fatal` on failed upload. To require it an option `--fatal-on-failure` can be used.
106106
<!-- doxy
107107
* \subpage refDetectorsCalibrationtestMacros
108108
/doxy -->

Detectors/Calibration/workflow/CCDBPopulatorSpec.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,20 @@ class CCDBPopulator : public o2::framework::Task
4646
mCCDBpath = ic.options().get<std::string>("ccdb-path");
4747
mSSpecMin = ic.options().get<std::int64_t>("sspec-min");
4848
mSSpecMax = ic.options().get<std::int64_t>("sspec-max");
49-
mFatalOnFailure = ic.options().get<bool>("no-fatal-on-failure");
49+
mFatalOnFailure = ic.options().get<bool>("fatal-on-failure");
5050
mAPI.init(mCCDBpath);
5151
}
5252

5353
void run(o2::framework::ProcessingContext& pc) final
5454
{
5555
int nSlots = pc.inputs().getNofParts(0);
56-
assert(pc.inputs().getNofParts(1) == nSlots);
56+
if (nSlots != pc.inputs().getNofParts(1)) {
57+
LOGP(alarm, "Number of slots={} in part0 is different from that ({}) in part1", nSlots, pc.inputs().getNofParts(1));
58+
return;
59+
} else if (nSlots == 0) {
60+
LOG(alarm) << "0 slots received";
61+
return;
62+
}
5763
auto runNoFromDH = pc.services().get<o2::framework::TimingInfo>().runNumber;
5864
std::string runNoStr;
5965
if (runNoFromDH > 0) {
@@ -63,6 +69,14 @@ class CCDBPopulator : public o2::framework::Task
6369
for (int isl = 0; isl < nSlots; isl++) {
6470
auto refWrp = pc.inputs().get("clbWrapper", isl);
6571
auto refPld = pc.inputs().get("clbPayload", isl);
72+
if (!o2::framework::DataRefUtils::isValid(refWrp)) {
73+
LOGP(info, "Wrapper is not valid for slot {}", isl);
74+
continue;
75+
}
76+
if (!o2::framework::DataRefUtils::isValid(refPld)) {
77+
LOGP(info, "Payload is not valid for slot {}", isl);
78+
continue;
79+
}
6680
if (mSSpecMin >= 0 && mSSpecMin <= mSSpecMax) { // there is a selection
6781
auto ss = std::int64_t(o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(refWrp)->subSpecification);
6882
if (ss < mSSpecMin || ss > mSSpecMax) {
@@ -71,6 +85,11 @@ class CCDBPopulator : public o2::framework::Task
7185
}
7286
const auto wrp = pc.inputs().get<CcdbObjectInfo*>(refWrp);
7387
const auto pld = pc.inputs().get<gsl::span<char>>(refPld); // this is actually an image of TMemFile
88+
if (!wrp) {
89+
LOGP(alarm, "No CcdbObjectInfo info for {} at slot {}",
90+
o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(refWrp)->dataDescription.as<std::string>(), isl);
91+
continue;
92+
}
7493
const auto* md = &wrp->getMetaData();
7594
if (runNoFromDH > 0 && md->find(o2::base::NameConf::CCDBRunTag.data()) == md->end()) { // if valid run number is provided and it is not filled in the metadata, add it to the clone
7695
metadata = *md; // clone since the md from the message is const
@@ -93,6 +112,11 @@ class CCDBPopulator : public o2::framework::Task
93112
}
94113
}
95114

115+
void endOfStream(o2::framework::EndOfStreamContext& ec) final
116+
{
117+
LOG(info) << "EndOfStream received";
118+
}
119+
96120
private:
97121
CcdbApi mAPI;
98122
bool mFatalOnFailure = true; // produce fatal on failed upload
@@ -121,7 +145,7 @@ DataProcessorSpec getCCDBPopulatorDeviceSpec(const std::string& defCCDB, const s
121145
{"ccdb-path", VariantType::String, defCCDB, {"Path to CCDB"}},
122146
{"sspec-min", VariantType::Int64, -1L, {"min subspec to accept"}},
123147
{"sspec-max", VariantType::Int64, -1L, {"max subspec to accept"}},
124-
{"no-fatal-on-failure", VariantType::Bool, false, {"do not produce fatal on failed upload"}}}};
148+
{"fatal-on-failure", VariantType::Bool, false, {"do not produce fatal on failed upload"}}}};
125149
}
126150

127151
} // namespace framework

0 commit comments

Comments
 (0)