CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes
Config.TestModuleCommand Class Reference
Inheritance diagram for Config.TestModuleCommand:

Public Member Functions

def setUp (self)
 
def testCloneSequence (self)
 
def testContains (self)
 
def testDelete (self)
 
def testExamples (self)
 
def testFreeze (self)
 
def testGlobalReplace (self)
 
def testImplicitSchedule (self)
 
def testMaxEvents (self)
 
def testModifier (self)
 
def testOptions (self)
 
def testOverride (self)
 
def testParameterizable (self)
 
def testPath (self)
 
def testPrefers (self)
 
def testProcessDumpPython (self)
 
def testProcessExtend (self)
 
def testProcessFragment (self)
 
def testProcessInsertion (self)
 
def testPrune (self)
 
def testRefToPSet (self)
 
def testSchedule (self)
 
def testSecSource (self)
 
def testSequence (self)
 
def testSequence2 (self)
 
def testServiceInProcess (self)
 
def testSubProcess (self)
 
def testSwitchProducer (self)
 
def testTask (self)
 
def testTaskPlaceholder (self)
 
def testTypedParameterizable (self)
 
def testUsing (self)
 

Public Attributes

 proc_mod_
 

Static Public Attributes

 a
 
 b
 
 c
 
 d
 
 e
 
 f
 
 g
 
 p
 
 p2
 
 process
 
 r
 
 s
 
 s1
 
 s2
 
 s3
 
 schedule
 
 task1
 
 task2
 
 task3
 
 task4
 
 task5
 
 tasks
 

Detailed Description

Definition at line 1839 of file Config.py.

Member Function Documentation

◆ setUp()

def Config.TestModuleCommand.setUp (   self)
Nothing to do 

Definition at line 1840 of file Config.py.

1840  def setUp(self):
1841  """Nothing to do """
1842  None

◆ testCloneSequence()

def Config.TestModuleCommand.testCloneSequence (   self)

Definition at line 2509 of file Config.py.

2509  def testCloneSequence(self):
2510  p = Process("test")
2511  a = EDAnalyzer("MyAnalyzer")
2512  p.a = a
2513  a.setLabel("a")
2514  b = EDAnalyzer("YOurAnalyzer")
2515  p.b = b
2516  b.setLabel("b")
2517  path = Path(a * b)
2518  p.path = Path(p.a*p.b)
2519  lookuptable = {id(a): p.a, id(b): p.b}
2520  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
2521  #lookuptable = p._cloneToObjectDict
2522  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
2523  self.assertEqual(str(path),str(p.path))
2524 

References triggerObjects_cff.id, and str.

◆ testContains()

def Config.TestModuleCommand.testContains (   self)

Definition at line 2525 of file Config.py.

2525  def testContains(self):
2526 
2527  a = EDProducer("a")
2528  b = EDProducer("b")
2529  c = EDProducer("c")
2530  d = EDProducer("d")
2531  e = EDProducer("e")
2532  f = EDProducer("f")
2533  g = EDProducer("g")
2534  h = EDProducer("h")
2535  i = EDProducer("i")
2536  j = EDProducer("j")
2537  k = EDProducer("k")
2538  l = EDProducer("l")
2539  m = EDProducer("m")
2540  n = EDProducer("n")
2541 
2542  seq1 = Sequence(e)
2543  task1 = Task(g)
2544  path = Path(a * c * seq1, task1)
2545 
2546  self.assertTrue(path.contains(a))
2547  self.assertFalse(path.contains(b))
2548  self.assertTrue(path.contains(c))
2549  self.assertFalse(path.contains(d))
2550  self.assertTrue(path.contains(e))
2551  self.assertFalse(path.contains(f))
2552  self.assertTrue(path.contains(g))
2553 
2554  endpath = EndPath(h * i)
2555  self.assertFalse(endpath.contains(b))
2556  self.assertTrue(endpath.contains(i))
2557 
2558  seq = Sequence(a * c)
2559  self.assertFalse(seq.contains(b))
2560  self.assertTrue(seq.contains(c))
2561 
2562  task2 = Task(l)
2563  task = Task(j, k, task2)
2564  self.assertFalse(task.contains(b))
2565  self.assertTrue(task.contains(j))
2566  self.assertTrue(task.contains(k))
2567  self.assertTrue(task.contains(l))
2568 
2569  task3 = Task(m)
2570  path2 = Path(n)
2571  sch = Schedule(path, path2, tasks=[task,task3])
2572  self.assertFalse(sch.contains(b))
2573  self.assertTrue(sch.contains(a))
2574  self.assertTrue(sch.contains(c))
2575  self.assertTrue(sch.contains(e))
2576  self.assertTrue(sch.contains(g))
2577  self.assertTrue(sch.contains(n))
2578  self.assertTrue(sch.contains(j))
2579  self.assertTrue(sch.contains(k))
2580  self.assertTrue(sch.contains(l))
2581  self.assertTrue(sch.contains(m))
2582 

◆ testDelete()

def Config.TestModuleCommand.testDelete (   self)

Definition at line 3153 of file Config.py.

3153  def testDelete(self):
3154  p = Process("test")
3155  p.a = EDAnalyzer("MyAnalyzer")
3156  p.b = EDAnalyzer("YourAnalyzer")
3157  p.c = EDAnalyzer("OurAnalyzer")
3158  p.d = EDAnalyzer("OurAnalyzer")
3159  p.e = EDAnalyzer("OurAnalyzer")
3160  p.f = EDAnalyzer("OurAnalyzer")
3161  p.g = EDProducer("OurProducer")
3162  p.h = EDProducer("YourProducer")
3163  p.t1 = Task(p.g, p.h)
3164  t2 = Task(p.g, p.h)
3165  t3 = Task(p.g, p.h)
3166  p.s = Sequence(p.d+p.e)
3167  p.path1 = Path(p.a+p.f+p.s,t2)
3168  p.endpath1 = EndPath(p.b+p.f)
3169  p.schedule = Schedule(tasks=[t3])
3170  self.assertTrue(hasattr(p, 'f'))
3171  self.assertTrue(hasattr(p, 'g'))
3172  del p.e
3173  del p.f
3174  del p.g
3175  self.assertFalse(hasattr(p, 'f'))
3176  self.assertFalse(hasattr(p, 'g'))
3177  self.assertTrue(p.t1.dumpPython() == 'cms.Task(process.h)\n')
3178  self.assertTrue(p.s.dumpPython() == 'cms.Sequence(process.d)\n')
3179  self.assertTrue(p.path1.dumpPython() == 'cms.Path(process.a+process.s, cms.Task(process.h))\n')
3180  self.assertTrue(p.endpath1.dumpPython() == 'cms.EndPath(process.b)\n')
3181  del p.s
3182  self.assertTrue(p.path1.dumpPython() == 'cms.Path(process.a+(process.d), cms.Task(process.h))\n')
3183  self.assertTrue(p.schedule_().dumpPython() == 'cms.Schedule(tasks=[cms.Task(process.h)])\n')

References ConfigBuilder.dumpPython().

◆ testExamples()

def Config.TestModuleCommand.testExamples (   self)

Definition at line 2778 of file Config.py.

2778  def testExamples(self):
2779  p = Process("Test")
2780  p.source = Source("PoolSource",fileNames = untracked(string("file:reco.root")))
2781  p.foos = EDProducer("FooProducer")
2782  p.bars = EDProducer("BarProducer", foos=InputTag("foos"))
2783  p.out = OutputModule("PoolOutputModule",fileName=untracked(string("file:foos.root")))
2784  p.bars.foos = 'Foosball'
2785  self.assertEqual(p.bars.foos, InputTag('Foosball'))
2786  p.p = Path(p.foos*p.bars)
2787  p.e = EndPath(p.out)
2788  p.add_(Service("MessageLogger"))
2789 

References Types.untracked.

◆ testFreeze()

def Config.TestModuleCommand.testFreeze (   self)

Definition at line 2810 of file Config.py.

2810  def testFreeze(self):
2811  process = Process("Freeze")
2812  m = EDProducer("M", p=PSet(i = int32(1)))
2813  m.p.i = 2
2814  process.m = m
2815  # should be frozen
2816  #self.assertRaises(ValueError, setattr, m.p, 'i', 3)
2817  #self.assertRaises(ValueError, setattr, m, 'p', PSet(i=int32(1)))
2818  #self.assertRaises(ValueError, setattr, m.p, 'j', 1)
2819  #self.assertRaises(ValueError, setattr, m, 'j', 1)
2820  # But OK to change through the process
2821  process.m.p.i = 4
2822  self.assertEqual(process.m.p.i.value(), 4)
2823  process.m.p = PSet(j=int32(1))
2824  # should work to clone it, though
2825  m2 = m.clone(p = PSet(i = int32(5)), j = int32(8))
2826  m2.p.i = 6
2827  m2.j = 8

◆ testGlobalReplace()

def Config.TestModuleCommand.testGlobalReplace (   self)

Definition at line 2181 of file Config.py.

2181  def testGlobalReplace(self):
2182  p = Process('test')
2183  p.a = EDAnalyzer("MyAnalyzer")
2184  old = p.a
2185  p.b = EDAnalyzer("YourAnalyzer")
2186  p.c = EDAnalyzer("OurAnalyzer")
2187  p.d = EDProducer("MyProducer")
2188  old2 = p.d
2189  p.t1 = Task(p.d)
2190  t2 = Task(p.d)
2191  t3 = Task(p.d)
2192  t4 = Task(p.d)
2193  t5 = Task(p.d)
2194  t6 = Task(p.d)
2195  s = Sequence(p.a*p.b)
2196  p.s4 = Sequence(p.a*p.b)
2197  s.associate(t2)
2198  p.s4.associate(t2)
2199  p.p = Path(p.c+s+p.a)
2200  p.p2 = Path(p.c+p.s4+p.a)
2201  p.e3 = EndPath(p.c+s+p.a)
2202  new = EDAnalyzer("NewAnalyzer")
2203  new2 = EDProducer("NewProducer")
2204  visitor1 = NodeVisitor()
2205  p.p.visit(visitor1)
2206  self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
2207  p.schedule = Schedule(tasks=[t6])
2208  p.globalReplace("a",new)
2209  p.globalReplace("d",new2)
2210  visitor2 = NodeVisitor()
2211  p.p.visit(visitor2)
2212  self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
2213  self.assertEqual(p.p.dumpPython()[:-1], "cms.Path(process.c+process.a+process.b+process.a, cms.Task(process.d))")
2214  visitor_p2 = NodeVisitor()
2215  p.p2.visit(visitor_p2)
2216  self.assertTrue(visitor_p2.modules == set([new,new2,p.b,p.c]))
2217  self.assertEqual(p.p2.dumpPython()[:-1], "cms.Path(process.c+process.s4+process.a)")
2218  visitor3 = NodeVisitor()
2219  p.e3.visit(visitor3)
2220  self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
2221  visitor4 = NodeVisitor()
2222  p.s4.visit(visitor4)
2223  self.assertTrue(visitor4.modules == set([new,new2,p.b]))
2224  self.assertEqual(p.s4.dumpPython()[:-1],"cms.Sequence(process.a+process.b, cms.Task(process.d))")
2225  visitor5 = NodeVisitor()
2226  p.t1.visit(visitor5)
2227  self.assertTrue(visitor5.modules == set([new2]))
2228  visitor6 = NodeVisitor()
2229  listOfTasks = list(p.schedule._tasks)
2230  listOfTasks[0].visit(visitor6)
2231  self.assertTrue(visitor6.modules == set([new2]))
2232 

