Skip to content

Commit

Permalink
Added FinalPath
Browse files Browse the repository at this point in the history
OutputModules on FinalPaths do not cause unscheduled execution.
  • Loading branch information
Dr15Jones committed Dec 7, 2021
1 parent a303839 commit cfaaff9
Show file tree
Hide file tree
Showing 7 changed files with 288 additions and 14 deletions.
10 changes: 1 addition & 9 deletions FWCore/Framework/src/ProductResolvers.cc
Expand Up @@ -436,15 +436,7 @@ namespace edm {
SharedResourcesAcquirer*,
ModuleCallingContext const*) const {
if (!skipCurrentProcess and worker_) {
return resolveProductImpl<true>([this]() {
edm::Exception ex(errors::UnimplementedFeature);
ex << "Attempting to run unscheduled module without doing prefetching";
std::ostringstream ost;
ost << "Calling produce method for unscheduled module " << worker_->description()->moduleName() << "/'"
<< worker_->description()->moduleLabel() << "'";
ex.addContext(ost.str());
throw ex;
});
return resolveProductImpl<false>([] {});
}
return Resolution(nullptr);
}
Expand Down
1 change: 1 addition & 0 deletions FWCore/Integration/test/BuildFile.xml
Expand Up @@ -529,5 +529,6 @@
<flags PRE_TEST="TestIntegrationProcessBlock23"/>
<flags PRE_TEST="TestIntegrationProcessBlock24"/>
</test>
<test name="TestIntegrationFinalPath" command="test_finalpath.sh"/>

</environment>
79 changes: 79 additions & 0 deletions FWCore/Integration/test/test_finalpath.sh
@@ -0,0 +1,79 @@
#!/bin/bash

LOCAL_TEST_DIR=${CMSSW_BASE}/src/FWCore/Integration/test
LOCAL_TMP_DIR=${CMSSW_BASE}/tmp/${SCRAM_ARCH}

# Pass in name and status
function die { echo $1: status $2 ; echo === Log file === ; cat ${3:-/dev/null} ; echo === End log file === ; exit $2; }

pushd ${LOCAL_TMP_DIR}

cat <<EOF > finalpath_expected_empty.log
EOF

cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py >& finalpath.log || die "failed test_finalpath_cfg.py" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_empty.log - || die "differences for test_finalpath_cfg.py" $?


cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py -- --schedule >& finalpath.log || die "failed test_finalpath_cfg.py --schedule" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_empty.log - || die "differences for test_finalpath_cfg.py" $?


cat <<EOF > finalpath_expected_not_found.log
did not find thing '' TEST
did not find thing '' TEST
did not find thing '' TEST
found thing 'beginLumi' TEST
found thing 'endLumi' TEST
found thing 'beginRun' TEST
found thing 'endRun' TEST
EOF
cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py -- --schedule --task >& finalpath.log || die "failed test_finalpath_cfg.py --schedule --task" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_not_found.log - || die "differences for test_finalpath_cfg.py --schedule --task" $?


cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py -- --endpath >& finalpath.log || die "failed test_finalpath_cfg.py --endpath" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_empty.log - || die "differences for test_finalpath_cfg.py --endpath" $?

cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py -- --schedule --endpath >& finalpath.log || die "failed test_finalpath_cfg.py --schedule --endpath" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_empty.log - || die "differences for test_finalpath_cfg.py --schedule --endpath" $?


cat <<EOF > finalpath_expected_found.log
found thing '' TEST
found thing '' TEST
found thing '' TEST
found thing 'beginLumi' TEST
found thing 'endLumi' TEST
found thing 'beginRun' TEST
found thing 'endRun' TEST
EOF
cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py -- --endpath --task >& finalpath.log || die "failed test_finalpath_cfg.py --endpath --task" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_found.log - || die "differences for test_finalpath_cfg.py --endpath --task" $?

cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py -- --endpath --task --schedule >& finalpath.log || die "failed test_finalpath_cfg.py --endpath --task --schedule" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_found.log - || die "differences for test_finalpath_cfg.py --endpath --task --schedule" $?

cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py -- --path --task >& finalpath.log || die "failed test_finalpath_cfg.py --path --task" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_found.log - || die "differences for test_finalpath_cfg.py --path --task" $?

cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py -- --path --task --schedule >& finalpath.log || die "failed test_finalpath_cfg.py --path --task --schedule" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_found.log - || die "differences for test_finalpath_cfg.py --path --task --schedule" $?


cat <<EOF > finalpath_expected_filter.log
did not find thing '' TEST
found thing '' TEST
did not find thing '' TEST
found thing 'beginLumi' TEST
found thing 'endLumi' TEST
found thing 'beginRun' TEST
found thing 'endRun' TEST
EOF

cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py -- --path --filter >& finalpath.log || die "failed test_finalpath_cfg.py --path --filter" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_found.log - || die "differences for test_finalpath_cfg.py --path --filter" $?


cmsRun ${LOCAL_TEST_DIR}/test_finalpath_cfg.py -- --path --filter --task >& finalpath.log || die "failed test_finalpath_cfg.py --path --filter --task" $?
grep "thing '.*' TEST" finalpath.log | diff finalpath_expected_found.log - || die "differences for test_finalpath_cfg.py --path --filter --task" $?
69 changes: 69 additions & 0 deletions FWCore/Integration/test/test_finalpath_cfg.py
@@ -0,0 +1,69 @@
import FWCore.ParameterSet.Config as cms
import argparse
import sys

parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test FinalPath.')

parser.add_argument("--schedule", help="use cms.Schedule", action="store_true")
parser.add_argument("--task", help="put EDProducer into a task", action="store_true")
parser.add_argument("--path", help="put a consumer of the product onto a Path", action="store_true")
parser.add_argument("--endpath", help="put a consumer of the product onto an EndPath", action="store_true")
parser.add_argument("--filter", action="store_true")
parser.add_argument("--tracer", help="add Tracer service", action="store_true")

print(sys.argv)
argv = sys.argv[:]
if '--' in argv:
argv.remove("--")
args, unknown = parser.parse_known_args(argv)


process = cms.Process("TEST")

process.MessageLogger.cerr.INFO.limit = 10000

process.source = cms.Source("EmptySource")

process.maxEvents.input = 3

process.thing = cms.EDProducer("ThingProducer")

scheduledPaths =[]
if args.path:
print("adding Path")
process.otherThing = cms.EDProducer("OtherThingProducer", thingTag = cms.InputTag("thing"))
p = cms.Path()
if args.filter:
process.fltr = cms.EDFilter("Prescaler", prescaleFactor = cms.int32(2), prescaleOffset=cms.int32(0))
p += process.fltr
if not args.task:
p += process.thing
p += process.otherThing
process.p = p
scheduledPaths.append(process.p)
if args.task:
process.p.associate(cms.Task(process.thing))

if args.endpath:
print("adding EndPath")
process.out2 = cms.OutputModule("AsciiOutputModule",outputCommands = cms.untracked.vstring("drop *", "keep *_thing_*_*"))
process.o = cms.EndPath(process.out2)
scheduledPaths.append(process.o)
if args.task:
process.o.associate(cms.Task(process.thing))

process.out = cms.OutputModule("GetProductCheckerOutputModule", verbose= cms.untracked.bool(True), outputCommands = cms.untracked.vstring("drop *", "keep *_thing_*_*"))
process.f = cms.FinalPath(process.out)

if args.schedule:
print("adding Schedule")
scheduledPaths.append(process.f)
process.schedule = cms.Schedule(*scheduledPaths)
if args.task:
process.schedule.associate(cms.Task(process.thing))

if args.tracer:
process.add_(cms.Service("Tracer"))

process.options.numberOfThreads=3
process.options.numberOfStreams=1

0 comments on commit cfaaff9

Please sign in to comment.