Skip to content

Commit 47c4f87

Browse files
committed
Add test for reading files with different ProductRegistries
This checks a fix made in an early pull request.
1 parent 76ecfc5 commit 47c4f87

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

IOPool/Tests/test/BuildFile.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,5 @@
118118
<test name="TestParentageWithStreamerIO" command="run_ParentageWithStreamerIO.sh"/>
119119

120120
<test name="TestIOPoolUnscheduledFailOnOutput" command="run_unscheduledFailOnOutput.sh"/>
121+
122+
<test name="TestIOPoolDifferentProductRegistries" command="runDifferentProductRegistries.sh"/>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
function die { echo Failure $1: status $2 ; exit $2 ; }
4+
5+
# Set the directory holding the configuration files
6+
LOCAL_TEST_DIR=${SCRAM_TEST_PATH}
7+
8+
# Run first write job (events starting at 1)
9+
cmsRun ${LOCAL_TEST_DIR}/testDifferentProductRegistriesWrite_cfg.py --startEvent 1 --outputFile write1.root || die "cmsRun write1" $?
10+
11+
# Run second write job (events starting at 4)
12+
cmsRun ${LOCAL_TEST_DIR}/testDifferentProductRegistriesWrite_cfg.py --startEvent 4 --outputFile write2.root || die "cmsRun write2" $?
13+
14+
# Run read job with both output files as input
15+
cmsRun ${LOCAL_TEST_DIR}/testDifferentProductRegistriesRead_cfg.py --inputFiles file:write1.root file:write2.root || die "cmsRun read 1 then 2" $?
16+
17+
cmsRun ${LOCAL_TEST_DIR}/testDifferentProductRegistriesRead_cfg.py --inputFiles file:write2.root file:write1.root || die "cmsRun read 2 then 1" $?
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import FWCore.ParameterSet.Config as cms
2+
import argparse
3+
4+
parser = argparse.ArgumentParser(description="cmsRun config for reading two files with different product registries")
5+
parser.add_argument("--inputFiles", nargs=2, required=True, help="Input files for PoolSource (two required)")
6+
args, unknown = parser.parse_known_args()
7+
8+
process = cms.Process("READ")
9+
10+
from IOPool.Input.modules import PoolSource
11+
process.source = PoolSource(
12+
fileNames = cms.untracked.vstring(*args.inputFiles)
13+
)
14+
15+
from FWCore.Modules.modules import AsciiOutputModule
16+
process.asciiOut = AsciiOutputModule()
17+
process.outpath = cms.EndPath(process.asciiOut)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import FWCore.ParameterSet.Config as cms
2+
import argparse
3+
4+
5+
parser = argparse.ArgumentParser(description="cmsRun config for testing writing product registries with different content")
6+
parser.add_argument("--startEvent", type=int, default=1, help="First event number for EmptySource")
7+
parser.add_argument("--outputFile", type=str, default=None, help="Output file name for PoolOutputModule")
8+
args, unknown = parser.parse_known_args()
9+
10+
process = cms.Process("TEST")
11+
12+
process.maxEvents.input = 3
13+
from FWCore.Modules.modules import EmptySource
14+
process.source = EmptySource(
15+
firstRun = 1,
16+
firstLuminosityBlock = 1,
17+
firstEvent = args.startEvent
18+
)
19+
20+
21+
from FWCore.Modules.modules import EventIDFilter
22+
process.eventIDFilter = EventIDFilter(
23+
eventsToPass = [
24+
cms.EventID(1,1,1),
25+
cms.EventID(1,1,2),
26+
cms.EventID(1,1,3)
27+
]
28+
)
29+
30+
31+
from FWCore.Integration.modules import ThingProducer, OtherThingProducer
32+
process.thing = ThingProducer()
33+
process.otherThing = OtherThingProducer(thingTag="thing")
34+
35+
# Path: EventIDFilter -> ThingProducer -> OtherThingProducer
36+
process.p = cms.Path(
37+
process.eventIDFilter +
38+
process.thing +
39+
process.otherThing
40+
)
41+
42+
from IOPool.Output.modules import PoolOutputModule
43+
output_file = args.outputFile if args.outputFile is not None else f'testDifferentProductRegistriesWrite{args.startEvent}.root'
44+
process.out = PoolOutputModule(
45+
outputCommands = [
46+
"keep *",
47+
'drop *_thing_*_*'
48+
],
49+
fileName = output_file
50+
)
51+
52+
process.e = cms.EndPath(process.out)

0 commit comments

Comments
 (0)