◆ testImplicitSchedule()

def Config.TestModuleCommand.testImplicitSchedule (   self)

Definition at line 2688 of file Config.py.

2688  def testImplicitSchedule(self):
2689  p = Process("test")
2690  p.a = EDAnalyzer("MyAnalyzer")
2691  p.b = EDAnalyzer("YourAnalyzer")
2692  p.c = EDAnalyzer("OurAnalyzer")
2693  p.path1 = Path(p.a)
2694  p.path2 = Path(p.b)
2695  self.assertTrue(p.schedule is None)
2696  pths = p.paths
2697  keys = pths.keys()
2698  self.assertEqual(pths[keys[0]],p.path1)
2699  self.assertEqual(pths[keys[1]],p.path2)
2700  p.prune()
2701  self.assertTrue(hasattr(p, 'a'))
2702  self.assertTrue(hasattr(p, 'b'))
2703  self.assertTrue(not hasattr(p, 'c'))
2704  self.assertTrue(hasattr(p, 'path1'))
2705  self.assertTrue(hasattr(p, 'path2'))
2706 
2707 
2708  p = Process("test")
2709  p.a = EDAnalyzer("MyAnalyzer")
2710  p.b = EDAnalyzer("YourAnalyzer")
2711  p.c = EDAnalyzer("OurAnalyzer")
2712  p.path2 = Path(p.b)
2713  p.path1 = Path(p.a)
2714  self.assertTrue(p.schedule is None)
2715  pths = p.paths
2716  keys = pths.keys()
2717  self.assertEqual(pths[keys[1]],p.path1)
2718  self.assertEqual(pths[keys[0]],p.path2)
2719 
2720 

◆ testMaxEvents()

def Config.TestModuleCommand.testMaxEvents (   self)

Definition at line 2763 of file Config.py.

2763  def testMaxEvents(self):
2764  p = Process("Test")
2765  p.maxEvents.input = 10
2766  self.assertEqual(p.maxEvents.input.value(),10)
2767  p = Process("Test")
2768  p.maxEvents.output = 10
2769  self.assertEqual(p.maxEvents.output.value(),10)
2770  p = Process("Test")
2771  p.maxEvents.output = PSet(out=untracked.int32(10))
2772  self.assertEqual(p.maxEvents.output.out.value(), 10)
2773  p = Process("Test")
2774  p.maxEvents = untracked.PSet(input = untracked.int32(5))
2775  self.assertEqual(p.maxEvents.input.value(), 5)
2776 
2777 

◆ testModifier()

def Config.TestModuleCommand.testModifier (   self)

Definition at line 3184 of file Config.py.

