Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw a clear exception if OutputModule SelectEvents refers to a non-existent Path or Process #44767

Merged
merged 2 commits into from
May 1, 2024
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: 2 additions & 2 deletions FWCore/Framework/interface/WorkerInPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace edm {
typename T::TransitionInfoType const&,
ServiceToken const&,
StreamID,
typename T::Context const*);
typename T::Context const*) noexcept;

bool checkResultsOfRunWorker(bool wasEvent);

Expand Down Expand Up @@ -109,7 +109,7 @@ namespace edm {
typename T::TransitionInfoType const& info,
ServiceToken const& token,
StreamID streamID,
typename T::Context const* context) {
typename T::Context const* context) noexcept {
rappoccio marked this conversation as resolved.
Show resolved Hide resolved
if constexpr (T::isEvent_) {
++timesVisited_;
}
Expand Down
37 changes: 25 additions & 12 deletions FWCore/Framework/src/Worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,31 @@ namespace edm {
auto choiceTask =
edm::make_waiting_task([id, successTask, iPrincipal, this, weakToken, &group](std::exception_ptr const*) {
ServiceRegistry::Operate guard(weakToken.lock());
// There is no reasonable place to rethrow, and implDoPrePrefetchSelection() should not throw in the first place.
CMS_SA_ALLOW try {
if (not implDoPrePrefetchSelection(id, *iPrincipal, &moduleCallingContext_)) {
timesRun_.fetch_add(1, std::memory_order_relaxed);
setPassed<true>();
waitingTasks_.doneWaiting(nullptr);
//TBB requires that destroyed tasks have count 0
if (0 == successTask->decrement_ref_count()) {
TaskSentry s(successTask);
try {
convertException::wrap([&]() {
if (not implDoPrePrefetchSelection(id, *iPrincipal, &moduleCallingContext_)) {
timesRun_.fetch_add(1, std::memory_order_relaxed);
setPassed<true>();
waitingTasks_.doneWaiting(nullptr);
//TBB requires that destroyed tasks have count 0
if (0 == successTask->decrement_ref_count()) {
TaskSentry s(successTask);
}
return;
}
return;
});

} catch (cms::Exception& e) {
e.addContext("Calling OutputModule prePrefetchSelection()");
if (moduleCallingContext_.type() == ModuleCallingContext::Type::kPlaceInPath) {
auto pathContext = moduleCallingContext_.placeInPathContext()->pathContext();
e.addContext("Running path '" + pathContext->pathName() + "'");
auto streamContext = moduleCallingContext_.getStreamContext();
std::ostringstream ost;
exceptionContext(ost, *streamContext);
e.addContext(ost.str());
}
} catch (...) {
waitingTasks_.doneWaiting(std::current_exception());
}
if (0 == successTask->decrement_ref_count()) {
group.run([successTask]() {
Expand All @@ -193,7 +205,8 @@ namespace edm {
for (auto const& item : items) {
ProductResolverIndex productResolverIndex = item.productResolverIndex();
bool skipCurrentProcess = item.skipCurrentProcess();
if (productResolverIndex != ProductResolverIndexAmbiguous) {
if (productResolverIndex != ProductResolverIndexAmbiguous and
productResolverIndex != ProductResolverIndexInvalid) {
iPrincipal->prefetchAsync(
choiceHolder, productResolverIndex, skipCurrentProcess, token, &moduleCallingContext_);
}
Expand Down
21 changes: 21 additions & 0 deletions FWCore/Framework/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,28 @@
<test name="testFWCoreFrameworkNonEventOrdering" command="test_non_event_ordering.sh"/>
<test name="testFWCoreFramework1ThreadESPrefetch" command="run_test_1_thread_es_prefetching.sh"/>
<test name="testFWCoreFrameworkModuleDeletion" command="run_module_delete_tests.sh"/>

<test name="testFWCoreFrameworkExternalWorkOutputModule" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testExternalWorkGlobalOutputModule_cfg.py"/>

<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathSameProcess" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=sameProcess 2>&amp;1 | grep 'to request a trigger name that does not exist'"/>
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathSameProcessAnotherModuleBefore" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=sameProcess --anotherModule=before 2>&amp;1 | grep 'to request a trigger name that does not exist'"/>
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathSameProcessAnotherModuleAfter" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=sameProcess --anotherModule=after 2>&amp;1 | grep 'to request a trigger name that does not exist'"/>

<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlier" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPathEarlier_cfg.py"/>
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlierProcess" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=earlierProcess 2>&amp;1 | grep 'to request a trigger name that does not exist'">
<flags PRE_TEST="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlier"/>
</test>
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlierProcessBefore" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=earlierProcess --anotherModule=before 2>&amp;1 | grep 'to request a trigger name that does not exist'">
<flags PRE_TEST="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlier"/>
</test>
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlierProcessAfter" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=earlierProcess --anotherModule=after 2>&amp;1 | grep 'to request a trigger name that does not exist'">
<flags PRE_TEST="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlier"/>
</test>

<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathMissingProcess" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=missingProcess 2>&amp;1 | grep 'An exception of category .ProductNotFound'"/>
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathMissingProcessAnotherModuleBefore" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=missingProcess --anotherModule=before 2>&amp;1 | grep 'An exception of category .ProductNotFound'"/>
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathMissingProcessAnotherModuleAfter" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=missingProcess --anotherModule=after 2>&amp;1 | grep 'An exception of category .ProductNotFound'"/>

<test name="testFWCoreFrameworkBadScheduleException0" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/test_bad_schedule_exception_message_cfg.py 0; grep -v 'Fatal Exception' test_bad_schedule_0.log | diff -q ${LOCALTOP}/src/FWCore/Framework/test/unit_test_outputs/test_bad_schedule_0.log -"/>
<test name="testFWCoreFrameworkBadScheduleException1" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/test_bad_schedule_exception_message_cfg.py 1; grep -v 'Fatal Exception' test_bad_schedule_1.log | diff -q ${LOCALTOP}/src/FWCore/Framework/test/unit_test_outputs/test_bad_schedule_1.log -"/>
<test name="testFWCoreFrameworkBadScheduleException2" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/test_bad_schedule_exception_message_cfg.py 2; grep -v 'Fatal Exception' test_bad_schedule_2.log | diff -q ${LOCALTOP}/src/FWCore/Framework/test/unit_test_outputs/test_bad_schedule_2.log -"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("EARLIER")

process.source = cms.Source("EmptySource")
process.maxEvents.input = 3

process.out = cms.OutputModule("PoolOutputModule",
fileName = cms.untracked.string("testOutputModuleSelectEventsMissingPath.root")
)

process.intprod = cms.EDProducer("IntProducer", ivalue=cms.int32(3))

process.p = cms.Path(process.intprod)

process.ep3 = cms.EndPath(process.out)

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import FWCore.ParameterSet.Config as cms

import argparse
import sys
parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test OutputModule SelectEvents referring to a non-existent Path and/or Process ')
parser.add_argument("--missingPath", type=str, required=True, help="Specify how the specified Path is missing. Can be 'sameProcess', 'earlierProcess', 'missingProcess'")
parser.add_argument("--anotherModule", type=str, default="", help="Specify placement of another producer. Can be empty (default), 'before', 'after")
args = parser.parse_args()

process = cms.Process("TEST")

process.source = cms.Source("EmptySource")
if args.missingPath == "earlierProcess":
process.source = cms.Source("PoolSource", fileNames=cms.untracked.vstring("file:testOutputModuleSelectEventsMissingPath.root"))
process.maxEvents.input = 3

selectEvents = {
"sameProcess" : "nonexistent_path:TEST",
"earlierProcess" : "nonexistent_path:EARLIER",
"missingProcess" : "nonexistent_path:NONEXISTENT_PROCESS",
}

process.out = cms.OutputModule("SewerModule",
SelectEvents = cms.untracked.PSet(
SelectEvents = cms.vstring(selectEvents[args.missingPath])
),
name = cms.string("out"),
shouldPass = cms.int32(1)
)

process.ep = cms.EndPath(process.out)

process.intprod = cms.EDProducer("IntProducer", ivalue=cms.int32(3))
if args.anotherModule == "before":
process.ep.insert(0, process.intprod)
elif args.anotherModule == "after":
process.ep += process.intprod
elif args.anotherModule != "":
raise Exception("Invalid value for anotherModule '{}'".format(args.anotherModule))

process.add_(cms.Service('ZombieKillerService', secondsBetweenChecks=cms.untracked.uint32(2)))