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 1835 of file Config.py.

Member Function Documentation

◆ setUp()

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

Definition at line 1836 of file Config.py.

1836  def setUp(self):
1837  """Nothing to do """
1838  None

◆ testCloneSequence()

def Config.TestModuleCommand.testCloneSequence (   self)

Definition at line 2503 of file Config.py.

2503  def testCloneSequence(self):
2504  p = Process("test")
2505  a = EDAnalyzer("MyAnalyzer")
2506  p.a = a
2507  a.setLabel("a")
2508  b = EDAnalyzer("YOurAnalyzer")
2509  p.b = b
2510  b.setLabel("b")
2511  path = Path(a * b)
2512  p.path = Path(p.a*p.b)
2513  lookuptable = {id(a): p.a, id(b): p.b}
2514  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
2515  #lookuptable = p._cloneToObjectDict
2516  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
2517  self.assertEqual(str(path),str(p.path))
2518 

References triggerObjects_cff.id, and str.

◆ testContains()

def Config.TestModuleCommand.testContains (   self)

Definition at line 2519 of file Config.py.

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

◆ testDelete()

def Config.TestModuleCommand.testDelete (   self)

Definition at line 3147 of file Config.py.

3147  def testDelete(self):
3148  p = Process("test")
3149  p.a = EDAnalyzer("MyAnalyzer")
3150  p.b = EDAnalyzer("YourAnalyzer")
3151  p.c = EDAnalyzer("OurAnalyzer")
3152  p.d = EDAnalyzer("OurAnalyzer")
3153  p.e = EDAnalyzer("OurAnalyzer")
3154  p.f = EDAnalyzer("OurAnalyzer")
3155  p.g = EDProducer("OurProducer")
3156  p.h = EDProducer("YourProducer")
3157  p.t1 = Task(p.g, p.h)
3158  t2 = Task(p.g, p.h)
3159  t3 = Task(p.g, p.h)
3160  p.s = Sequence(p.d+p.e)
3161  p.path1 = Path(p.a+p.f+p.s,t2)
3162  p.endpath1 = EndPath(p.b+p.f)
3163  p.schedule = Schedule(tasks=[t3])
3164  self.assertTrue(hasattr(p, 'f'))
3165  self.assertTrue(hasattr(p, 'g'))
3166  del p.e
3167  del p.f
3168  del p.g
3169  self.assertFalse(hasattr(p, 'f'))
3170  self.assertFalse(hasattr(p, 'g'))
3171  self.assertTrue(p.t1.dumpPython() == 'cms.Task(process.h)\n')
3172  self.assertTrue(p.s.dumpPython() == 'cms.Sequence(process.d)\n')
3173  self.assertTrue(p.path1.dumpPython() == 'cms.Path(process.a+process.s, cms.Task(process.h))\n')
3174  self.assertTrue(p.endpath1.dumpPython() == 'cms.EndPath(process.b)\n')
3175  del p.s
3176  self.assertTrue(p.path1.dumpPython() == 'cms.Path(process.a+(process.d), cms.Task(process.h))\n')
3177  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 2772 of file Config.py.

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

References Types.untracked.

◆ testFreeze()

def Config.TestModuleCommand.testFreeze (   self)

Definition at line 2804 of file Config.py.

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

◆ testGlobalReplace()

def Config.TestModuleCommand.testGlobalReplace (   self)

Definition at line 2175 of file Config.py.

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

◆ testImplicitSchedule()

def Config.TestModuleCommand.testImplicitSchedule (   self)

Definition at line 2682 of file Config.py.

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

◆ testMaxEvents()

def Config.TestModuleCommand.testMaxEvents (   self)

Definition at line 2757 of file Config.py.

2757  def testMaxEvents(self):
2758  p = Process("Test")
2759  p.maxEvents.input = 10
2760  self.assertEqual(p.maxEvents.input.value(),10)
2761  p = Process("Test")
2762  p.maxEvents.output = 10
2763  self.assertEqual(p.maxEvents.output.value(),10)
2764  p = Process("Test")
2765  p.maxEvents.output = PSet(out=untracked.int32(10))
2766  self.assertEqual(p.maxEvents.output.out.value(), 10)
2767  p = Process("Test")
2768  p.maxEvents = untracked.PSet(input = untracked.int32(5))
2769  self.assertEqual(p.maxEvents.input.value(), 5)
2770 
2771 

◆ testModifier()

def Config.TestModuleCommand.testModifier (   self)

Definition at line 3178 of file Config.py.

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