3184  def testModifier(self):
3185  m1 = Modifier()
3186  p = Process("test",m1)
3187  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
3188  def _mod_fred(obj):
3189  obj.fred = 2
3190  m1.toModify(p.a,_mod_fred)
3191  self.assertEqual(p.a.fred.value(),2)
3192  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
3193  m1.toModify(p.b, wilma = 2)
3194  self.assertEqual(p.b.wilma.value(),2)
3195  self.assertTrue(p.isUsingModifier(m1))
3196  #check that Modifier not attached to a process doesn't run
3197  m1 = Modifier()
3198  p = Process("test")
3199  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
3200  m1.toModify(p.a,_mod_fred)
3201  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
3202  m1.toModify(p.b, wilma = 2)
3203  self.assertEqual(p.a.fred.value(),1)
3204  self.assertEqual(p.b.wilma.value(),1)
3205  self.assertEqual(p.isUsingModifier(m1),False)
3206  #make sure clones get the changes
3207  m1 = Modifier()
3208  p = Process("test",m1)
3209  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3210  m1.toModify(p.a, fred = int32(2))
3211  p.b = p.a.clone(wilma = int32(3))
3212  self.assertEqual(p.a.fred.value(),2)
3213  self.assertEqual(p.a.wilma.value(),1)
3214  self.assertEqual(p.b.fred.value(),2)
3215  self.assertEqual(p.b.wilma.value(),3)
3216  #test removal of parameter
3217  m1 = Modifier()
3218  p = Process("test",m1)
3219  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1), fintstones = PSet(fred = int32(1)))
3220  m1.toModify(p.a, fred = None, fintstones = dict(fred = None))
3221  self.assertEqual(hasattr(p.a, "fred"), False)
3222  self.assertEqual(hasattr(p.a.fintstones, "fred"), False)
3223  self.assertEqual(p.a.wilma.value(),1)
3224  #test adding a parameter
3225  m1 = Modifier()
3226  p = Process("test",m1)
3227  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
3228  m1.toModify(p.a, wilma = int32(2))
3229  self.assertEqual(p.a.fred.value(), 1)
3230  self.assertEqual(p.a.wilma.value(),2)
3231  #test setting of value in PSet
3232  m1 = Modifier()
3233  p = Process("test",m1)
3234  p.a = EDAnalyzer("MyAnalyzer", flintstones = PSet(fred = int32(1), wilma = int32(1)))
3235  m1.toModify(p.a, flintstones = dict(fred = int32(2)))
3236  self.assertEqual(p.a.flintstones.fred.value(),2)
3237  self.assertEqual(p.a.flintstones.wilma.value(),1)
3238  #test proper exception from nonexisting parameter name
3239  m1 = Modifier()
3240  p = Process("test",m1)
3241  p.a = EDAnalyzer("MyAnalyzer", flintstones = PSet(fred = PSet(wilma = int32(1))))
3242  self.assertRaises(KeyError, lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
3243  self.assertRaises(KeyError, lambda: m1.toModify(p.a, foo = 1))
3244  #test setting a value in a VPSet
3245  m1 = Modifier()
3246  p = Process("test",m1)
3247  p.a = EDAnalyzer("MyAnalyzer", flintstones = VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
3248  m1.toModify(p.a, flintstones = {1:dict(wilma = int32(2))})
3249  self.assertEqual(p.a.flintstones[0].fred.value(),1)
3250  self.assertEqual(p.a.flintstones[1].wilma.value(),2)
3251  #test setting a value in a list of values
3252  m1 = Modifier()
3253  p = Process("test",m1)
3254  p.a = EDAnalyzer("MyAnalyzer", fred = vuint32(1,2,3))
3255  m1.toModify(p.a, fred = {1:7})
3256  self.assertEqual(p.a.fred[0],1)
3257  self.assertEqual(p.a.fred[1],7)
3258  self.assertEqual(p.a.fred[2],3)
3259  #test IndexError setting a value in a list to an item key not in the list
3260  m1 = Modifier()
3261  p = Process("test",m1)
3262  p.a = EDAnalyzer("MyAnalyzer", fred = vuint32(1,2,3))
3263  raised = False
3264  try: m1.toModify(p.a, fred = {5:7})
3265  except IndexError as e: raised = True
3266  self.assertEqual(raised, True)
3267  #test TypeError setting a value in a list using a key that is not an int
3268  m1 = Modifier()
3269  p = Process("test",m1)
3270  p.a = EDAnalyzer("MyAnalyzer", flintstones = VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
3271  raised = False
3272  try: m1.toModify(p.a, flintstones = dict(bogus = int32(37)))
3273  except TypeError as e: raised = True
3274  self.assertEqual(raised, True)
3275  #test that load causes process wide methods to run
3276  def _rem_a(proc):
3277  del proc.a
3278  class ProcModifierMod(object):
3279  def __init__(self,modifier,func):
3280  self.proc_mod_ = modifier.makeProcessModifier(func)
3281  class DummyMod(object):
3282  def __init__(self):
3283  self.a = EDAnalyzer("Dummy")
3284  testMod = DummyMod()
3285  p.extend(testMod)
3286  self.assertTrue(hasattr(p,"a"))
3287  m1 = Modifier()
3288  p = Process("test",m1)
3289  testProcMod = ProcModifierMod(m1,_rem_a)
3290  p.extend(testMod)
3291  p.extend(testProcMod)
3292  self.assertTrue(not hasattr(p,"a"))
3293  #test ModifierChain
3294  m1 = Modifier()
3295  mc = ModifierChain(m1)
3296  p = Process("test",mc)
3297  self.assertTrue(p.isUsingModifier(m1))
3298  self.assertTrue(p.isUsingModifier(mc))
3299  testMod = DummyMod()
3300  p.b = EDAnalyzer("Dummy2", fred = int32(1))
3301  m1.toModify(p.b, fred = int32(3))
3302  p.extend(testMod)
3303  testProcMod = ProcModifierMod(m1,_rem_a)
3304  p.extend(testProcMod)
3305  self.assertTrue(not hasattr(p,"a"))
3306  self.assertEqual(p.b.fred.value(),3)
3307  #check cloneAndExclude
3308  m1 = Modifier()
3309  m2 = Modifier()
3310  mc = ModifierChain(m1,m2)
3311  mclone = mc.copyAndExclude([m2])
3312  self.assertTrue(not mclone._isOrContains(m2))
3313  self.assertTrue(mclone._isOrContains(m1))
3314  m3 = Modifier()
3315  mc2 = ModifierChain(mc,m3)
3316  mclone = mc2.copyAndExclude([m2])
3317  self.assertTrue(not mclone._isOrContains(m2))
3318  self.assertTrue(mclone._isOrContains(m1))
3319  self.assertTrue(mclone._isOrContains(m3))
3320  #check combining
3321  m1 = Modifier()
3322  m2 = Modifier()
3323  p = Process("test",m1)
3324  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3325  (m1 & m2).toModify(p.a, fred = int32(2))
3326  self.assertRaises(TypeError, lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
3327  self.assertEqual(p.a.fred, 1)
3328  m1 = Modifier()
3329  m2 = Modifier()
3330  p = Process("test",m1,m2)
3331  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3332  (m1 & m2).toModify(p.a, fred = int32(2))
3333  self.assertEqual(p.a.fred, 2)
3334  m1 = Modifier()
3335  m2 = Modifier()
3336  m3 = Modifier()
3337  p = Process("test",m1,m2,m3)
3338  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3339  (m1 & m2 & m3).toModify(p.a, fred = int32(2))
3340  self.assertEqual(p.a.fred, 2)
3341  (m1 & (m2 & m3)).toModify(p.a, fred = int32(3))
3342  self.assertEqual(p.a.fred, 3)
3343  ((m1 & m2) & m3).toModify(p.a, fred = int32(4))
3344  self.assertEqual(p.a.fred, 4)
3345  #check inverse
3346  m1 = Modifier()
3347  m2 = Modifier()
3348  p = Process("test", m1)
3349  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3350  (~m1).toModify(p.a, fred=2)
3351  self.assertEqual(p.a.fred, 1)
3352  (~m2).toModify(p.a, wilma=2)
3353  self.assertEqual(p.a.wilma, 2)
3354  self.assertRaises(TypeError, lambda: (~m1).toModify(p.a, 1, wilma=2))
3355  self.assertRaises(TypeError, lambda: (~m2).toModify(p.a, 1, wilma=2))
3356  # check or
3357  m1 = Modifier()
3358  m2 = Modifier()
3359  m3 = Modifier()
3360  p = Process("test", m1)
3361  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3362  (m1 | m2).toModify(p.a, fred=2)
3363  self.assertEqual(p.a.fred, 2)
3364  (m1 | m2 | m3).toModify(p.a, fred=3)
3365  self.assertEqual(p.a.fred, 3)
3366  (m3 | m2 | m1).toModify(p.a, fred=4)
3367  self.assertEqual(p.a.fred, 4)
3368  ((m1 | m2) | m3).toModify(p.a, fred=5)
3369  self.assertEqual(p.a.fred, 5)
3370  (m1 | (m2 | m3)).toModify(p.a, fred=6)
3371  self.assertEqual(p.a.fred, 6)
3372  (m2 | m3).toModify(p.a, fred=7)
3373  self.assertEqual(p.a.fred, 6)
3374  self.assertRaises(TypeError, lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
3375  self.assertRaises(TypeError, lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
3376  # check combinations
3377  m1 = Modifier()
3378  m2 = Modifier()
3379  m3 = Modifier()
3380  m4 = Modifier()
3381  p = Process("test", m1, m2)
3382  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3383  (m1 & ~m2).toModify(p.a, fred=2)
3384  self.assertEqual(p.a.fred, 1)
3385  (m1 & ~m3).toModify(p.a, fred=2)
3386  self.assertEqual(p.a.fred, 2)
3387  (m1 | ~m2).toModify(p.a, fred=3)
3388  self.assertEqual(p.a.fred, 3)
3389  (~m1 | ~m2).toModify(p.a, fred=4)
3390  self.assertEqual(p.a.fred, 3)
3391  (~m3 & ~m4).toModify(p.a, fred=4)
3392  self.assertEqual(p.a.fred, 4)
3393  ((m1 & m3) | ~m4).toModify(p.a, fred=5)
3394  self.assertEqual(p.a.fred, 5)
3395  #check toReplaceWith
3396  m1 = Modifier()
3397  p = Process("test",m1)
3398  p.a =EDAnalyzer("MyAnalyzer", fred = int32(1))
3399  m1.toReplaceWith(p.a, EDAnalyzer("YourAnalyzer", wilma = int32(3)))
3400  self.assertRaises(TypeError, lambda: m1.toReplaceWith(p.a, EDProducer("YourProducer")))
3401  p.b =EDAnalyzer("BAn")
3402  p.c =EDProducer("c")
3403  p.d =EDProducer("d")
3404  p.tc = Task(p.c)
3405  p.td = Task(p.d)
3406  p.s = Sequence(p.a, p.tc)
3407  m1.toReplaceWith(p.s, Sequence(p.a+p.b, p.td))
3408  self.assertEqual(p.a.wilma.value(),3)
3409  self.assertEqual(p.a.type_(),"YourAnalyzer")
3410  self.assertEqual(hasattr(p,"fred"),False)
3411  self.assertTrue(p.s.dumpPython() == "cms.Sequence(process.a+process.b, process.td)\n")
3412  p.e =EDProducer("e")
3413  m1.toReplaceWith(p.td, Task(p.e))
3414  self.assertTrue(p.td._collection == OrderedSet([p.e]))
3415  #check toReplaceWith doesn't activate not chosen
3416  m1 = Modifier()
3417  p = Process("test")
3418  p.a =EDAnalyzer("MyAnalyzer", fred = int32(1))
3419  m1.toReplaceWith(p.a, EDAnalyzer("YourAnalyzer", wilma = int32(3)))
3420  self.assertEqual(p.a.type_(),"MyAnalyzer")
3421  #check toReplaceWith and and/not/or combinations
3422  m1 = Modifier()
3423  m2 = Modifier()
3424  m3 = Modifier()
3425  m4 = Modifier()
3426  p = Process("test", m1, m2)
3427  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
3428  self.assertRaises(TypeError, lambda: (m1 & m2).toReplaceWith(p.a, EDProducer("YourProducer")))
3429  self.assertRaises(TypeError, lambda: (m3 & m4).toReplaceWith(p.a, EDProducer("YourProducer")))
3430  self.assertRaises(TypeError, lambda: (~m3).toReplaceWith(p.a, EDProducer("YourProducer")))
3431  self.assertRaises(TypeError, lambda: (~m1).toReplaceWith(p.a, EDProducer("YourProducer")))
3432  self.assertRaises(TypeError, lambda: (m1 | m3).toReplaceWith(p.a, EDProducer("YourProducer")))
3433  self.assertRaises(TypeError, lambda: (m3 | m4).toReplaceWith(p.a, EDProducer("YourProducer")))
3434  (m1 & m2).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer1"))
3435  self.assertEqual(p.a.type_(), "YourAnalyzer1")
3436  (m1 & m3).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer2"))
3437  self.assertEqual(p.a.type_(), "YourAnalyzer1")
3438  (~m1).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer2"))
3439  self.assertEqual(p.a.type_(), "YourAnalyzer1")
3440  (~m3).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer2"))
3441  self.assertEqual(p.a.type_(), "YourAnalyzer2")
3442  (m1 | m3).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer3"))
3443  self.assertEqual(p.a.type_(), "YourAnalyzer3")
3444  (m3 | m4).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer4"))
3445  self.assertEqual(p.a.type_(), "YourAnalyzer3")
3446 
3447  # EDAlias
3448  a = EDAlias(foo2 = VPSet(PSet(type = string("Foo2"))))
3449  m = Modifier()
3450  m._setChosen()
3451  # Modify parameters
3452  m.toModify(a, foo2 = {0: dict(type = "Foo3")})
3453  self.assertEqual(a.foo2[0].type, "Foo3")
3454  # Add an alias
3455  m.toModify(a, foo4 = VPSet(PSet(type = string("Foo4"))))
3456  self.assertEqual(a.foo2[0].type, "Foo3")
3457  self.assertEqual(a.foo4[0].type, "Foo4")
3458  # Remove an alias
3459  m.toModify(a, foo2 = None)
3460  self.assertFalse(hasattr(a, "foo2"))
3461  self.assertEqual(a.foo4[0].type, "Foo4")
3462  # Replace (doesn't work out of the box because EDAlias is not _Parameterizable
3463  m.toReplaceWith(a, EDAlias(bar = VPSet(PSet(type = string("Bar")))))
3464  self.assertFalse(hasattr(a, "foo2"))
3465  self.assertFalse(hasattr(a, "foo4"))
3466  self.assertTrue(hasattr(a, "bar"))
3467  self.assertEqual(a.bar[0].type, "Bar")
3468 
3469  # SwitchProducer
3470  sp = SwitchProducerTest(test1 = EDProducer("Foo",
3471  a = int32(1),
3472  b = PSet(c = int32(2))),
3473  test2 = EDProducer("Bar",
3474  aa = int32(11),
3475  bb = PSet(cc = int32(12))))
3476  m = Modifier()
3477  m._setChosen()
3478  # Modify parameters
3479  m.toModify(sp,
3480  test1 = dict(a = 4, b = dict(c = None)),
3481  test2 = dict(aa = 15, bb = dict(cc = 45, dd = string("foo"))))
3482  self.assertEqual(sp.test1.a.value(), 4)
3483  self.assertEqual(sp.test1.b.hasParameter("c"), False)
3484  self.assertEqual(sp.test2.aa.value(), 15)
3485  self.assertEqual(sp.test2.bb.cc.value(), 45)
3486  self.assertEqual(sp.test2.bb.dd.value(), "foo")
3487  # Replace a producer
3488  m.toReplaceWith(sp.test1, EDProducer("Fred", x = int32(42)))
3489  self.assertEqual(sp.test1.type_(), "Fred")
3490  self.assertEqual(sp.test1.x.value(), 42)
3491  self.assertRaises(TypeError, lambda: m.toReplaceWith(sp.test1, EDAnalyzer("Foo")))
3492  # Alternative way (only to be allow same syntax to be used as for adding)
3493  m.toModify(sp, test2 = EDProducer("Xyzzy", x = int32(24)))
3494  self.assertEqual(sp.test2.type_(), "Xyzzy")
3495  self.assertEqual(sp.test2.x.value(), 24)
3496  self.assertRaises(TypeError, lambda: m.toModify(sp, test2 = EDAnalyzer("Foo")))
3497  # Add a producer
3498  m.toModify(sp, test3 = EDProducer("Wilma", y = int32(24)))
3499  self.assertEqual(sp.test3.type_(), "Wilma")
3500  self.assertEqual(sp.test3.y.value(), 24)
3501  self.assertRaises(TypeError, lambda: m.toModify(sp, test4 = EDAnalyzer("Foo")))
3502  # Remove a producer
3503  m.toModify(sp, test2 = None)
3504  self.assertEqual(hasattr(sp, "test2"), False)
3505  # Add an alias
3506  m.toModify(sp, test2 = EDAlias(foo = VPSet(PSet(type = string("int")))))
3507  self.assertTrue(hasattr(sp.test2, "foo"))
3508  # Replace an alias
3509  m.toReplaceWith(sp.test2, EDAlias(bar = VPSet(PSet(type = string("int")))))
3510  self.assertTrue(hasattr(sp.test2, "bar"))
3511  # Alternative way
3512  m.toModify(sp, test2 = EDAlias(xyzzy = VPSet(PSet(type = string("int")))))
3513  self.assertTrue(hasattr(sp.test2, "xyzzy"))
3514  # Replace an alias with EDProducer
3515  self.assertRaises(TypeError, lambda: m.toReplaceWith(sp.test2, EDProducer("Foo")))
3516  m.toModify(sp, test2 = EDProducer("Foo"))

References resolutioncreator_cfi.object.

◆ testOptions()

def Config.TestModuleCommand.testOptions (   self)

Definition at line 2751 of file Config.py.

2751  def testOptions(self):
2752  p = Process('test')
2753  self.assertEqual(p.options.numberOfThreads.value(),1)
2754  p.options.numberOfThreads = 8
2755  self.assertEqual(p.options.numberOfThreads.value(),8)
2756  p.options = PSet()
2757  self.assertEqual(p.options.numberOfThreads.value(),1)
2758  p.options = dict(numberOfStreams =2,
2759  numberOfThreads =2)
2760  self.assertEqual(p.options.numberOfThreads.value(),2)
2761  self.assertEqual(p.options.numberOfStreams.value(),2)
2762 

◆ testOverride()

def Config.TestModuleCommand.testOverride (   self)

Definition at line 2728 of file Config.py.

2728  def testOverride(self):
2729  p = Process('test')
2730  a = EDProducer("A", a1=int32(0))
2731  self.assertTrue(not a.isModified())
2732  a.a1 = 1
2733  self.assertTrue(a.isModified())
2734  p.a = a
2735  self.assertEqual(p.a.a1.value(), 1)
2736  # try adding an unmodified module.
2737  # should accept it
2738  p.a = EDProducer("A", a1=int32(2))
2739  self.assertEqual(p.a.a1.value(), 2)
2740  # try adding a modified module. Should throw
2741  # no longer, since the same (modified) say, geometry
2742  # could come from more than one cff
2743  b = EDProducer("A", a1=int32(3))
2744  b.a1 = 4
2745  #self.assertRaises(RuntimeError, setattr, *(p,'a',b))
2746  ps1 = PSet(a = int32(1))
2747  ps2 = PSet(a = int32(2))
2748  self.assertRaises(ValueError, EDProducer, 'C', ps1, ps2)
2749  self.assertRaises(ValueError, EDProducer, 'C', ps1, a=int32(3))
2750 

◆ testParameterizable()

def Config.TestModuleCommand.testParameterizable (   self)

Definition at line 1843 of file Config.py.

1843  def testParameterizable(self):
1844  p = _Parameterizable()
1845  self.assertEqual(len(p.parameterNames_()),0)
1846  p.a = int32(1)
1847  self.assertTrue('a' in p.parameterNames_())
1848  self.assertEqual(p.a.value(), 1)
1849  p.a = 10
1850  self.assertEqual(p.a.value(), 10)
1851  p.a = untracked(int32(1))
1852  self.assertEqual(p.a.value(), 1)
1853  self.assertFalse(p.a.isTracked())
1854  p.a = untracked.int32(1)
1855  self.assertEqual(p.a.value(), 1)
1856  self.assertFalse(p.a.isTracked())
1857  p = _Parameterizable(foo=int32(10), bar = untracked(double(1.0)))
1858  self.assertEqual(p.foo.value(), 10)
1859  self.assertEqual(p.bar.value(),1.0)
1860  self.assertFalse(p.bar.isTracked())
1861  self.assertRaises(TypeError,setattr,(p,'c',1))
1862  p = _Parameterizable(a=PSet(foo=int32(10), bar = untracked(double(1.0))))
1863  self.assertEqual(p.a.foo.value(),10)
1864  self.assertEqual(p.a.bar.value(),1.0)
1865  p.b = untracked(PSet(fii = int32(1)))
1866  self.assertEqual(p.b.fii.value(),1)
1867  self.assertFalse(p.b.isTracked())
1868  #test the fact that values can be shared
1869  v = int32(10)
1870  p=_Parameterizable(a=v)
1871  v.setValue(11)
1872  self.assertEqual(p.a.value(),11)
1873  p.a = 12
1874  self.assertEqual(p.a.value(),12)
1875  self.assertEqual(v.value(),12)

◆ testPath()

def Config.TestModuleCommand.testPath (   self)

Definition at line 2469 of file Config.py.

2469  def testPath(self):
2470  p = Process("test")
2471  p.a = EDAnalyzer("MyAnalyzer")
2472  p.b = EDAnalyzer("YourAnalyzer")
2473  p.c = EDAnalyzer("OurAnalyzer")
2474  path = Path(p.a)
2475  path *= p.b
2476  path += p.c
2477  self.assertEqual(str(path),'a+b+c')
2478  path = Path(p.a*p.b+p.c)
2479  self.assertEqual(str(path),'a+b+c')
2480 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences
2481 # self.assertEqual(str(path),'((a*b)+c)')
2482  path = Path(p.a+ p.b*p.c)
2483  self.assertEqual(str(path),'a+b+c')
2484  path = Path(p.a*(p.b+p.c))
2485  self.assertEqual(str(path),'a+b+c')
2486  path = Path(p.a*(p.b+~p.c))
2487  pathx = Path(p.a*(p.b+ignore(p.c)))
2488  self.assertEqual(str(path),'a+b+~c')
2489  p.es = ESProducer("AnESProducer")
2490  self.assertRaises(TypeError,Path,p.es)
2491 
2492  t = Path()
2493  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path()\n')
2494 
2495  t = Path(p.a)
2496  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(process.a)\n')
2497 
2498  t = Path(Task())
2499  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(cms.Task())\n')
2500 
2501  t = Path(p.a, Task())
2502  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(process.a, cms.Task())\n')
2503 
2504  p.prod = EDProducer("prodName")
2505  p.t1 = Task(p.prod)
2506  t = Path(p.a, p.t1, Task(), p.t1)
2507  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(process.a, cms.Task(), process.t1)\n')
2508 

References SequenceTypes.ignore(), and str.

◆ testPrefers()

def Config.TestModuleCommand.testPrefers (   self)

Definition at line 2790 of file Config.py.

2790  def testPrefers(self):
2791  p = Process("Test")
2792  p.add_(ESSource("ForceSource"))
2793  p.juicer = ESProducer("JuicerProducer")
2794  p.prefer("ForceSource")
2795  p.prefer("juicer")
2796  self.assertEqual(_lineDiff(p.dumpPython(), Process('Test').dumpPython()),
2797 """process.juicer = cms.ESProducer("JuicerProducer")
2798 process.ForceSource = cms.ESSource("ForceSource")
2799 process.prefer("ForceSource")
2800 process.prefer("juicer")""")
2801  p.prefer("juicer",fooRcd=vstring("Foo"))
2802  self.assertEqual(_lineDiff(p.dumpPython(), Process('Test').dumpPython()),
2803 """process.juicer = cms.ESProducer("JuicerProducer")
2804 process.ForceSource = cms.ESSource("ForceSource")
2805 process.prefer("ForceSource")
2806 process.prefer("juicer",
2807  fooRcd = cms.vstring('Foo')
2808 )""")
2809 

References Config._lineDiff(), and ConfigBuilder.dumpPython().

◆ testProcessDumpPython()

def Config.TestModuleCommand.testProcessDumpPython (   self)

Definition at line 1995 of file Config.py.

1995  def testProcessDumpPython(self):
1996  self.assertEqual(Process("test").dumpPython(),
1997 """import FWCore.ParameterSet.Config as cms
1998 
1999 process = cms.Process("test")
2000 
2001 process.maxEvents = cms.untracked.PSet(
2002  input = cms.optional.untracked.int32,
2003  output = cms.optional.untracked.allowed(cms.int32,cms.PSet)
2004 )
2005 
2006 process.maxLuminosityBlocks = cms.untracked.PSet(
2007  input = cms.untracked.int32(-1)
2008 )
2009 
2010 process.options = cms.untracked.PSet(
2011  FailPath = cms.untracked.vstring(),
2012  IgnoreCompletely = cms.untracked.vstring(),
2013  Rethrow = cms.untracked.vstring(),
2014  SkipEvent = cms.untracked.vstring(),
2015  allowUnscheduled = cms.obsolete.untracked.bool,
2016  canDeleteEarly = cms.untracked.vstring(),
2017  deleteNonConsumedUnscheduledModules = cms.untracked.bool(True),
2018  dumpOptions = cms.untracked.bool(False),
2019  emptyRunLumiMode = cms.obsolete.untracked.string,
2020  eventSetup = cms.untracked.PSet(
2021  forceNumberOfConcurrentIOVs = cms.untracked.PSet(
2022  allowAnyLabel_=cms.required.untracked.uint32
2023  ),
2024  numberOfConcurrentIOVs = cms.untracked.uint32(0)
2025  ),
2026  fileMode = cms.untracked.string('FULLMERGE'),
2027  forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
2028  makeTriggerResults = cms.obsolete.untracked.bool,
2029  numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0),
2030  numberOfConcurrentRuns = cms.untracked.uint32(1),
2031  numberOfStreams = cms.untracked.uint32(0),
2032  numberOfThreads = cms.untracked.uint32(1),
2033  printDependencies = cms.untracked.bool(False),
2034  sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
2035  throwIfIllegalParameter = cms.untracked.bool(True),
2036  wantSummary = cms.untracked.bool(False)
2037 )
2038 
2039 """)
2040  p = Process("test")
2041  p.a = EDAnalyzer("MyAnalyzer")
2042  p.p = Path(p.a)
2043  p.s = Sequence(p.a)
2044  p.r = Sequence(p.s)
2045  p.p2 = Path(p.s)
2046  p.schedule = Schedule(p.p2,p.p)
2047  d=p.dumpPython()
2048  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2049 """process.a = cms.EDAnalyzer("MyAnalyzer")
2050 process.s = cms.Sequence(process.a)
2051 process.r = cms.Sequence(process.s)
2052 process.p = cms.Path(process.a)
2053 process.p2 = cms.Path(process.s)
2054 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2055  #Reverse order of 'r' and 's'
2056  p = Process("test")
2057  p.a = EDAnalyzer("MyAnalyzer")
2058  p.p = Path(p.a)
2059  p.r = Sequence(p.a)
2060  p.s = Sequence(p.r)
2061  p.p2 = Path(p.r)
2062  p.schedule = Schedule(p.p2,p.p)
2063  p.b = EDAnalyzer("YourAnalyzer")
2064  d=p.dumpPython()
2065  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2066 """process.a = cms.EDAnalyzer("MyAnalyzer")
2067 process.b = cms.EDAnalyzer("YourAnalyzer")
2068 process.r = cms.Sequence(process.a)
2069 process.s = cms.Sequence(process.r)
2070 process.p = cms.Path(process.a)
2071 process.p2 = cms.Path(process.r)
2072 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")

References Config._lineDiff(), and ConfigBuilder.dumpPython().

◆ testProcessExtend()

def Config.TestModuleCommand.testProcessExtend (   self)

Definition at line 1908 of file Config.py.

1908  def testProcessExtend(self):
1909  class FromArg(object):
1910  def __init__(self,*arg,**args):
1911  for name in args.keys():
1912  self.__dict__[name]=args[name]
1913 
1914  a=EDAnalyzer("MyAnalyzer")
1915  t=EDAnalyzer("MyAnalyzer")
1916  t.setLabel("foo")
1917  s1 = Sequence(a)
1918  s2 = Sequence(s1)
1919  s3 = Sequence(s2)
1920  d = FromArg(
1921  a=a,
1922  b=Service("Full"),
1923  c=Path(a),
1924  d=s2,
1925  e=s1,
1926  f=s3,
1927  g=Sequence(s1+s2+s3)
1928  )
1929  p = Process("Test")
1930  p.extend(d)
1931  self.assertEqual(p.a.type_(),"MyAnalyzer")
1932  self.assertEqual(p.a.label_(),"a")
1933  self.assertRaises(AttributeError,getattr,p,'b')
1934  self.assertEqual(p.Full.type_(),"Full")
1935  self.assertEqual(str(p.c),'a')
1936  self.assertEqual(str(p.d),'a')
1937 
1938  z1 = FromArg(
1939  a=a,
1940  b=Service("Full"),
1941  c=Path(a),
1942  d=s2,
1943  e=s1,
1944  f=s3,
1945  s4=s3,
1946  g=Sequence(s1+s2+s3)
1947  )
1948 
1949  p1 = Process("Test")
1950  #p1.extend(z1)
1951  self.assertRaises(ValueError, p1.extend, z1)
1952 
1953  z2 = FromArg(
1954  a=a,
1955  b=Service("Full"),
1956  c=Path(a),
1957  d=s2,
1958  e=s1,
1959  f=s3,
1960  aaa=copy.deepcopy(a),
1961  s4=copy.deepcopy(s3),
1962  g=Sequence(s1+s2+s3),
1963  t=t
1964  )
1965  p2 = Process("Test")
1966  p2.extend(z2)
1967  #self.assertRaises(ValueError, p2.extend, z2)
1968  self.assertEqual(p2.s4.label_(),"s4")
1969  #p2.s4.setLabel("foo")
1970  self.assertRaises(ValueError, p2.s4.setLabel, "foo")
1971  p2.s4.setLabel("s4")
1972  p2.s4.setLabel(None)
1973  p2.s4.setLabel("foo")
1974  p2._Process__setObjectLabel(p2.s4, "foo")
1975  p2._Process__setObjectLabel(p2.s4, None)
1976  p2._Process__setObjectLabel(p2.s4, "bar")
1977 
1978 
1979  p = Process('test')
1980  p.a = EDProducer("MyProducer")
1981  p.t = Task(p.a)
1982  p.p = Path(p.t)
1983  self.assertRaises(ValueError, p.extend, FromArg(a = EDProducer("YourProducer")))
1984  self.assertRaises(ValueError, p.extend, FromArg(a = EDAlias()))
1985  self.assertRaises(ValueError, p.__setattr__, "a", EDAlias())
1986 
1987  p = Process('test')
1988  p.a = EDProducer("MyProducer")
1989  p.s = Sequence(p.a)
1990  p.p = Path(p.s)
1991  self.assertRaises(ValueError, p.extend, FromArg(a = EDProducer("YourProducer")))
1992  self.assertRaises(ValueError, p.extend, FromArg(a = EDAlias()))
1993  self.assertRaises(ValueError, p.__setattr__, "a", EDAlias())
1994 

References resolutioncreator_cfi.object, and str.

◆ testProcessFragment()

def Config.TestModuleCommand.testProcessFragment (   self)

Definition at line 3517 of file Config.py.

3517  def testProcessFragment(self):
3518  #check defaults are not overwritten
3519  f = ProcessFragment('Fragment')
3520  p = Process('PROCESS')
3521  p.maxEvents.input = 10
3522  p.options.numberOfThreads = 4
3523  p.maxLuminosityBlocks.input = 2
3524  p.extend(f)
3525  self.assertEqual(p.maxEvents.input.value(),10)
3526  self.assertEqual(p.options.numberOfThreads.value(), 4)
3527  self.assertEqual(p.maxLuminosityBlocks.input.value(),2)
3528  #general checks
3529  f = ProcessFragment("Fragment")
3530  f.fltr = EDFilter("Foo")
3531  p = Process('PROCESS')
3532  p.extend(f)
3533  self.assertTrue(hasattr(p,'fltr'))
3534 
3535  unittest.main()

◆ testProcessInsertion()

def Config.TestModuleCommand.testProcessInsertion (   self)

Definition at line 1883 of file Config.py.

1883  def testProcessInsertion(self):
1884  p = Process("test")
1885  p.a = EDAnalyzer("MyAnalyzer")
1886  self.assertTrue( 'a' in p.analyzers_() )
1887  self.assertTrue( 'a' in p.analyzers)
1888  p.add_(Service("MessageLogger"))
1889  self.assertTrue('MessageLogger' in p.services_())
1890  self.assertEqual(p.MessageLogger.type_(), "MessageLogger")
1891  p.Tracer = Service("Tracer")
1892  self.assertTrue('Tracer' in p.services_())
1893  self.assertRaises(TypeError, setattr, *(p,'b',"this should fail"))
1894  self.assertRaises(TypeError, setattr, *(p,'bad',Service("MessageLogger")))
1895  self.assertRaises(ValueError, setattr, *(p,'bad',Source("PoolSource")))
1896  p.out = OutputModule("Outer")
1897  self.assertEqual(p.out.type_(), 'Outer')
1898  self.assertTrue( 'out' in p.outputModules_() )
1899 
1900  p.geom = ESSource("GeomProd")
1901  self.assertTrue('geom' in p.es_sources_())
1902  p.add_(ESSource("ConfigDB"))
1903  self.assertTrue('ConfigDB' in p.es_sources_())
1904 
1905  p.aliasfoo1 = EDAlias(foo1 = VPSet(PSet(type = string("Foo1"))))
1906  self.assertTrue('aliasfoo1' in p.aliases_())
1907 

◆ testPrune()

def Config.TestModuleCommand.testPrune (   self)

Definition at line 2951 of file Config.py.

2951  def testPrune(self):
2952  p = Process("test")
2953  p.a = EDAnalyzer("MyAnalyzer")
2954  p.b = EDAnalyzer("YourAnalyzer")
2955  p.c = EDAnalyzer("OurAnalyzer")
2956  p.d = EDAnalyzer("OurAnalyzer")
2957  p.e = EDProducer("MyProducer")
2958  p.f = EDProducer("YourProducer")
2959  p.g = EDProducer("TheirProducer")
2960  p.s = Sequence(p.d)
2961  p.t1 = Task(p.e)
2962  p.t2 = Task(p.f)
2963  p.t3 = Task(p.g, p.t1)
2964  p.path1 = Path(p.a, p.t3)
2965  p.path2 = Path(p.b)
2966  self.assertTrue(p.schedule is None)
2967  pths = p.paths
2968  keys = pths.keys()
2969  self.assertEqual(pths[keys[0]],p.path1)
2970  self.assertEqual(pths[keys[1]],p.path2)
2971  p.pset1 = PSet(parA = string("pset1"))
2972  p.pset2 = untracked.PSet(parA = string("pset2"))
2973  p.vpset1 = VPSet()
2974  p.vpset2 = untracked.VPSet()
2975  p.prune()
2976  self.assertTrue(hasattr(p, 'a'))
2977  self.assertTrue(hasattr(p, 'b'))
2978  self.assertTrue(not hasattr(p, 'c'))
2979  self.assertTrue(not hasattr(p, 'd'))
2980  self.assertTrue(hasattr(p, 'e'))
2981  self.assertTrue(not hasattr(p, 'f'))
2982  self.assertTrue(hasattr(p, 'g'))
2983  self.assertTrue(not hasattr(p, 's'))
2984  self.assertTrue(hasattr(p, 't1'))
2985  self.assertTrue(not hasattr(p, 't2'))
2986  self.assertTrue(hasattr(p, 't3'))
2987  self.assertTrue(hasattr(p, 'path1'))
2988  self.assertTrue(hasattr(p, 'path2'))
2989 # self.assertTrue(not hasattr(p, 'pset1'))
2990 # self.assertTrue(hasattr(p, 'pset2'))
2991 # self.assertTrue(not hasattr(p, 'vpset1'))
2992 # self.assertTrue(not hasattr(p, 'vpset2'))
2993 
2994  p = Process("test")
2995  p.a = EDAnalyzer("MyAnalyzer")
2996  p.b = EDAnalyzer("YourAnalyzer")
2997  p.c = EDAnalyzer("OurAnalyzer")
2998  p.d = EDAnalyzer("OurAnalyzer")
2999  p.e = EDAnalyzer("OurAnalyzer")
3000  p.f = EDProducer("MyProducer")
3001  p.g = EDProducer("YourProducer")
3002  p.h = EDProducer("TheirProducer")
3003  p.i = EDProducer("OurProducer")
3004  p.t1 = Task(p.f)
3005  p.t2 = Task(p.g)
3006  p.t3 = Task(p.h)
3007  p.t4 = Task(p.i)
3008  p.s = Sequence(p.d, p.t1)
3009  p.s2 = Sequence(p.b, p.t2)
3010  p.s3 = Sequence(p.e)
3011  p.path1 = Path(p.a, p.t3)
3012  p.path2 = Path(p.b)
3013  p.path3 = Path(p.b+p.s2)
3014  p.path4 = Path(p.b+p.s3)
3015  p.schedule = Schedule(p.path1,p.path2,p.path3)
3016  p.schedule.associate(p.t4)
3017  pths = p.paths
3018  keys = pths.keys()
3019  self.assertEqual(pths[keys[0]],p.path1)
3020  self.assertEqual(pths[keys[1]],p.path2)
3021  p.prune()
3022  self.assertTrue(hasattr(p, 'a'))
3023  self.assertTrue(hasattr(p, 'b'))
3024  self.assertTrue(not hasattr(p, 'c'))
3025  self.assertTrue(not hasattr(p, 'd'))
3026  self.assertTrue(not hasattr(p, 'e'))
3027  self.assertTrue(not hasattr(p, 'f'))
3028  self.assertTrue(hasattr(p, 'g'))
3029  self.assertTrue(hasattr(p, 'h'))
3030  self.assertTrue(hasattr(p, 'i'))
3031  self.assertTrue(not hasattr(p, 't1'))
3032  self.assertTrue(hasattr(p, 't2'))
3033  self.assertTrue(hasattr(p, 't3'))
3034  self.assertTrue(hasattr(p, 't4'))
3035  self.assertTrue(not hasattr(p, 's'))
3036  self.assertTrue(hasattr(p, 's2'))
3037  self.assertTrue(not hasattr(p, 's3'))
3038  self.assertTrue(hasattr(p, 'path1'))
3039  self.assertTrue(hasattr(p, 'path2'))
3040  self.assertTrue(hasattr(p, 'path3'))
3041  self.assertTrue(not hasattr(p, 'path4'))
3042  #test SequencePlaceholder
3043  p = Process("test")
3044  p.a = EDAnalyzer("MyAnalyzer")
3045  p.b = EDAnalyzer("YourAnalyzer")
3046  p.s = Sequence(SequencePlaceholder("a")+p.b)
3047  p.pth = Path(p.s)
3048  p.prune()
3049  self.assertTrue(hasattr(p, 'a'))
3050  self.assertTrue(hasattr(p, 'b'))
3051  self.assertTrue(hasattr(p, 's'))
3052  self.assertTrue(hasattr(p, 'pth'))
3053  #test unresolved SequencePlaceholder
3054  p = Process("test")
3055  p.b = EDAnalyzer("YourAnalyzer")
3056  p.s = Sequence(SequencePlaceholder("a")+p.b)
3057  p.pth = Path(p.s)
3058  p.prune(keepUnresolvedSequencePlaceholders=True)
3059  self.assertTrue(hasattr(p, 'b'))
3060  self.assertTrue(hasattr(p, 's'))
3061  self.assertTrue(hasattr(p, 'pth'))
3062  self.assertEqual(p.s.dumpPython(),'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
3063  #test TaskPlaceholder
3064  p = Process("test")
3065  p.a = EDProducer("MyProducer")
3066  p.b = EDProducer("YourProducer")
3067  p.s = Task(TaskPlaceholder("a"),p.b)
3068  p.pth = Path(p.s)
3069  p.prune()
3070  self.assertTrue(hasattr(p, 'a'))
3071  self.assertTrue(hasattr(p, 'b'))
3072  self.assertTrue(hasattr(p, 's'))
3073  self.assertTrue(hasattr(p, 'pth'))
3074  #test unresolved SequencePlaceholder
3075  p = Process("test")
3076  p.b = EDProducer("YourAnalyzer")
3077  p.s = Task(TaskPlaceholder("a"),p.b)
3078  p.pth = Path(p.s)
3079  p.prune(keepUnresolvedSequencePlaceholders=True)
3080  self.assertTrue(hasattr(p, 'b'))
3081  self.assertTrue(hasattr(p, 's'))
3082  self.assertTrue(hasattr(p, 'pth'))
3083  self.assertEqual(p.s.dumpPython(),'cms.Task(cms.TaskPlaceholder("a"), process.b)\n')

◆ testRefToPSet()

def Config.TestModuleCommand.testRefToPSet (   self)

Definition at line 2851 of file Config.py.

2851  def testRefToPSet(self):
2852  proc = Process("test")
2853  proc.top = PSet(a = int32(1))
2854  proc.ref = PSet(refToPSet_ = string("top"))
2855  proc.ref2 = PSet( a = int32(1), b = PSet( refToPSet_ = string("top")))
2856  proc.ref3 = PSet(refToPSet_ = string("ref"))
2857  proc.ref4 = VPSet(PSet(refToPSet_ = string("top")),
2858  PSet(refToPSet_ = string("ref2")))
2859  p = TestMakePSet()
2860  proc.fillProcessDesc(p)
2861  self.assertEqual((True,1),p.values["ref"][1].values["a"])
2862  self.assertEqual((True,1),p.values["ref3"][1].values["a"])
2863  self.assertEqual((True,1),p.values["ref2"][1].values["a"])
2864  self.assertEqual((True,1),p.values["ref2"][1].values["b"][1].values["a"])
2865  self.assertEqual((True,1),p.values["ref4"][1][0].values["a"])
2866  self.assertEqual((True,1),p.values["ref4"][1][1].values["a"])

◆ testSchedule()

def Config.TestModuleCommand.testSchedule (   self)

Definition at line 2583 of file Config.py.

2583  def testSchedule(self):
2584  p = Process("test")
2585  p.a = EDAnalyzer("MyAnalyzer")
2586  p.b = EDAnalyzer("YourAnalyzer")
2587  p.c = EDAnalyzer("OurAnalyzer")
2588  p.d = EDAnalyzer("OurAnalyzer")
2589  p.path1 = Path(p.a)
2590  p.path2 = Path(p.b)
2591  p.path3 = Path(p.d)
2592 
2593  s = Schedule(p.path1,p.path2)
2594  self.assertEqual(s[0],p.path1)
2595  self.assertEqual(s[1],p.path2)
2596  p.schedule = s
2597  self.assertTrue('b' in p.schedule.moduleNames())
2598  self.assertTrue(hasattr(p, 'b'))
2599  self.assertTrue(hasattr(p, 'c'))
2600  self.assertTrue(hasattr(p, 'd'))
2601  self.assertTrue(hasattr(p, 'path1'))
2602  self.assertTrue(hasattr(p, 'path2'))
2603  self.assertTrue(hasattr(p, 'path3'))
2604  p.prune()
2605  self.assertTrue('b' in p.schedule.moduleNames())
2606  self.assertTrue(hasattr(p, 'b'))
2607  self.assertTrue(not hasattr(p, 'c'))
2608  self.assertTrue(not hasattr(p, 'd'))
2609  self.assertTrue(hasattr(p, 'path1'))
2610  self.assertTrue(hasattr(p, 'path2'))
2611  self.assertTrue(not hasattr(p, 'path3'))
2612 
2613  self.assertTrue(len(p.schedule._tasks) == 0)
2614 
2615  p = Process("test")
2616  p.a = EDAnalyzer("MyAnalyzer")
2617  p.b = EDAnalyzer("YourAnalyzer")
2618  p.c = EDAnalyzer("OurAnalyzer")
2619  p.d = EDAnalyzer("dAnalyzer")
2620  p.e = EDProducer("eProducer")
2621  p.f = EDProducer("fProducer")
2622  p.Tracer = Service("Tracer")
2623  p.path1 = Path(p.a)
2624  p.path2 = Path(p.b)
2625  p.path3 = Path(p.d)
2626  p.task1 = Task(p.e)
2627  p.task2 = Task(p.f, p.Tracer)
2628  s = Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
2629  self.assertEqual(s[0],p.path1)
2630  self.assertEqual(s[1],p.path2)
2631  self.assertTrue(len(s._tasks) == 2)
2632  self.assertTrue(p.task1 in s._tasks)
2633  self.assertTrue(p.task2 in s._tasks)
2634  listOfTasks = list(s._tasks)
2635  self.assertTrue(len(listOfTasks) == 2)
2636  self.assertTrue(p.task1 == listOfTasks[0])
2637  self.assertTrue(p.task2 == listOfTasks[1])
2638  p.schedule = s
2639  self.assertTrue('b' in p.schedule.moduleNames())
2640 
2641  process2 = Process("test")
2642  process2.a = EDAnalyzer("MyAnalyzer")
2643  process2.e = EDProducer("eProducer")
2644  process2.path1 = Path(process2.a)
2645  process2.task1 = Task(process2.e)
2646  process2.schedule = Schedule(process2.path1,tasks=process2.task1)
2647  listOfTasks = list(process2.schedule._tasks)
2648  self.assertTrue(listOfTasks[0] == process2.task1)
2649 
2650  # test Schedule copy
2651  s2 = s.copy()
2652  self.assertEqual(s2[0],p.path1)
2653  self.assertEqual(s2[1],p.path2)
2654  self.assertTrue(len(s2._tasks) == 2)
2655  self.assertTrue(p.task1 in s2._tasks)
2656  self.assertTrue(p.task2 in s2._tasks)
2657  listOfTasks = list(s2._tasks)
2658  self.assertTrue(len(listOfTasks) == 2)
2659  self.assertTrue(p.task1 == listOfTasks[0])
2660  self.assertTrue(p.task2 == listOfTasks[1])
2661 
2662  names = s.moduleNames()
2663  self.assertTrue(names == set(['a', 'b', 'e', 'Tracer', 'f']))
2664  #adding a path not attached to the Process should cause an exception
2665  p = Process("test")
2666  p.a = EDAnalyzer("MyAnalyzer")
2667  path1 = Path(p.a)
2668  s = Schedule(path1)
2669  self.assertRaises(RuntimeError, lambda : p.setSchedule_(s) )
2670 
2671  #make sure anonymous sequences work
2672  p = Process("test")
2673  p.a = EDAnalyzer("MyAnalyzer")
2674  p.b = EDAnalyzer("MyOtherAnalyzer")
2675  p.c = EDProducer("MyProd")
2676  path1 = Path(p.c*Sequence(p.a+p.b))
2677  s = Schedule(path1)
2678  self.assertTrue('a' in s.moduleNames())
2679  self.assertTrue('b' in s.moduleNames())
2680  self.assertTrue('c' in s.moduleNames())
2681  p.path1 = path1
2682  p.schedule = s
2683  p.prune()
2684  self.assertTrue('a' in s.moduleNames())
2685  self.assertTrue('b' in s.moduleNames())
2686  self.assertTrue('c' in s.moduleNames())
2687 

◆ testSecSource()

def Config.TestModuleCommand.testSecSource (   self)

Definition at line 2176 of file Config.py.

2176  def testSecSource(self):
2177  p = Process('test')
2178  p.a = SecSource("MySecSource")
2179  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),'process.a = cms.SecSource("MySecSource")')
2180 

References Config._lineDiff(), and ConfigBuilder.dumpPython().

◆ testSequence()

def Config.TestModuleCommand.testSequence (   self)

Definition at line 2233 of file Config.py.

2233  def testSequence(self):
2234  p = Process('test')
2235  p.a = EDAnalyzer("MyAnalyzer")
2236  p.b = EDAnalyzer("YourAnalyzer")
2237  p.c = EDAnalyzer("OurAnalyzer")
2238  p.s = Sequence(p.a*p.b)
2239  self.assertEqual(str(p.s),'a+b')
2240  self.assertEqual(p.s.label_(),'s')
2241  path = Path(p.c+p.s)
2242  self.assertEqual(str(path),'c+a+b')
2243  p._validateSequence(path, 'p1')
2244  notInProcess = EDAnalyzer('NotInProcess')
2245  p2 = Path(p.c+p.s*notInProcess)
2246  self.assertRaises(RuntimeError, p._validateSequence, p2, 'p2')
2247 

References str.

◆ testSequence2()

def Config.TestModuleCommand.testSequence2 (   self)

Definition at line 2248 of file Config.py.

2248  def testSequence2(self):
2249  p = Process('test')
2250  p.a = EDAnalyzer("MyAnalyzer")
2251  p.b = EDAnalyzer("YourAnalyzer")
2252  p.c = EDAnalyzer("OurAnalyzer")
2253  testseq = Sequence(p.a*p.b)
2254  p.s = testseq
2255  #p.y = testseq
2256  self.assertRaises(ValueError, p.__setattr__, "y", testseq)
2257 

◆ testServiceInProcess()

def Config.TestModuleCommand.testServiceInProcess (   self)

Definition at line 2258 of file Config.py.

2258  def testServiceInProcess(self):
2259  service = Service("d")
2260  self.assertFalse(service._inProcess)
2261  process = Process("test")
2262  process.d = service
2263  self.assertTrue(service._inProcess)
2264  service2 = Service("d")
2265  process.d = service2
2266  self.assertFalse(service._inProcess)
2267  self.assertTrue(service2._inProcess)
2268  del process.d
2269  self.assertFalse(service2._inProcess)
2270 

◆ testSubProcess()

def Config.TestModuleCommand.testSubProcess (   self)

Definition at line 2828 of file Config.py.

2828  def testSubProcess(self):
2829  process = Process("Parent")
2830  subProcess = Process("Child")
2831  subProcess.a = EDProducer("A")
2832  subProcess.p = Path(subProcess.a)
2833  subProcess.add_(Service("Foo"))
2834  process.addSubProcess(SubProcess(subProcess))
2835  d = process.dumpPython()
2836  equalD ="""parentProcess = process
2837 process.a = cms.EDProducer("A")
2838 process.Foo = cms.Service("Foo")
2839 process.p = cms.Path(process.a)
2840 childProcess = process
2841 process = parentProcess
2842 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet(
2843 ), outputCommands = cms.untracked.vstring()))"""
2844  equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcesses_()[0])))
2845  self.assertEqual(_lineDiff(d,Process('Parent').dumpPython()+Process('Child').dumpPython()),equalD)
2846  p = TestMakePSet()
2847  process.fillProcessDesc(p)
2848  self.assertEqual((True,['a']),p.values["subProcesses"][1][0].values["process"][1].values['@all_modules'])
2849  self.assertEqual((True,['p']),p.values["subProcesses"][1][0].values["process"][1].values['@paths'])
2850  self.assertEqual({'@service_type':(True,'Foo')}, p.values["subProcesses"][1][0].values["process"][1].values["services"][1][0].values)

References Config._lineDiff(), ConfigBuilder.dumpPython(), cond.hash, and str.

◆ testSwitchProducer()

def Config.TestModuleCommand.testSwitchProducer (   self)

Definition at line 2867 of file Config.py.

2867  def testSwitchProducer(self):
2868  proc = Process("test")
2869  proc.sp = SwitchProducerTest(test2 = EDProducer("Foo",
2870  a = int32(1),
2871  b = PSet(c = int32(2))),
2872  test1 = EDProducer("Bar",
2873  aa = int32(11),
2874  bb = PSet(cc = int32(12))))
2875  proc.a = EDProducer("A")
2876  proc.s = Sequence(proc.a + proc.sp)
2877  proc.t = Task(proc.a, proc.sp)
2878  proc.p = Path()
2879  proc.p.associate(proc.t)
2880  p = TestMakePSet()
2881  proc.fillProcessDesc(p)
2882  self.assertEqual((True,"EDProducer"), p.values["sp"][1].values["@module_edm_type"])
2883  self.assertEqual((True, "SwitchProducer"), p.values["sp"][1].values["@module_type"])
2884  self.assertEqual((True, "sp"), p.values["sp"][1].values["@module_label"])
2885  all_cases = copy.deepcopy(p.values["sp"][1].values["@all_cases"])
2886  all_cases[1].sort() # names of all cases come via dict, i.e. their order is undefined
2887  self.assertEqual((True, ["sp@test1", "sp@test2"]), all_cases)
2888  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
2889  self.assertEqual(["a", "sp", "sp@test1", "sp@test2"], p.values["@all_modules"][1])
2890  self.assertEqual((True,"EDProducer"), p.values["sp@test1"][1].values["@module_edm_type"])
2891  self.assertEqual((True,"Bar"), p.values["sp@test1"][1].values["@module_type"])
2892  self.assertEqual((True,"EDProducer"), p.values["sp@test2"][1].values["@module_edm_type"])
2893  self.assertEqual((True,"Foo"), p.values["sp@test2"][1].values["@module_type"])
2894  dump = proc.dumpPython()
2895  self.assertEqual(dump.find('@'), -1)
2896  self.assertEqual(specialImportRegistry.getSpecialImports(), ["from test import SwitchProducerTest"])
2897  self.assertTrue(dump.find("\nfrom test import SwitchProducerTest\n") != -1)
2898 
2899  # EDAlias as non-chosen case
2900  proc = Process("test")
2901  proc.sp = SwitchProducerTest(test2 = EDProducer("Foo",
2902  a = int32(1),
2903  b = PSet(c = int32(2))),
2904  test1 = EDAlias(a = VPSet(PSet(type = string("Bar")))))
2905  proc.a = EDProducer("A")
2906  proc.s = Sequence(proc.a + proc.sp)
2907  proc.t = Task(proc.a, proc.sp)
2908  proc.p = Path()
2909  proc.p.associate(proc.t)
2910  p = TestMakePSet()
2911  proc.fillProcessDesc(p)
2912  self.assertEqual((True,"EDProducer"), p.values["sp"][1].values["@module_edm_type"])
2913  self.assertEqual((True, "SwitchProducer"), p.values["sp"][1].values["@module_type"])
2914  self.assertEqual((True, "sp"), p.values["sp"][1].values["@module_label"])
2915  all_cases = copy.deepcopy(p.values["sp"][1].values["@all_cases"])
2916  all_cases[1].sort()
2917  self.assertEqual((True, ["sp@test1", "sp@test2"]), all_cases)
2918  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
2919  self.assertEqual(["a", "sp", "sp@test2"], p.values["@all_modules"][1])
2920  self.assertEqual(["sp@test1"], p.values["@all_aliases"][1])
2921  self.assertEqual((True,"EDProducer"), p.values["sp@test2"][1].values["@module_edm_type"])
2922  self.assertEqual((True,"Foo"), p.values["sp@test2"][1].values["@module_type"])
2923  self.assertEqual((True,"EDAlias"), p.values["sp@test1"][1].values["@module_edm_type"])
2924  self.assertEqual((True,"Bar"), p.values["sp@test1"][1].values["a"][1][0].values["type"])
2925 
2926  # EDAlias as chosen case
2927  proc = Process("test")
2928  proc.sp = SwitchProducerTest(test1 = EDProducer("Foo",
2929  a = int32(1),
2930  b = PSet(c = int32(2))),
2931  test2 = EDAlias(a = VPSet(PSet(type = string("Bar")))))
2932  proc.a = EDProducer("A")
2933  proc.s = Sequence(proc.a + proc.sp)
2934  proc.t = Task(proc.a, proc.sp)
2935  proc.p = Path()
2936  proc.p.associate(proc.t)
2937  p = TestMakePSet()
2938  proc.fillProcessDesc(p)
2939  self.assertEqual((True,"EDProducer"), p.values["sp"][1].values["@module_edm_type"])
2940  self.assertEqual((True, "SwitchProducer"), p.values["sp"][1].values["@module_type"])
2941  self.assertEqual((True, "sp"), p.values["sp"][1].values["@module_label"])
2942  self.assertEqual((True, ["sp@test1", "sp@test2"]), p.values["sp"][1].values["@all_cases"])
2943  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
2944  self.assertEqual(["a", "sp", "sp@test1"], p.values["@all_modules"][1])
2945  self.assertEqual(["sp@test2"], p.values["@all_aliases"][1])
2946  self.assertEqual((True,"EDProducer"), p.values["sp@test1"][1].values["@module_edm_type"])
2947  self.assertEqual((True,"Foo"), p.values["sp@test1"][1].values["@module_type"])
2948  self.assertEqual((True,"EDAlias"), p.values["sp@test2"][1].values["@module_edm_type"])
2949  self.assertEqual((True,"Bar"), p.values["sp@test2"][1].values["a"][1][0].values["type"])
2950 

References jetUpdater_cfi.sort.

◆ testTask()

def Config.TestModuleCommand.testTask (   self)

Definition at line 2271 of file Config.py.

2271  def testTask(self):
2272 
2273  # create some objects to use in tests
2274  edanalyzer = EDAnalyzer("a")
2275  edproducer = EDProducer("b")
2276  edproducer2 = EDProducer("b2")
2277  edproducer3 = EDProducer("b3")
2278  edproducer4 = EDProducer("b4")
2279  edproducer8 = EDProducer("b8")
2280  edproducer9 = EDProducer("b9")
2281  edfilter = EDFilter("c")
2282  service = Service("d")
2283  service3 = Service("d")
2284  essource = ESSource("e")
2285  esproducer = ESProducer("f")
2286  testTask2 = Task()
2287 
2288  # test adding things to Tasks
2289  testTask1 = Task(edproducer, edfilter)
2290  self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2291  testTask1.add(essource, service)
2292  testTask1.add(essource, esproducer)
2293  testTask1.add(testTask2)
2294  coll = testTask1._collection
2295  self.assertTrue(edproducer in coll)
2296  self.assertTrue(edfilter in coll)
2297  self.assertTrue(service in coll)
2298  self.assertTrue(essource in coll)
2299  self.assertTrue(esproducer in coll)
2300  self.assertTrue(testTask2 in coll)
2301  self.assertTrue(len(coll) == 6)
2302  self.assertTrue(len(testTask2._collection) == 0)
2303 
2304  taskContents = []
2305  for i in testTask1:
2306  taskContents.append(i)
2307  self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2308 
2309  # test attaching Task to Process
2310  process = Process("test")
2311 
2312  process.mproducer = edproducer
2313  process.mproducer2 = edproducer2
2314  process.mfilter = edfilter
2315  process.messource = essource
2316  process.mesproducer = esproducer
2317  process.d = service
2318 
2319  testTask3 = Task(edproducer, edproducer2)
2320  testTask1.add(testTask3)
2321  process.myTask1 = testTask1
2322 
2323  # test the validation that occurs when attaching a Task to a Process
2324  # first a case that passes, then one the fails on an EDProducer
2325  # then one that fails on a service
2326  l = set()
2327  visitor = NodeNameVisitor(l)
2328  testTask1.visit(visitor)
2329  self.assertTrue(l == set(['mesproducer', 'mproducer', 'mproducer2', 'mfilter', 'd', 'messource']))
2330  l2 = testTask1.moduleNames
2331  self.assertTrue(l == set(['mesproducer', 'mproducer', 'mproducer2', 'mfilter', 'd', 'messource']))
2332 
2333  testTask4 = Task(edproducer3)
2334  l.clear()
2335  self.assertRaises(RuntimeError, testTask4.visit, visitor)
2336  try:
2337  process.myTask4 = testTask4
2338  self.assertTrue(False)
2339  except RuntimeError:
2340  pass
2341 
2342  testTask5 = Task(service3)
2343  l.clear()
2344  self.assertRaises(RuntimeError, testTask5.visit, visitor)
2345  try:
2346  process.myTask5 = testTask5
2347  self.assertTrue(False)
2348  except RuntimeError:
2349  pass
2350 
2351  process.d = service3
2352  process.myTask5 = testTask5
2353 
2354  # test placement into the Process and the tasks property
2355  expectedDict = { 'myTask1' : testTask1, 'myTask5' : testTask5 }
2356  expectedFixedDict = DictTypes.FixedKeysDict(expectedDict);
2357  self.assertTrue(process.tasks == expectedFixedDict)
2358  self.assertTrue(process.tasks['myTask1'] == testTask1)
2359  self.assertTrue(process.myTask1 == testTask1)
2360 
2361  # test replacing an EDProducer in a Task when calling __settattr__
2362  # for the EDProducer on the Process.
2363  process.mproducer2 = edproducer4
2364  process.d = service
2365  l = list()
2366  visitor1 = ModuleNodeVisitor(l)
2367  testTask1.visit(visitor1)
2368  l.sort(key=lambda mod: mod.__str__())
2369  expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=lambda mod: mod.__str__())
2370  self.assertTrue(expectedList == l)
2371  process.myTask6 = Task()
2372  process.myTask7 = Task()
2373  process.mproducer8 = edproducer8
2374  process.myTask8 = Task(process.mproducer8)
2375  process.myTask6.add(process.myTask7)
2376  process.myTask7.add(process.myTask8)
2377  process.myTask1.add(process.myTask6)
2378  process.myTask8.add(process.myTask5)
2379 
2380  testDict = process._itemsInDependencyOrder(process.tasks)
2381  expectedLabels = ["myTask5", "myTask8", "myTask7", "myTask6", "myTask1"]
2382  expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2383  index = 0
2384  for testLabel, testTask in testDict.items():
2385  self.assertTrue(testLabel == expectedLabels[index])
2386  self.assertTrue(testTask == expectedTasks[index])
2387  index += 1
2388 
2389  pythonDump = testTask1.dumpPython(PrintOptions())
2390 
2391 
2392  expectedPythonDump = 'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n'
2393  self.assertTrue(pythonDump == expectedPythonDump)
2394 
2395  process.myTask5 = Task()
2396  process.myTask100 = Task()
2397  process.mproducer9 = edproducer9
2398  sequence1 = Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
2399  sequence2 = Sequence(process.mproducer8 + process.mproducer9)
2400  process.sequence3 = Sequence((process.mproducer8 + process.mfilter))
2401  sequence4 = Sequence()
2402  process.path1 = Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
2403  process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
2404  process.path11 = Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
2405  process.path2 = Path(process.mproducer)
2406  process.path3 = Path(process.mproducer9+process.mproducer8,testTask2)
2407 
2408  self.assertTrue(process.path1.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask5)\n')
2409 
2410  self.assertTrue(process.path11.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask100, process.myTask5)\n')
2411 
2412  # test NodeNameVisitor and moduleNames
2413  l = set()
2414  nameVisitor = NodeNameVisitor(l)
2415  process.path1.visit(nameVisitor)
2416  self.assertTrue(l == set(['mproducer', 'd', 'mesproducer', None, 'mproducer9', 'mproducer8', 'messource', 'mproducer2', 'mfilter']))
2417  self.assertTrue(process.path1.moduleNames() == set(['mproducer', 'd', 'mesproducer', None, 'mproducer9', 'mproducer8', 'messource', 'mproducer2', 'mfilter']))
2418 
2419  # test copy
2420  process.mproducer10 = EDProducer("b10")
2421  process.path21 = process.path11.copy()
2422  process.path21.replace(process.mproducer, process.mproducer10)
2423 
2424  self.assertTrue(process.path11.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer), process.myTask1, process.myTask100, process.myTask5)\n')
2425 
2426  # Some peculiarities of the way things work show up here. dumpPython sorts tasks and
2427  # removes duplication at the level of strings. The Task and Sequence objects themselves
2428  # remove duplicate tasks in their contents if the instances are the same (exact same python
2429  # object id which is not the same as the string representation being the same).
2430  # Also note that the mutating visitor replaces sequences and tasks that have
2431  # modified contents with their modified contents, it does not modify the sequence
2432  # or task itself.
2433  self.assertTrue(process.path21.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
2434 
2435  process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
2436  self.assertTrue(process.path22.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.messource, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
2437 
2438  process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
2439  self.assertTrue(process.path23.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None), cms.Task(process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
2440 
2441  process.a = EDAnalyzer("MyAnalyzer")
2442  process.b = OutputModule("MyOutputModule")
2443  process.c = EDFilter("MyFilter")
2444  process.d = EDProducer("MyProducer")
2445  process.e = ESProducer("MyESProducer")
2446  process.f = ESSource("MyESSource")
2447  process.g = ESProducer("g")
2448  process.path24 = Path(process.a+process.b+process.c+process.d)
2449  process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
2450  self.assertTrue(process.path25.dumpPython() == 'cms.Path(process.d)\n')
2451  #print process.path3
2452  #print process.dumpPython()
2453 
2454  process.path200 = EndPath(Sequence(process.c,Task(process.e)))
2455  process.path200.replace(process.c,process.b)
2456  process.path200.replace(process.e,process.f)
2457  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.b, cms.Task(process.f))\n")
2458  process.path200.replace(process.b,process.c)
2459  process.path200.replace(process.f,process.e)
2460  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.c, cms.Task(process.e))\n")
2461  process.path200.replace(process.c,process.a)
2462  process.path200.replace(process.e,process.g)
2463  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.a, cms.Task(process.g))\n")
2464  process.path200.replace(process.a,process.c)
2465  process.path200.replace(process.g,process.e)
2466  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.c, cms.Task(process.e))\n")
2467 
2468 

