Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:40

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 import sys
0004 import argparse
0005 
0006 parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test TryToContinue exception handling.')
0007 
0008 parser.add_argument("--useTask", help="Put failing module in a Task", action="store_true")
0009 parser.add_argument("--inRun", help="throw exception in begin run", action="store_true")
0010 parser.add_argument("--inLumi", help="throw exception in begin lumi", action="store_true")
0011 
0012 args = parser.parse_args()
0013 
0014 process = cms.Process("TEST")
0015 
0016 process.source = cms.Source("EmptySource")
0017 
0018 process.options.TryToContinue = ['NotFound']
0019 process.maxEvents.input = 3
0020 
0021 if args.inRun:
0022     process.fail = cms.EDProducer("edmtest::FailingInRunProducer")
0023 elif args.inLumi:
0024     process.fail = cms.EDProducer("edmtest::FailingInLumiProducer")
0025 else:
0026     process.fail = cms.EDProducer("FailingProducer")
0027 
0028 process.shouldRun1 = cms.EDAnalyzer("edmtest::global::StreamIntAnalyzer", transitions = cms.int32(4+3), nLumis = cms.untracked.uint32(1), verbose = cms.untracked.bool(False))
0029 process.shouldRun2 = cms.EDAnalyzer("edmtest::global::StreamIntAnalyzer", transitions = cms.int32(4+3), nLumis = cms.untracked.uint32(1), verbose = cms.untracked.bool(False))
0030 process.shouldNotRun = cms.EDAnalyzer("edmtest::global::StreamIntAnalyzer", transitions = cms.int32(4), nLumis = cms.untracked.uint32(1), verbose = cms.untracked.bool(False))
0031 process.dependentFilter = cms.EDFilter("IntProductFilter",
0032    label = cms.InputTag("fail"),
0033    threshold = cms.int32(0),
0034    shouldProduce = cms.bool(False)
0035 )
0036 
0037 process.intProd = cms.EDProducer("IntProducer", ivalue = cms.int32(10))
0038 process.addInts = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProd"))
0039 
0040 process.dependentAnalyzer = cms.EDAnalyzer("TestFindProduct",
0041   inputTags = cms.untracked.VInputTag( cms.InputTag("fail"), cms.InputTag("addInts") ),
0042   expectedSum = cms.untracked.int32(0)
0043 )
0044 
0045 process.independentAnalyzer = cms.EDAnalyzer("TestFindProduct",
0046   inputTags = cms.untracked.VInputTag( cms.InputTag("addInts") ),
0047   expectedSum = cms.untracked.int32(30)
0048 )
0049 
0050 if args.inRun:
0051     process.independentAnalyzer.expectedSum = 0
0052     process.shouldRun1.transitions=2
0053     process.shouldRun2.transitions=2
0054     process.shouldNotRun.transitions=2
0055     process.shouldRun1.nLumis=0
0056     process.shouldRun2.nLumis=0
0057     process.shouldNotRun.nLumis=0
0058 
0059 if args.inLumi:
0060     process.independentAnalyzer.expectedSum = 0
0061     process.shouldRun1.transitions=4
0062     process.shouldRun2.transitions=4
0063     process.shouldNotRun.transitions=4
0064     process.shouldRun1.nLumis=0
0065     process.shouldRun2.nLumis=0
0066     process.shouldNotRun.nLumis=0
0067 
0068 process.seq = cms.Sequence()
0069 process.t = cms.Task(process.intProd,process.addInts)
0070 if args.useTask:
0071     process.t.add(process.fail)
0072 else:
0073     process.seq = cms.Sequence(process.fail)
0074 process.errorPath = cms.Path(process.seq+process.shouldRun1+process.dependentFilter+process.shouldNotRun,process.t)
0075 process.goodPath = cms.Path(process.shouldRun2)
0076 
0077 
0078 process.errorEndPath = cms.EndPath(process.dependentAnalyzer)
0079 process.goodEndPath = cms.EndPath(process.independentAnalyzer)