References resolutioncreator_cfi.object.

◆ testOptions()

def Config.TestModuleCommand.testOptions (   self)

Definition at line 2745 of file Config.py.

2745  def testOptions(self):
2746  p = Process('test')
2747  self.assertEqual(p.options.numberOfThreads.value(),1)
2748  p.options.numberOfThreads = 8
2749  self.assertEqual(p.options.numberOfThreads.value(),8)
2750  p.options = PSet()
2751  self.assertEqual(p.options.numberOfThreads.value(),1)
2752  p.options = dict(numberOfStreams =2,
2753  numberOfThreads =2)
2754  self.assertEqual(p.options.numberOfThreads.value(),2)
2755  self.assertEqual(p.options.numberOfStreams.value(),2)
2756 

◆ testOverride()

def Config.TestModuleCommand.testOverride (   self)

Definition at line 2722 of file Config.py.

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

◆ testParameterizable()

def Config.TestModuleCommand.testParameterizable (   self)

Definition at line 1839 of file Config.py.

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

◆ testPath()

def Config.TestModuleCommand.testPath (   self)

Definition at line 2463 of file Config.py.

2463  def testPath(self):
2464  p = Process("test")
2465  p.a = EDAnalyzer("MyAnalyzer")
2466  p.b = EDAnalyzer("YourAnalyzer")
2467  p.c = EDAnalyzer("OurAnalyzer")
2468  path = Path(p.a)
2469  path *= p.b
2470  path += p.c
2471  self.assertEqual(str(path),'a+b+c')
2472  path = Path(p.a*p.b+p.c)
2473  self.assertEqual(str(path),'a+b+c')
2474 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences
2475 # self.assertEqual(str(path),'((a*b)+c)')
2476  path = Path(p.a+ p.b*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))
2481  pathx = Path(p.a*(p.b+ignore(p.c)))
2482  self.assertEqual(str(path),'a+b+~c')
2483  p.es = ESProducer("AnESProducer")
2484  self.assertRaises(TypeError,Path,p.es)
2485 
2486  t = Path()
2487  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path()\n')
2488 
2489  t = Path(p.a)
2490  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(process.a)\n')
2491 
2492  t = Path(Task())
2493  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(cms.Task())\n')
2494 
2495  t = Path(p.a, Task())
2496  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(process.a, cms.Task())\n')
2497 
2498  p.prod = EDProducer("prodName")
2499  p.t1 = Task(p.prod)
2500  t = Path(p.a, p.t1, Task(), p.t1)
2501  self.assertTrue(t.dumpPython(PrintOptions()) == 'cms.Path(process.a, cms.Task(), process.t1)\n')
2502 

References SequenceTypes.ignore(), and str.

◆ testPrefers()

def Config.TestModuleCommand.testPrefers (   self)

Definition at line 2784 of file Config.py.