◆ testTaskPlaceholder()

def Config.TestModuleCommand.testTaskPlaceholder (   self)

Definition at line 3084 of file Config.py.

3084  def testTaskPlaceholder(self):
3085  p = Process("test")
3086  p.a = EDProducer("ma")
3087  p.b = EDAnalyzer("mb")
3088  p.t1 = Task(TaskPlaceholder("c"))
3089  p.t2 = Task(p.a, TaskPlaceholder("d"), p.t1)
3090  p.t3 = Task(TaskPlaceholder("e"))
3091  p.path1 = Path(p.b, p.t2, p.t3)
3092  p.t5 = Task(p.a, TaskPlaceholder("g"), TaskPlaceholder("t4"))
3093  p.t4 = Task(TaskPlaceholder("f"))
3094  p.endpath1 = EndPath(p.b, p.t5)
3095  p.t6 = Task(TaskPlaceholder("h"))
3096  p.t7 = Task(p.a, TaskPlaceholder("i"), p.t6)
3097  p.t8 = Task(TaskPlaceholder("j"))
3098  p.schedule = Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
3099  p.c = EDProducer("mc")
3100  p.d = EDProducer("md")
3101  p.e = EDProducer("me")
3102  p.f = EDProducer("mf")
3103  p.g = EDProducer("mg")
3104  p.h = EDProducer("mh")
3105  p.i = EDProducer("mi")
3106  p.j = EDProducer("mj")
3107  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),
3108 """process.a = cms.EDProducer("ma")
3109 process.c = cms.EDProducer("mc")
3110 process.d = cms.EDProducer("md")
3111 process.e = cms.EDProducer("me")
3112 process.f = cms.EDProducer("mf")
3113 process.g = cms.EDProducer("mg")
3114 process.h = cms.EDProducer("mh")
3115 process.i = cms.EDProducer("mi")
3116 process.j = cms.EDProducer("mj")
3117 process.b = cms.EDAnalyzer("mb")
3118 process.t1 = cms.Task(cms.TaskPlaceholder("c"))
3119 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1)
3120 process.t3 = cms.Task(cms.TaskPlaceholder("e"))
3121 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a)
3122 process.t4 = cms.Task(cms.TaskPlaceholder("f"))
3123 process.t6 = cms.Task(cms.TaskPlaceholder("h"))
3124 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6)
3125 process.t8 = cms.Task(cms.TaskPlaceholder("j"))
3126 process.path1 = cms.Path(process.b, process.t2, process.t3)
3127 process.endpath1 = cms.EndPath(process.b, process.t5)
3128 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3129  p.resolve()
3130  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),
3131 """process.a = cms.EDProducer("ma")
3132 process.c = cms.EDProducer("mc")
3133 process.d = cms.EDProducer("md")
3134 process.e = cms.EDProducer("me")
3135 process.f = cms.EDProducer("mf")
3136 process.g = cms.EDProducer("mg")
3137 process.h = cms.EDProducer("mh")
3138 process.i = cms.EDProducer("mi")
3139 process.j = cms.EDProducer("mj")
3140 process.b = cms.EDAnalyzer("mb")
3141 process.t1 = cms.Task(process.c)
3142 process.t2 = cms.Task(process.a, process.d, process.t1)
3143 process.t3 = cms.Task(process.e)
3144 process.t4 = cms.Task(process.f)
3145 process.t6 = cms.Task(process.h)
3146 process.t7 = cms.Task(process.a, process.i, process.t6)
3147 process.t8 = cms.Task(process.j)
3148 process.t5 = cms.Task(process.a, process.g, process.t4)
3149 process.path1 = cms.Path(process.b, process.t2, process.t3)
3150 process.endpath1 = cms.EndPath(process.b, process.t5)
3151 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3152 

