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

Updated test of edm::Ref use from a merged ROOT file #47060

Merged
merged 1 commit into from
Jan 9, 2025
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
26 changes: 18 additions & 8 deletions FWCore/Integration/test/ref_merge_cfg.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import FWCore.ParameterSet.Config as cms
import argparse
import sys

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

parser.add_argument("--inFile1", help="first file to read")
parser.add_argument("--inFile2", help="second file to read")
parser.add_argument("--outFile", help="name of output file", default="ref_merge.root")

args = parser.parse_args()

process = cms.Process("MERGE")

process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring("file:ref_merge_prod1.root",
"file:ref_merge_prod2.root")
from IOPool.Input.modules import PoolSource
process.source = PoolSource(fileNames = [f"file:{args.inFile1}",
f"file:{args.inFile2}"]
)

process.out = cms.OutputModule("PoolOutputModule",
fileName = cms.untracked.string("ref_merge.root")
)
from IOPool.Output.modules import PoolOutputModule
process.out = PoolOutputModule(fileName = args.outFile)

process.tester = cms.EDAnalyzer("OtherThingAnalyzer",
other = cms.untracked.InputTag("d","testUserTag"))
from FWCore.Integration.modules import OtherThingAnalyzer
process.tester = OtherThingAnalyzer(other = ("d","testUserTag"))

process.o = cms.EndPath(process.out+process.tester)

39 changes: 0 additions & 39 deletions FWCore/Integration/test/ref_merge_prod1_cfg.py

This file was deleted.

34 changes: 0 additions & 34 deletions FWCore/Integration/test/ref_merge_prod2_cfg.py

This file was deleted.

63 changes: 63 additions & 0 deletions FWCore/Integration/test/ref_merge_prod_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import FWCore.ParameterSet.Config as cms

import argparse
import sys

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

parser.add_argument("--extraProducers", help="Add extra producers to configuration", action="store_true")
parser.add_argument("--fileName", help="name of output file")
parser.add_argument("--firstLumi", help="LuminosityBlock number for first lumi", type = int, default=1)
parser.add_argument("--keepAllProducts", help="Keep all products made in the job", action="store_true")
parser.add_argument("--dropThings", help="drop the Things collections so the refs will not function", action="store_true")

args = parser.parse_args()


process = cms.Process("PROD")

nEvents = 10
from FWCore.Modules.modules import EmptySource
process.source = EmptySource(
firstLuminosityBlock = args.firstLumi,
firstEvent = nEvents*(args.firstLumi-1)+1
)

process.maxEvents.input = nEvents

if args.extraProducers:
from FWCore.Framework.modules import IntProducer
process.a = IntProducer(ivalue = 1)

process.b = IntProducer(ivalue = 2)

from FWCore.Integration.modules import ThingProducer, OtherThingProducer, OtherThingAnalyzer
process.c = ThingProducer()

process.d = OtherThingProducer(thingTag="c")

outputs = []
if not args.keepAllProducts:
outputs = ["drop *",
"keep edmtestOtherThings_*_*_*"]
if not args.dropThings:
outputs.append("keep edmtestThings_*_*_*")


from IOPool.Output.modules import PoolOutputModule
process.o = PoolOutputModule(outputCommands = outputs,
fileName = args.fileName
)
if args.extraProducers:
process.p = cms.Path(process.a+process.b+process.c*process.d)
else:
process.p = cms.Path(process.c*process.d)

process.tester = OtherThingAnalyzer(other = ("d","testUserTag"))

process.out = cms.EndPath(process.o+process.tester)





18 changes: 13 additions & 5 deletions FWCore/Integration/test/ref_merge_test_cfg.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import FWCore.ParameterSet.Config as cms
import argparse
import sys

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

parser.add_argument("--fileName", help="file to read")

args = parser.parse_args()

process = cms.Process("TEST")

