Public Member Functions | |
def | setUp |
def | testCloneSequence |
def | testExamples |
def | testFreeze |
def | testGlobalReplace |
def | testImplicitSchedule |
def | testOverride |
def | testParameterizable |
def | testPath |
def | testPrefers |
def | testProcessDumpPython |
def | testProcessExtend |
def | testProcessInsertion |
def | testPrune |
def | testSchedule |
def | testSecSource |
def | testSequence |
def | testSubProcess |
def | testTypedParameterizable |
def | testUsing |
Static Public Attributes | |
tuple | d = p.dumpPython() |
tuple | p = Process("test") |
tuple | s = Sequence(p.a) |
def Config::TestModuleCommand::setUp | ( | self | ) |
def Config::TestModuleCommand::testCloneSequence | ( | self | ) |
Definition at line 1231 of file Config.py.
01232 : 01233 p = Process("test") 01234 a = EDAnalyzer("MyAnalyzer") 01235 p.a = a 01236 a.setLabel("a") 01237 b = EDAnalyzer("YOurAnalyzer") 01238 p.b = b 01239 b.setLabel("b") 01240 path = Path(a * b) 01241 p.path = Path(p.a*p.b) 01242 lookuptable = {id(a): p.a, id(b): p.b} 01243 #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable))) 01244 #lookuptable = p._cloneToObjectDict 01245 #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable))) 01246 self.assertEqual(str(path),str(p.path))
def Config::TestModuleCommand::testExamples | ( | self | ) |
Definition at line 1364 of file Config.py.
01365 : 01366 p = Process("Test") 01367 p.source = Source("PoolSource",fileNames = untracked(string("file:reco.root"))) 01368 p.foos = EDProducer("FooProducer") 01369 p.bars = EDProducer("BarProducer", foos=InputTag("foos")) 01370 p.out = OutputModule("PoolOutputModule",fileName=untracked(string("file:foos.root"))) 01371 p.bars.foos = 'Foosball' 01372 self.assertEqual(p.bars.foos, InputTag('Foosball')) 01373 p.p = Path(p.foos*p.bars) 01374 p.e = EndPath(p.out) 01375 p.add_(Service("MessageLogger"))
def Config::TestModuleCommand::testFreeze | ( | self | ) |
Definition at line 1430 of file Config.py.
01431 : 01432 process = Process("Freeze") 01433 m = EDProducer("M", p=PSet(i = int32(1))) 01434 m.p.i = 2 01435 process.m = m 01436 # should be frozen 01437 #self.assertRaises(ValueError, setattr, m.p, 'i', 3) 01438 #self.assertRaises(ValueError, setattr, m, 'p', PSet(i=int32(1))) 01439 #self.assertRaises(ValueError, setattr, m.p, 'j', 1) 01440 #self.assertRaises(ValueError, setattr, m, 'j', 1) 01441 # But OK to change through the process 01442 process.m.p.i = 4 01443 self.assertEqual(process.m.p.i.value(), 4) 01444 process.m.p = PSet(j=int32(1)) 01445 # should work to clone it, though 01446 m2 = m.clone(p = PSet(i = int32(5)), j = int32(8)) 01447 m2.p.i = 6 m2.j = 8
def Config::TestModuleCommand::testGlobalReplace | ( | self | ) |
def Config::TestModuleCommand::testImplicitSchedule | ( | self | ) |
Definition at line 1301 of file Config.py.
01302 : 01303 p = Process("test") 01304 p.a = EDAnalyzer("MyAnalyzer") 01305 p.b = EDAnalyzer("YourAnalyzer") 01306 p.c = EDAnalyzer("OurAnalyzer") 01307 p.path1 = Path(p.a) 01308 p.path2 = Path(p.b) 01309 self.assert_(p.schedule is None) 01310 pths = p.paths 01311 keys = pths.keys() 01312 self.assertEqual(pths[keys[0]],p.path1) 01313 self.assertEqual(pths[keys[1]],p.path2) 01314 p.prune() 01315 self.assert_(hasattr(p, 'a')) 01316 self.assert_(hasattr(p, 'b')) 01317 self.assert_(not hasattr(p, 'c')) 01318 self.assert_(hasattr(p, 'path1')) 01319 self.assert_(hasattr(p, 'path2')) 01320 01321 01322 p = Process("test") 01323 p.a = EDAnalyzer("MyAnalyzer") 01324 p.b = EDAnalyzer("YourAnalyzer") 01325 p.c = EDAnalyzer("OurAnalyzer") 01326 p.path2 = Path(p.b) 01327 p.path1 = Path(p.a) 01328 self.assert_(p.schedule is None) 01329 pths = p.paths 01330 keys = pths.keys() 01331 self.assertEqual(pths[keys[1]],p.path1) 01332 self.assertEqual(pths[keys[0]],p.path2) 01333
def Config::TestModuleCommand::testOverride | ( | self | ) |
Definition at line 1341 of file Config.py.
01342 : 01343 p = Process('test') 01344 a = EDProducer("A", a1=int32(0)) 01345 self.assert_(not a.isModified()) 01346 a.a1 = 1 01347 self.assert_(a.isModified()) 01348 p.a = a 01349 self.assertEqual(p.a.a1.value(), 1) 01350 # try adding an unmodified module. 01351 # should accept it 01352 p.a = EDProducer("A", a1=int32(2)) 01353 self.assertEqual(p.a.a1.value(), 2) 01354 # try adding a modified module. Should throw 01355 # no longer, since the same (modified) say, geometry 01356 # could come from more than one cff 01357 b = EDProducer("A", a1=int32(3)) 01358 b.a1 = 4 01359 #self.assertRaises(RuntimeError, setattr, *(p,'a',b)) 01360 ps1 = PSet(a = int32(1)) 01361 ps2 = PSet(a = int32(2)) 01362 self.assertRaises(ValueError, EDProducer, 'C', ps1, ps2) 01363 self.assertRaises(ValueError, EDProducer, 'C', ps1, a=int32(3))
def Config::TestModuleCommand::testParameterizable | ( | self | ) |
Definition at line 995 of file Config.py.
00996 : 00997 p = _Parameterizable() 00998 self.assertEqual(len(p.parameterNames_()),0) 00999 p.a = int32(1) 01000 self.assert_('a' in p.parameterNames_()) 01001 self.assertEqual(p.a.value(), 1) 01002 p.a = 10 01003 self.assertEqual(p.a.value(), 10) 01004 p.a = untracked(int32(1)) 01005 self.assertEqual(p.a.value(), 1) 01006 self.failIf(p.a.isTracked()) 01007 p.a = untracked.int32(1) 01008 self.assertEqual(p.a.value(), 1) 01009 self.failIf(p.a.isTracked()) 01010 p = _Parameterizable(foo=int32(10), bar = untracked(double(1.0))) 01011 self.assertEqual(p.foo.value(), 10) 01012 self.assertEqual(p.bar.value(),1.0) 01013 self.failIf(p.bar.isTracked()) 01014 self.assertRaises(TypeError,setattr,(p,'c',1)) 01015 p = _Parameterizable(a=PSet(foo=int32(10), bar = untracked(double(1.0)))) 01016 self.assertEqual(p.a.foo.value(),10) 01017 self.assertEqual(p.a.bar.value(),1.0) 01018 p.b = untracked(PSet(fii = int32(1))) 01019 self.assertEqual(p.b.fii.value(),1) 01020 self.failIf(p.b.isTracked()) 01021 #test the fact that values can be shared 01022 v = int32(10) 01023 p=_Parameterizable(a=v) 01024 v.setValue(11) 01025 self.assertEqual(p.a.value(),11) 01026 p.a = 12 01027 self.assertEqual(p.a.value(),12) self.assertEqual(v.value(),12)
def Config::TestModuleCommand::testPath | ( | self | ) |
Definition at line 1209 of file Config.py.
01210 : 01211 p = Process("test") 01212 p.a = EDAnalyzer("MyAnalyzer") 01213 p.b = EDAnalyzer("YourAnalyzer") 01214 p.c = EDAnalyzer("OurAnalyzer") 01215 path = Path(p.a) 01216 path *= p.b 01217 path += p.c 01218 self.assertEqual(str(path),'a+b+c') 01219 path = Path(p.a*p.b+p.c) 01220 self.assertEqual(str(path),'a+b+c') 01221 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences 01222 # self.assertEqual(str(path),'((a*b)+c)') 01223 path = Path(p.a+ p.b*p.c) 01224 self.assertEqual(str(path),'a+b+c') 01225 path = Path(p.a*(p.b+p.c)) 01226 self.assertEqual(str(path),'a+b+c') 01227 path = Path(p.a*(p.b+~p.c)) 01228 self.assertEqual(str(path),'a+b+~c') 01229 p.es = ESProducer("AnESProducer") 01230 self.assertRaises(TypeError,Path,p.es)
def Config::TestModuleCommand::testPrefers | ( | self | ) |
Definition at line 1376 of file Config.py.
01377 : 01378 p = Process("Test") 01379 p.add_(ESSource("ForceSource")) 01380 p.juicer = ESProducer("JuicerProducer") 01381 p.prefer("ForceSource") 01382 p.prefer("juicer") 01383 self.assertEqual(p.dumpConfig(), 01384 """process Test = { 01385 es_module juicer = JuicerProducer { 01386 } 01387 es_source = ForceSource { 01388 } 01389 es_prefer = ForceSource { 01390 } 01391 es_prefer juicer = JuicerProducer { 01392 } 01393 } 01394 """) 01395 p.prefer("juicer",fooRcd=vstring("Foo")) 01396 self.assertEqual(p.dumpConfig(), 01397 """process Test = { 01398 es_module juicer = JuicerProducer { 01399 } 01400 es_source = ForceSource { 01401 } 01402 es_prefer = ForceSource { 01403 } 01404 es_prefer juicer = JuicerProducer { 01405 vstring fooRcd = { 01406 'Foo' 01407 } 01408 01409 } 01410 } 01411 """) 01412 self.assertEqual(p.dumpPython(), 01413 """import FWCore.ParameterSet.Config as cms 01414 01415 process = cms.Process("Test") 01416 01417 process.juicer = cms.ESProducer("JuicerProducer") 01418 01419 01420 process.ForceSource = cms.ESSource("ForceSource") 01421 01422 01423 process.prefer("ForceSource") 01424 01425 process.prefer("juicer", 01426 fooRcd = cms.vstring('Foo') 01427 ) 01428 01429 """)
def Config::TestModuleCommand::testProcessDumpPython | ( | self | ) |
Definition at line 1084 of file Config.py.
01085 : 01086 p = Process("test") 01087 p.a = EDAnalyzer("MyAnalyzer") 01088 p.p = Path(p.a) 01089 p.s = Sequence(p.a) 01090 p.r = Sequence(p.s) 01091 p.p2 = Path(p.s) 01092 p.schedule = Schedule(p.p2,p.p) 01093 d=p.dumpPython() 01094 self.assertEqual(d, 01095 """import FWCore.ParameterSet.Config as cms 01096 01097 process = cms.Process("test") 01098 01099 process.a = cms.EDAnalyzer("MyAnalyzer") 01100 01101 01102 process.s = cms.Sequence(process.a) 01103 01104 01105 process.r = cms.Sequence(process.s) 01106 01107 01108 process.p = cms.Path(process.a) 01109 01110 01111 process.p2 = cms.Path(process.s) 01112 01113 01114 process.schedule = cms.Schedule(*[ process.p2, process.p ]) 01115 """) 01116 #Reverse order of 'r' and 's' 01117 p = Process("test") 01118 p.a = EDAnalyzer("MyAnalyzer") 01119 p.p = Path(p.a) 01120 p.r = Sequence(p.a) 01121 p.s = Sequence(p.r) 01122 p.p2 = Path(p.r) 01123 p.schedule = Schedule(p.p2,p.p) 01124 p.b = EDAnalyzer("YourAnalyzer") 01125 d=p.dumpPython() 01126 self.assertEqual(d, 01127 """import FWCore.ParameterSet.Config as cms 01128 01129 process = cms.Process("test") 01130 01131 process.a = cms.EDAnalyzer("MyAnalyzer") 01132 01133 01134 process.b = cms.EDAnalyzer("YourAnalyzer") 01135 01136 01137 process.r = cms.Sequence(process.a) 01138 01139 01140 process.s = cms.Sequence(process.r) 01141 01142 01143 process.p = cms.Path(process.a) 01144 01145 01146 process.p2 = cms.Path(process.r) 01147 01148 01149 process.schedule = cms.Schedule(*[ process.p2, process.p ]) """)
def Config::TestModuleCommand::testProcessExtend | ( | self | ) |
Definition at line 1057 of file Config.py.
01058 : 01059 class FromArg(object): 01060 def __init__(self,*arg,**args): 01061 for name in args.iterkeys(): 01062 self.__dict__[name]=args[name] 01063 01064 a=EDAnalyzer("MyAnalyzer") 01065 s1 = Sequence(a) 01066 s2 = Sequence(s1) 01067 s3 = Sequence(s2) 01068 d = FromArg( 01069 a=a, 01070 b=Service("Full"), 01071 c=Path(a), 01072 d=s2, 01073 e=s1, 01074 f=s3, 01075 g=Sequence(s1+s2+s3) 01076 ) 01077 p = Process("Test") 01078 p.extend(d) 01079 self.assertEqual(p.a.type_(),"MyAnalyzer") 01080 self.assertRaises(AttributeError,getattr,p,'b') 01081 self.assertEqual(p.Full.type_(),"Full") 01082 self.assertEqual(str(p.c),'a') 01083 self.assertEqual(str(p.d),'a')
def Config::TestModuleCommand::testProcessInsertion | ( | self | ) |
Definition at line 1035 of file Config.py.
01036 : 01037 p = Process("test") 01038 p.a = EDAnalyzer("MyAnalyzer") 01039 self.assert_( 'a' in p.analyzers_() ) 01040 self.assert_( 'a' in p.analyzers) 01041 p.add_(Service("MessageLogger")) 01042 self.assert_('MessageLogger' in p.services_()) 01043 self.assertEqual(p.MessageLogger.type_(), "MessageLogger") 01044 p.Tracer = Service("Tracer") 01045 self.assert_('Tracer' in p.services_()) 01046 self.assertRaises(TypeError, setattr, *(p,'b',"this should fail")) 01047 self.assertRaises(TypeError, setattr, *(p,'bad',Service("MessageLogger"))) 01048 self.assertRaises(ValueError, setattr, *(p,'bad',Source("PoolSource"))) 01049 p.out = OutputModule("Outer") 01050 self.assertEqual(p.out.type_(), 'Outer') 01051 self.assert_( 'out' in p.outputModules_() ) 01052 01053 p.geom = ESSource("GeomProd") 01054 self.assert_('geom' in p.es_sources_()) 01055 p.add_(ESSource("ConfigDB")) 01056 self.assert_('ConfigDB' in p.es_sources_())
def Config::TestModuleCommand::testPrune | ( | self | ) |
Definition at line 1487 of file Config.py.
01488 : 01489 p = Process("test") 01490 p.a = EDAnalyzer("MyAnalyzer") 01491 p.b = EDAnalyzer("YourAnalyzer") 01492 p.c = EDAnalyzer("OurAnalyzer") 01493 p.d = EDAnalyzer("OurAnalyzer") 01494 p.s = Sequence(p.d) 01495 p.path1 = Path(p.a) 01496 p.path2 = Path(p.b) 01497 self.assert_(p.schedule is None) 01498 pths = p.paths 01499 keys = pths.keys() 01500 self.assertEqual(pths[keys[0]],p.path1) 01501 self.assertEqual(pths[keys[1]],p.path2) 01502 p.prune() 01503 self.assert_(hasattr(p, 'a')) 01504 self.assert_(hasattr(p, 'b')) 01505 self.assert_(not hasattr(p, 'c')) 01506 self.assert_(not hasattr(p, 'd')) 01507 self.assert_(not hasattr(p, 's')) 01508 self.assert_(hasattr(p, 'path1')) 01509 self.assert_(hasattr(p, 'path2')) 01510 01511 p = Process("test") 01512 p.a = EDAnalyzer("MyAnalyzer") 01513 p.b = EDAnalyzer("YourAnalyzer") 01514 p.c = EDAnalyzer("OurAnalyzer") 01515 p.d = EDAnalyzer("OurAnalyzer") 01516 p.e = EDAnalyzer("OurAnalyzer") 01517 p.s = Sequence(p.d) 01518 p.s2 = Sequence(p.b) 01519 p.s3 = Sequence(p.e) 01520 p.path1 = Path(p.a) 01521 p.path2 = Path(p.b) 01522 p.path3 = Path(p.b+p.s2) 01523 p.path4 = Path(p.b+p.s3) 01524 p.schedule = Schedule(p.path1,p.path2,p.path3) 01525 pths = p.paths 01526 keys = pths.keys() 01527 self.assertEqual(pths[keys[0]],p.path1) 01528 self.assertEqual(pths[keys[1]],p.path2) 01529 p.prune() 01530 self.assert_(hasattr(p, 'a')) 01531 self.assert_(hasattr(p, 'b')) 01532 self.assert_(not hasattr(p, 'c')) 01533 self.assert_(not hasattr(p, 'd')) 01534 self.assert_(not hasattr(p, 'e')) 01535 self.assert_(not hasattr(p, 's')) 01536 self.assert_(hasattr(p, 's2')) 01537 self.assert_(not hasattr(p, 's3')) 01538 self.assert_(hasattr(p, 'path1')) 01539 self.assert_(hasattr(p, 'path2')) 01540 self.assert_(hasattr(p, 'path3')) 01541 self.assert_(not hasattr(p, 'path4')) 01542 #test SequencePlaceholder 01543 p = Process("test") 01544 p.a = EDAnalyzer("MyAnalyzer") 01545 p.b = EDAnalyzer("YourAnalyzer") 01546 p.s = Sequence(SequencePlaceholder("a")+p.b) 01547 p.pth = Path(p.s) 01548 p.prune() 01549 self.assert_(hasattr(p, 'a')) 01550 self.assert_(hasattr(p, 'b')) 01551 self.assert_(hasattr(p, 's')) 01552 self.assert_(hasattr(p, 'pth')) 01553 unittest.main()
def Config::TestModuleCommand::testSchedule | ( | self | ) |
Definition at line 1247 of file Config.py.
01248 : 01249 p = Process("test") 01250 p.a = EDAnalyzer("MyAnalyzer") 01251 p.b = EDAnalyzer("YourAnalyzer") 01252 p.c = EDAnalyzer("OurAnalyzer") 01253 p.d = EDAnalyzer("OurAnalyzer") 01254 p.path1 = Path(p.a) 01255 p.path2 = Path(p.b) 01256 p.path3 = Path(p.d) 01257 01258 s = Schedule(p.path1,p.path2) 01259 self.assertEqual(s[0],p.path1) 01260 self.assertEqual(s[1],p.path2) 01261 p.schedule = s 01262 self.assert_('b' in p.schedule.moduleNames()) 01263 self.assert_(hasattr(p, 'b')) 01264 self.assert_(hasattr(p, 'c')) 01265 self.assert_(hasattr(p, 'd')) 01266 self.assert_(hasattr(p, 'path1')) 01267 self.assert_(hasattr(p, 'path2')) 01268 self.assert_(hasattr(p, 'path3')) 01269 p.prune() 01270 self.assert_('b' in p.schedule.moduleNames()) 01271 self.assert_(hasattr(p, 'b')) 01272 self.assert_(not hasattr(p, 'c')) 01273 self.assert_(not hasattr(p, 'd')) 01274 self.assert_(hasattr(p, 'path1')) 01275 self.assert_(hasattr(p, 'path2')) 01276 self.assert_(not hasattr(p, 'path3')) 01277 01278 #adding a path not attached to the Process should cause an exception 01279 p = Process("test") 01280 p.a = EDAnalyzer("MyAnalyzer") 01281 path1 = Path(p.a) 01282 s = Schedule(path1) 01283 self.assertRaises(RuntimeError, lambda : p.setSchedule_(s) ) 01284 01285 #make sure anonymous sequences work 01286 p = Process("test") 01287 p.a = EDAnalyzer("MyAnalyzer") 01288 p.b = EDAnalyzer("MyOtherAnalyzer") 01289 p.c = EDProducer("MyProd") 01290 path1 = Path(p.c*Sequence(p.a+p.b)) 01291 s = Schedule(path1) 01292 self.assert_('a' in s.moduleNames()) 01293 self.assert_('b' in s.moduleNames()) 01294 self.assert_('c' in s.moduleNames()) 01295 p.path1 = path1 01296 p.schedule = s 01297 p.prune() 01298 self.assert_('a' in s.moduleNames()) 01299 self.assert_('b' in s.moduleNames()) 01300 self.assert_('c' in s.moduleNames())
def Config::TestModuleCommand::testSecSource | ( | self | ) |
def Config::TestModuleCommand::testSequence | ( | self | ) |
Definition at line 1194 of file Config.py.
01195 : 01196 p = Process('test') 01197 p.a = EDAnalyzer("MyAnalyzer") 01198 p.b = EDAnalyzer("YourAnalyzer") 01199 p.c = EDAnalyzer("OurAnalyzer") 01200 p.s = Sequence(p.a*p.b) 01201 self.assertEqual(str(p.s),'a+b') 01202 self.assertEqual(p.s.label_(),'s') 01203 path = Path(p.c+p.s) 01204 self.assertEqual(str(path),'c+a+b') 01205 p._validateSequence(path, 'p1') 01206 notInProcess = EDAnalyzer('NotInProcess') 01207 p2 = Path(p.c+p.s*notInProcess) 01208 self.assertRaises(RuntimeError, p._validateSequence, p2, 'p2')
def Config::TestModuleCommand::testSubProcess | ( | self | ) |
Definition at line 1448 of file Config.py.
01449 : 01450 process = Process("Parent") 01451 subProcess = Process("Child") 01452 subProcess.a = EDProducer("A") 01453 subProcess.p = Path(subProcess.a) 01454 subProcess.add_(Service("Foo")) 01455 process.add_( SubProcess(subProcess) ) 01456 d = process.dumpPython() 01457 equalD ="""import FWCore.ParameterSet.Config as cms 01458 01459 process = cms.Process("Parent") 01460 01461 parentProcess = process 01462 import FWCore.ParameterSet.Config as cms 01463 01464 process = cms.Process("Child") 01465 01466 process.a = cms.EDProducer("A") 01467 01468 01469 process.p = cms.Path(process.a) 01470 01471 01472 process.Foo = cms.Service("Foo") 01473 01474 01475 childProcess = process 01476 process = parentProcess 01477 process.subProcess = cms.SubProcess( process = childProcess, SelectEvents = cms.untracked.PSet( 01478 01479 ), outputCommands = cms.untracked.vstring()) 01480 """ 01481 equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcess))) 01482 self.assertEqual(d,equalD) 01483 p = TestMakePSet() 01484 process.subProcess.insertInto(p,"dummy") 01485 self.assertEqual((True,['a']),p.values["@sub_process"][1].values["process"][1].values['@all_modules']) 01486 self.assertEqual((True,['p']),p.values["@sub_process"][1].values["process"][1].values['@paths']) self.assertEqual({'@service_type':(True,'Foo')}, p.values["@sub_process"][1].values["process"][1].values["services"][1][0].values)
def Config::TestModuleCommand::testTypedParameterizable | ( | self | ) |
def Config::TestModuleCommand::testUsing | ( | self | ) |
tuple Config::TestModuleCommand::d = p.dumpPython() [static] |
tuple Config::TestModuleCommand::p = Process("test") [static] |
tuple Config::TestModuleCommand::s = Sequence(p.a) [static] |