References Config._lineDiff(), and ConfigBuilder.dumpPython().

◆ testTypedParameterizable()

def Config.TestModuleCommand.testTypedParameterizable (   self)

Definition at line 1876 of file Config.py.

1876  def testTypedParameterizable(self):
1877  p = _TypedParameterizable("blah", b=int32(1))
1878  #see if copy works deeply
1879  other = p.copy()
1880  other.b = 2
1881  self.assertNotEqual(p.b,other.b)
1882 

◆ testUsing()

def Config.TestModuleCommand.testUsing (   self)

Definition at line 2721 of file Config.py.

2721  def testUsing(self):
2722  p = Process('test')
2723  p.block = PSet(a = int32(1))
2724  p.modu = EDAnalyzer('Analyzer', p.block, b = int32(2))
2725  self.assertEqual(p.modu.a.value(),1)
2726  self.assertEqual(p.modu.b.value(),2)
2727 

Member Data Documentation

◆ a

Config.TestModuleCommand.a
static

Definition at line 2075 of file Config.py.

◆ b

Config.TestModuleCommand.b
static

Definition at line 2092 of file Config.py.

◆ c

Config.TestModuleCommand.c
static

Definition at line 2093 of file Config.py.

◆ d

Config.TestModuleCommand.d
static

Definition at line 2081 of file Config.py.