process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring("file:ref_merge.root")
)
from IOPool.Input.modules import PoolSource
process.source = PoolSource(fileNames = [f"file:{args.fileName}"])

process.tester = cms.EDAnalyzer("OtherThingAnalyzer",
other = cms.untracked.InputTag("d","testUserTag"))
from FWCore.Integration.modules import OtherThingAnalyzer
process.tester = OtherThingAnalyzer(other = ("d","testUserTag"))

process.e = cms.EndPath(process.tester)

20 changes: 16 additions & 4 deletions FWCore/Integration/test/run_RefMerge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,28 @@ function die { echo Failure $1: status $2 ; exit $2 ; }

LOCAL_TEST_DIR=${SCRAM_TEST_PATH}
echo ${test}prod1 ------------------------------------------------------------
cmsRun ${LOCAL_TEST_DIR}/${test}prod1_cfg.py || die "cmsRun ${test}prod1_cfg.py" $?
cmsRun ${LOCAL_TEST_DIR}/${test}prod_cfg.py --extraProducers --fileName 'ref_merge_prod1.root' || die "cmsRun ${test}prod_cfg.py --extraProducers" $?

echo ${test}prod2 ------------------------------------------------------------
cmsRun ${LOCAL_TEST_DIR}/${test}prod2_cfg.py || die "cmsRun ${test}prod2_cfg.py" $?
cmsRun ${LOCAL_TEST_DIR}/${test}prod_cfg.py --firstLumi 10 --fileName 'ref_merge_prod2.root'|| die "cmsRun ${test}prod_cfg.py" $?

echo ${test}MERGE------------------------------------------------------------
cmsRun ${LOCAL_TEST_DIR}/${test}cfg.py || die "cmsRun ${test}cfg.py" $?
cmsRun ${LOCAL_TEST_DIR}/${test}cfg.py --inFile1 'ref_merge_prod1.root' --inFile2 'ref_merge_prod2.root' --outFile 'ref_merge.root' || die "cmsRun ${test}cfg.py" $?

echo ${test}test------------------------------------------------------------
cmsRun ${LOCAL_TEST_DIR}/${test}test_cfg.py || die "cmsRun ${test}test_cfg.py" $?
cmsRun ${LOCAL_TEST_DIR}/${test}test_cfg.py --fileName 'ref_merge.root' || die "cmsRun ${test}test_cfg.py" $?

echo ${test}keepAllProd ------------------------------------------------------------
cmsRun ${LOCAL_TEST_DIR}/${test}prod_cfg.py --extraProducers --keepAllProducts --fileName 'ref_merge_prod_all.root' || die "cmsRun ${test}prod_cfg.py --keepAllProducts" $?

echo ${test}MERGE_keepAll1st ------------------------------------------------------------
cmsRun ${LOCAL_TEST_DIR}/${test}cfg.py --inFile1 'ref_merge_prod_all.root' --inFile2 'ref_merge_prod2.root' --outFile 'ref_merge_all1st.root' || die "cmsRun ${test}cfg.py" $?

echo ${test}test_all1st------------------------------------------------------------
cmsRun ${LOCAL_TEST_DIR}/${test}test_cfg.py --fileName 'ref_merge_all1st.root' || die "cmsRun ${test}test_cfg.py all1st" $?

#note having all be the second file does not work as PoolSource enforces that subsequent files must have a strict subset
# of the branches in the first file read
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a test with the other way around, where cmsRun would fail, be worth it? Or is it tested already somewhere?

Copy link
Contributor Author

@Dr15Jones Dr15Jones Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think such a test belongs in this particular suite as it is not a test of Refs just file compatibility. If it does exist, it should probably be in IPool/Input. From a quick look, it does not appear to exist there.


echo ${test}test------------------------------------------------------------
cmsRun ${LOCAL_TEST_DIR}/${test}subprocess_cfg.py || die "cmsRun ${test}subprocess_cfg.py" $?
Expand Down