Skip to content

Commit

Permalink
Throw GetByLabelWithoutRegistration exception also when no module in …
Browse files Browse the repository at this point in the history
…a job registered consumption of a given branch
  • Loading branch information
makortel committed Jul 28, 2022
1 parent abae3b4 commit 7b2d9a7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
28 changes: 28 additions & 0 deletions FWCore/Framework/src/Principal.cc
Expand Up @@ -769,6 +769,24 @@ namespace edm {
inputTag.instance(),
appendCurrentProcessIfAlias(inputTag.process(), processConfiguration_->processName()));
} else if (index == ProductResolverIndexInvalid) {
// can occur because of missing consumes if nothing else in the process consumes the product
for (auto const& item : preg_->productList()) {
auto const& bd = item.second;
if (bd.present() and bd.unwrappedTypeID() == typeID and bd.moduleLabel() == inputTag.label() and
bd.productInstanceName() == inputTag.instance()) {
bool const inCurrentProcess = bd.processName() == processConfiguration_->processName();
if (inputTag.process().empty() or bd.processName() == inputTag.process() or
(skipCurrentProcess and not inCurrentProcess) or
(inputTag.process() == InputTag::kCurrentProcess and inCurrentProcess)) {
failedToRegisterConsumes(
kindOfType,
typeID,
inputTag.label(),
inputTag.instance(),
appendCurrentProcessIfAlias(inputTag.process(), processConfiguration_->processName()));
}
}
}
return nullptr;
}
inputTag.tryToCacheIndex(index, typeID, branchType(), &productRegistry());
Expand Down Expand Up @@ -808,6 +826,16 @@ namespace edm {
if (index == ProductResolverIndexAmbiguous) {
throwAmbiguousException("findProductByLabel", typeID, label, instance, process);
} else if (index == ProductResolverIndexInvalid) {
// can occur because of missing consumes if nothing else in the process consumes the product
for (auto const& item : preg_->productList()) {
auto const& bd = item.second;
if (bd.present() and bd.unwrappedTypeID() == typeID and bd.moduleLabel() == label and
bd.productInstanceName() == instance) {
if (process.empty() or bd.processName() == process) {
failedToRegisterConsumes(kindOfType, typeID, label, instance, process);
}
}
}
return nullptr;
}

Expand Down
6 changes: 1 addition & 5 deletions FWCore/Integration/test/testGetByLabelStep2_cfg.py
Expand Up @@ -48,12 +48,8 @@

if args.noConsumes:
process.intAnalyzer.consumes = False
process.intAnalyzer.accessExceptionCategory = cms.untracked.string("ProductNotFound")
process.intAnalyzer.getExceptionCategory = cms.untracked.string("GetByLabelWithoutRegistration")

if args.thing:
process.thingAnalyzer.consumes = False
process.thingAnalyzer.getExceptionCategory = cms.untracked.string("GetByLabelWithoutRegistration")

if args.otherInt:
process.intAnalyzer.getExceptionCategory = cms.untracked.string("GetByLabelWithoutRegistration")
process.intAnalyzer.accessExceptionCategory = ""

0 comments on commit 7b2d9a7

Please sign in to comment.