◆ e

Config.TestModuleCommand.e
static

Definition at line 2095 of file Config.py.

◆ f

Config.TestModuleCommand.f
static

Definition at line 2096 of file Config.py.

◆ g

Config.TestModuleCommand.g
static

Definition at line 2097 of file Config.py.

◆ p

Config.TestModuleCommand.p
static

Definition at line 2074 of file Config.py.

Referenced by Electron.Electron.ptErr().

◆ p2

Config.TestModuleCommand.p2
static

Definition at line 2079 of file Config.py.

◆ proc_mod_

Config.TestModuleCommand.proc_mod_

Definition at line 3280 of file Config.py.

◆ process

Config.TestModuleCommand.process
static

◆ r

Config.TestModuleCommand.r
static

Definition at line 2078 of file Config.py.

◆ s

Config.TestModuleCommand.s
static

Definition at line 2077 of file Config.py.

◆ s1

Config.TestModuleCommand.s1
static

Definition at line 2163 of file Config.py.

◆ s2

Config.TestModuleCommand.s2
static

Definition at line 2153 of file Config.py.

◆ s3

Config.TestModuleCommand.s3
static

Definition at line 2165 of file Config.py.

◆ schedule

Config.TestModuleCommand.schedule
static

Definition at line 2080 of file Config.py.

