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