2784  def testPrefers(self):
2785  p = Process("Test")
2786  p.add_(ESSource("ForceSource"))
2787  p.juicer = ESProducer("JuicerProducer")
2788  p.prefer("ForceSource")
2789  p.prefer("juicer")
2790  self.assertEqual(_lineDiff(p.dumpPython(), Process('Test').dumpPython()),
2791 """process.juicer = cms.ESProducer("JuicerProducer")
2792 process.ForceSource = cms.ESSource("ForceSource")
2793 process.prefer("ForceSource")
2794 process.prefer("juicer")""")
2795  p.prefer("juicer",fooRcd=vstring("Foo"))
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  fooRcd = cms.vstring('Foo')
2802 )""")
2803 

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

◆ testProcessDumpPython()

def Config.TestModuleCommand.testProcessDumpPython (   self)

Definition at line 1991 of file Config.py.

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

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

◆ testProcessExtend()

def Config.TestModuleCommand.testProcessExtend (   self)

Definition at line 1904 of file Config.py.

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

References resolutioncreator_cfi.object, and str.

◆ testProcessFragment()

def Config.TestModuleCommand.testProcessFragment (   self)

Definition at line 3511 of file Config.py.

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

◆ testProcessInsertion()

def Config.TestModuleCommand.testProcessInsertion (   self)

Definition at line 1879 of file Config.py.

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

◆ testPrune()

def Config.TestModuleCommand.testPrune (   self)

Definition at line 2945 of file Config.py.

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

◆ testRefToPSet()

def Config.TestModuleCommand.testRefToPSet (   self)

Definition at line 2845 of file Config.py.

2845  def testRefToPSet(self):
2846  proc = Process("test")
2847  proc.top = PSet(a = int32(1))
2848  proc.ref = PSet(refToPSet_ = string("top"))
2849  proc.ref2 = PSet( a = int32(1), b = PSet( refToPSet_ = string("top")))
2850  proc.ref3 = PSet(refToPSet_ = string("ref"))
2851  proc.ref4 = VPSet(PSet(refToPSet_ = string("top")),
2852  PSet(refToPSet_ = string("ref2")))
2853  p = TestMakePSet()
2854  proc.fillProcessDesc(p)
2855  self.assertEqual((True,1),p.values["ref"][1].values["a"])
2856  self.assertEqual((True,1),p.values["ref3"][1].values["a"])
2857  self.assertEqual((True,1),p.values["ref2"][1].values["a"])
2858  self.assertEqual((True,1),p.values["ref2"][1].values["b"][1].values["a"])
2859  self.assertEqual((True,1),p.values["ref4"][1][0].values["a"])
2860  self.assertEqual((True,1),p.values["ref4"][1][1].values["a"])

◆ testSchedule()

def Config.TestModuleCommand.testSchedule (   self)

Definition at line 2577 of file Config.py.

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

◆ testSecSource()

def Config.TestModuleCommand.testSecSource (   self)

Definition at line 2170 of file Config.py.

2170  def testSecSource(self):
2171  p = Process('test')
2172  p.a = SecSource("MySecSource")
2173  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),'process.a = cms.SecSource("MySecSource")')
2174 

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

◆ testSequence()

def Config.TestModuleCommand.testSequence (   self)

Definition at line 2227 of file Config.py.

2227  def testSequence(self):
2228  p = Process('test')
2229  p.a = EDAnalyzer("MyAnalyzer")
2230  p.b = EDAnalyzer("YourAnalyzer")
2231  p.c = EDAnalyzer("OurAnalyzer")
2232  p.s = Sequence(p.a*p.b)
2233  self.assertEqual(str(p.s),'a+b')
2234  self.assertEqual(p.s.label_(),'s')
2235  path = Path(p.c+p.s)
2236  self.assertEqual(str(path),'c+a+b')
2237  p._validateSequence(path, 'p1')
2238  notInProcess = EDAnalyzer('NotInProcess')
2239  p2 = Path(p.c+p.s*notInProcess)
2240  self.assertRaises(RuntimeError, p._validateSequence, p2, 'p2')
2241 

References str.

◆ testSequence2()

def Config.TestModuleCommand.testSequence2 (   self)

Definition at line 2242 of file Config.py.

2242  def testSequence2(self):
2243  p = Process('test')
2244  p.a = EDAnalyzer("MyAnalyzer")
2245  p.b = EDAnalyzer("YourAnalyzer")
2246  p.c = EDAnalyzer("OurAnalyzer")
2247  testseq = Sequence(p.a*p.b)
2248  p.s = testseq
2249  #p.y = testseq
2250  self.assertRaises(ValueError, p.__setattr__, "y", testseq)
2251 

◆ testServiceInProcess()

def Config.TestModuleCommand.testServiceInProcess (   self)

Definition at line 2252 of file Config.py.

2252  def testServiceInProcess(self):
2253  service = Service("d")
2254  self.assertFalse(service._inProcess)
2255  process = Process("test")
2256  process.d = service
2257  self.assertTrue(service._inProcess)
2258  service2 = Service("d")
2259  process.d = service2
2260  self.assertFalse(service._inProcess)
2261  self.assertTrue(service2._inProcess)
2262  del process.d
2263  self.assertFalse(service2._inProcess)
2264 

◆ testSubProcess()

def Config.TestModuleCommand.testSubProcess (   self)

Definition at line 2822 of file Config.py.

2822  def testSubProcess(self):
2823  process = Process("Parent")
2824  subProcess = Process("Child")
2825  subProcess.a = EDProducer("A")
2826  subProcess.p = Path(subProcess.a)
2827  subProcess.add_(Service("Foo"))
2828  process.addSubProcess(SubProcess(subProcess))
2829  d = process.dumpPython()
2830  equalD ="""parentProcess = process
2831 process.a = cms.EDProducer("A")
2832 process.Foo = cms.Service("Foo")
2833 process.p = cms.Path(process.a)
2834 childProcess = process
2835 process = parentProcess
2836 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet(
2837 ), outputCommands = cms.untracked.vstring()))"""
2838  equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcesses_()[0])))
2839  self.assertEqual(_lineDiff(d,Process('Parent').dumpPython()+Process('Child').dumpPython()),equalD)
2840  p = TestMakePSet()
2841  process.fillProcessDesc(p)
2842  self.assertEqual((True,['a']),p.values["subProcesses"][1][0].values["process"][1].values['@all_modules'])
2843  self.assertEqual((True,['p']),p.values["subProcesses"][1][0].values["process"][1].values['@paths'])
2844  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 2861 of file Config.py.

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

◆ testTask()

def Config.TestModuleCommand.testTask (   self)

Definition at line 2265 of file Config.py.

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

◆ testTaskPlaceholder()

def Config.TestModuleCommand.testTaskPlaceholder (   self)

Definition at line 3078 of file Config.py.

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

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

◆ testTypedParameterizable()

def Config.TestModuleCommand.testTypedParameterizable (   self)

Definition at line 1872 of file Config.py.

1872  def testTypedParameterizable(self):
1873  p = _TypedParameterizable("blah", b=int32(1))
1874  #see if copy works deeply
1875  other = p.copy()
1876  other.b = 2
1877  self.assertNotEqual(p.b,other.b)
1878 

◆ testUsing()

def Config.TestModuleCommand.testUsing (   self)

Definition at line 2715 of file Config.py.

2715  def testUsing(self):
2716  p = Process('test')
2717  p.block = PSet(a = int32(1))
2718  p.modu = EDAnalyzer('Analyzer', p.block, b = int32(2))
2719  self.assertEqual(p.modu.a.value(),1)
2720  self.assertEqual(p.modu.b.value(),2)
2721 

Member Data Documentation

◆ a

Config.TestModuleCommand.a
static

Definition at line 2069 of file Config.py.

◆ b

Config.TestModuleCommand.b
static

Definition at line 2086 of file Config.py.

◆ c

Config.TestModuleCommand.c
static

Definition at line 2087 of file Config.py.

◆ d

Config.TestModuleCommand.d
static

Definition at line 2075 of file Config.py.

◆ e

Config.TestModuleCommand.e
static

Definition at line 2089 of file Config.py.

◆ f

Config.TestModuleCommand.f
static

Definition at line 2090 of file Config.py.

◆ g

Config.TestModuleCommand.g
static

Definition at line 2091 of file Config.py.

◆ p

Config.TestModuleCommand.p
static

Definition at line 2068 of file Config.py.

Referenced by Electron.Electron.ptErr().

◆ p2

Config.TestModuleCommand.p2
static

Definition at line 2073 of file Config.py.

◆ proc_mod_

Config.TestModuleCommand.proc_mod_

Definition at line 3274 of file Config.py.

◆ process

Config.TestModuleCommand.process
static

◆ r

Config.TestModuleCommand.r
static

Definition at line 2072 of file Config.py.

◆ s

Config.TestModuleCommand.s
static

Definition at line 2071 of file Config.py.

◆ s1

Config.TestModuleCommand.s1
static

Definition at line 2157 of file Config.py.

◆ s2

Config.TestModuleCommand.s2
static

Definition at line 2147 of file Config.py.

◆ s3

Config.TestModuleCommand.s3
static

Definition at line 2159 of file Config.py.

◆ schedule

Config.TestModuleCommand.schedule
static

Definition at line 2074 of file Config.py.

◆ task1

Config.TestModuleCommand.task1
static

Definition at line 2096 of file Config.py.

◆ task2

Config.TestModuleCommand.task2
static

Definition at line 2094 of file Config.py.

◆ task3

Config.TestModuleCommand.task3
static

Definition at line 2093 of file Config.py.

◆ task4

Config.TestModuleCommand.task4
static

Definition at line 2095 of file Config.py.

◆ task5

Config.TestModuleCommand.task5
static

Definition at line 2092 of file Config.py.

◆ tasks

Config.TestModuleCommand.tasks
static

Definition at line 2102 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:416
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
str
#define str(s)
Definition: TestProcessor.cc:51
Service
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SequenceTypes.ignore
def ignore(seq)
Definition: SequenceTypes.py:630
DictTypes.FixedKeysDict
Definition: DictTypes.py:72
HistogramManager_cfi.VPSet
def VPSet(*args)
Definition: HistogramManager_cfi.py:401
mps_fire.Path
Path
Definition: mps_fire.py:298
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
ConfigBuilder.dumpPython
def dumpPython(process, name)
Definition: ConfigBuilder.py:92
Types.untracked
untracked
Definition: Types.py:35
Config._lineDiff
def _lineDiff(newString, oldString)
Definition: Config.py:1738
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