◆ task1

Config.TestModuleCommand.task1
static

Definition at line 2102 of file Config.py.

◆ task2

Config.TestModuleCommand.task2
static

Definition at line 2100 of file Config.py.

◆ task3

Config.TestModuleCommand.task3
static

Definition at line 2099 of file Config.py.

◆ task4

Config.TestModuleCommand.task4
static

Definition at line 2101 of file Config.py.

◆ task5

Config.TestModuleCommand.task5
static

Definition at line 2098 of file Config.py.

◆ tasks

Config.TestModuleCommand.tasks
static

Definition at line 2108 of file Config.py.

mixOne_cfi.ESProducer
ESProducer
Definition: mixOne_cfi.py:33
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
cond::hash
Definition: Time.h:19
helpers.testContains
def testContains(self)
Definition: helpers.py:415
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
str
#define str(s)
Definition: TestProcessor.cc:53
Service
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
SequenceTypes.ignore
def ignore(seq)
Definition: SequenceTypes.py:628
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DictTypes.FixedKeysDict
Definition: DictTypes.py:71
HistogramManager_cfi.VPSet
def VPSet(*args)
Definition: HistogramManager_cfi.py:404
mps_fire.Path
Path
Definition: mps_fire.py:298
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
ConfigBuilder.dumpPython
def dumpPython(process, name)
Definition: ConfigBuilder.py:94
Types.untracked
untracked
Definition: Types.py:34
Config._lineDiff
def _lineDiff(newString, oldString)
Definition: Config.py:1742
TestTask.testTask
testTask
Definition: TestTask.py:3
OrderedSet
Definition: OrderedSet.py:1
cmsswSequenceInfo.Sequence
Sequence
Definition: cmsswSequenceInfo.py:14
CollectionTags_cfi.Source
Source
Definition: CollectionTags_cfi.py:11