Skip to content

Commit

Permalink
Limit the GUID override to the first output file only
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed May 9, 2022
1 parent de84af7 commit 42dc4a6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
8 changes: 6 additions & 2 deletions IOPool/Output/src/PoolOutputModule.cc
Expand Up @@ -392,6 +392,9 @@ namespace edm {
names.second,
processesWithSelectedMergeableRunProducts_,
overrideGUID_); // propagate_const<T> has no reset() function
// Override the GUID of the first file only, in order to avoid two
// output files from one Output Module to have identical GUID.
overrideGUID_.clear();
}

void PoolOutputModule::updateBranchParentsForOneBranch(ProductProvenanceRetriever const* provRetriever,
Expand Down Expand Up @@ -511,8 +514,9 @@ namespace edm {
"'ALL': Drop all of it.");
desc.addUntracked<std::string>("overrideGUID", defaultString)
->setComment(
"Allows to override the GUID of the file. Intended to be used only in Tier0 for re-creating files. The "
"GUID needs to be of the proper format.");
"Allows to override the GUID of the file. Intended to be used only in Tier0 for re-creating files.\n"
"The GUID needs to be of the proper format. If a new output file is started (see maxSize), the GUID of\n"
"the first file only is overridden, i.e. the subsequent output files have different, generated GUID.");
{
ParameterSetDescription dataSet;
dataSet.setAllowAnything();
Expand Down
15 changes: 12 additions & 3 deletions IOPool/Output/test/PoolOutputTestOverrideGUID_cfg.py
Expand Up @@ -4,13 +4,15 @@
import sys
parser = argparse.ArgumentParser(prog=sys.argv[0], description="Test PoolOutputModule")
parser.add_argument("--guid", type=str, help="GUID that overrides")
parser.add_argument("--maxSize", type=int, default=None, help="Set maximum file size")
parser.add_argument("--input", type=str, default=[], nargs="*", help="Optional list of input files")

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

process = cms.Process("TESTOUTPUT")
process = cms.Process("TESTOUTPUTGUID")
process.load("FWCore.Framework.test.cmsExceptionsFatal_cff")

process.maxEvents.input = 20
Expand All @@ -19,12 +21,19 @@

process.OtherThing = cms.EDProducer("OtherThingProducer")

process.source = cms.Source("EmptySource")
if len(args.input) > 0:
process.maxEvents.input = -1
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring("file:"+x for x in args.input)
)

process.output = cms.OutputModule("PoolOutputModule",
fileName = cms.untracked.string('file:PoolOutputTestOverrideGUID.root'),
overrideGUID = cms.untracked.string(args.guid),
)

process.source = cms.Source("EmptySource")
if args.maxSize is not None:
process.output.maxSize = cms.untracked.int32(args.maxSize)

process.p = cms.Path(process.Thing*process.OtherThing)
process.ep = cms.EndPath(process.output)
Expand Down
19 changes: 16 additions & 3 deletions IOPool/Output/test/PoolOutputTest_cfg.py
@@ -1,11 +1,21 @@
import FWCore.ParameterSet.Config as cms

import argparse
import sys
parser = argparse.ArgumentParser(prog=sys.argv[0], description="Test PoolOutputModule")
parser.add_argument("--firstLumi", type=int, default=None, help="Set first lumi to process ")

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


process = cms.Process("TESTOUTPUT")
process.load("FWCore.Framework.test.cmsExceptionsFatal_cff")

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(20)
)
process.maxEvents.input = 20

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

process.OtherThing = cms.EDProducer("OtherThingProducer")
Expand All @@ -15,6 +25,9 @@
)

process.source = cms.Source("EmptySource")
if args.firstLumi is not None:
process.source.firstLuminosityBlock = cms.untracked.uint32(args.firstLumi)
process.output.fileName = "file:PoolOutputTestLumi{}.root".format(args.firstLumi)

process.p = cms.Path(process.Thing*process.OtherThing)
process.ep = cms.EndPath(process.output)
Expand Down
15 changes: 15 additions & 0 deletions IOPool/Output/test/TestPoolOutput.sh
Expand Up @@ -60,4 +60,19 @@ cmsRun ${LOCAL_TEST_DIR}/PoolOutputTestOverrideGUID_cfg.py -- --guid abcdef012-3
cmsRun ${LOCAL_TEST_DIR}/PoolOutputTestOverrideGUID_cfg.py -- --guid abcdef01-2345-6789-abcd-ef012345678g && die 'PoolOutputTestOverrideGUID_cfg.py with invalid GUID 5 did not fail' 1
cmsRun ${LOCAL_TEST_DIR}/PoolOutputTestOverrideGUID_cfg.py -- --guid abcdef01-2345-6789-abcd_ef0123456789 && die 'PoolOutputTestOverrideGUID_cfg.py with invalid GUID 6 did not fail' 1

cmsRun ${LOCAL_TEST_DIR}/PoolOutputTest_cfg.py -- --firstLumi 1
cmsRun ${LOCAL_TEST_DIR}/PoolOutputTest_cfg.py -- --firstLumi 2

cmsRun ${LOCAL_TEST_DIR}/PoolOutputTestOverrideGUID_cfg.py -- --guid abcdef01-2345-6789-abcd-ef0123456789 --input PoolOutputTestLumi1.root PoolOutputTestLumi2.root --maxSize 1 || die 'Failure using PoolOutputTestOverrideGUID_cfg.py with valid GUID and two input files' $?
GUID1=$(edmFileUtil -u PoolOutputTestOverrideGUID.root | fgrep uuid | awk '{print $10}')
GUID2=$(edmFileUtil -u PoolOutputTestOverrideGUID001.root | fgrep uuid | awk '{print $10}')
if [ "x${GUID1}" != "xabcdef01-2345-6789-abcd-ef0123456789" ]; then
echo "GUID in first file '${GUID1}' did not match 'abcdef01-2345-6789-abcd-ef0123456789'"
exit 1
fi
if [ "x${GUID1}" == "x${GUID2}" ]; then
echo "GUID from two output files are the same: ${GUID1}"
exit 1
fi

popd

0 comments on commit 42dc4a6

Please sign in to comment.