CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 2508 of file Config.py.

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

References triggerObjects_cff.id, and str.

◆ testContains()

def Config.TestModuleCommand.testContains (   self)

Definition at line 2524 of file Config.py.

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

◆ testDelete()

def Config.TestModuleCommand.testDelete (   self)

Definition at line 3152 of file Config.py.

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

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

References Types.untracked.

◆ testFreeze()

def Config.TestModuleCommand.testFreeze (   self)

Definition at line 2809 of file Config.py.

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

◆ testGlobalReplace()

def Config.TestModuleCommand.testGlobalReplace (   self)

Definition at line 2180 of file Config.py.

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

◆ testImplicitSchedule()

def Config.TestModuleCommand.testImplicitSchedule (   self)

Definition at line 2687 of file Config.py.

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

◆ testMaxEvents()

def Config.TestModuleCommand.testMaxEvents (   self)

Definition at line 2762 of file Config.py.

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

◆ testModifier()

def Config.TestModuleCommand.testModifier (   self)

Definition at line 3183 of file Config.py.

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

References resolutioncreator_cfi.object.

◆ testOptions()

def Config.TestModuleCommand.testOptions (   self)

Definition at line 2750 of file Config.py.

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

◆ testOverride()

def Config.TestModuleCommand.testOverride (   self)

Definition at line 2727 of file Config.py.

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

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

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

References SequenceTypes.ignore(), and str.

◆ testPrefers()

def Config.TestModuleCommand.testPrefers (   self)

Definition at line 2789 of file Config.py.

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

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  emptyRunLumiMode = cms.obsolete.untracked.string,
2019  eventSetup = cms.untracked.PSet(
2020  forceNumberOfConcurrentIOVs = cms.untracked.PSet(
2021  allowAnyLabel_=cms.required.untracked.uint32
2022  ),
2023  numberOfConcurrentIOVs = cms.untracked.uint32(1)
2024  ),
2025  fileMode = cms.untracked.string('FULLMERGE'),
2026  forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
2027  makeTriggerResults = cms.obsolete.untracked.bool,
2028  numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(1),
2029  numberOfConcurrentRuns = cms.untracked.uint32(1),
2030  numberOfStreams = cms.untracked.uint32(0),
2031  numberOfThreads = cms.untracked.uint32(1),
2032  printDependencies = cms.untracked.bool(False),
2033  sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
2034  throwIfIllegalParameter = cms.untracked.bool(True),
2035  wantSummary = cms.untracked.bool(False)
2036 )
2037 
2038 """)
2039  p = Process("test")
2040  p.a = EDAnalyzer("MyAnalyzer")
2041  p.p = Path(p.a)
2042  p.s = Sequence(p.a)
2043  p.r = Sequence(p.s)
2044  p.p2 = Path(p.s)
2045  p.schedule = Schedule(p.p2,p.p)
2046  d=p.dumpPython()
2047  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2048 """process.a = cms.EDAnalyzer("MyAnalyzer")
2049 process.s = cms.Sequence(process.a)
2050 process.r = cms.Sequence(process.s)
2051 process.p = cms.Path(process.a)
2052 process.p2 = cms.Path(process.s)
2053 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2054  #Reverse order of 'r' and 's'
2055  p = Process("test")
2056  p.a = EDAnalyzer("MyAnalyzer")
2057  p.p = Path(p.a)
2058  p.r = Sequence(p.a)
2059  p.s = Sequence(p.r)
2060  p.p2 = Path(p.r)
2061  p.schedule = Schedule(p.p2,p.p)
2062  p.b = EDAnalyzer("YourAnalyzer")
2063  d=p.dumpPython()
2064  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2065 """process.a = cms.EDAnalyzer("MyAnalyzer")
2066 process.b = cms.EDAnalyzer("YourAnalyzer")
2067 process.r = cms.Sequence(process.a)
2068 process.s = cms.Sequence(process.r)
2069 process.p = cms.Path(process.a)
2070 process.p2 = cms.Path(process.r)
2071 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 six.iterkeys(args):
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 3516 of file Config.py.

3516  def testProcessFragment(self):
3517  #check defaults are not overwritten
3518  f = ProcessFragment('Fragment')
3519  p = Process('PROCESS')
3520  p.maxEvents.input = 10
3521  p.options.numberOfThreads = 4
3522  p.maxLuminosityBlocks.input = 2
3523  p.extend(f)
3524  self.assertEqual(p.maxEvents.input.value(),10)
3525  self.assertEqual(p.options.numberOfThreads.value(), 4)
3526  self.assertEqual(p.maxLuminosityBlocks.input.value(),2)
3527  #general checks
3528  f = ProcessFragment("Fragment")
3529  f.fltr = EDFilter("Foo")
3530  p = Process('PROCESS')
3531  p.extend(f)
3532  self.assertTrue(hasattr(p,'fltr'))
3533 
3534  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 2950 of file Config.py.

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

◆ testRefToPSet()

def Config.TestModuleCommand.testRefToPSet (   self)

Definition at line 2850 of file Config.py.

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

◆ testSchedule()

def Config.TestModuleCommand.testSchedule (   self)

Definition at line 2582 of file Config.py.

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

◆ testSecSource()

def Config.TestModuleCommand.testSecSource (   self)

Definition at line 2175 of file Config.py.

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

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

◆ testSequence()

def Config.TestModuleCommand.testSequence (   self)

Definition at line 2232 of file Config.py.

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

References str.

◆ testSequence2()

def Config.TestModuleCommand.testSequence2 (   self)

Definition at line 2247 of file Config.py.

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

◆ testServiceInProcess()

def Config.TestModuleCommand.testServiceInProcess (   self)

Definition at line 2257 of file Config.py.

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

◆ testSubProcess()

def Config.TestModuleCommand.testSubProcess (   self)

Definition at line 2827 of file Config.py.

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

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

References jetUpdater_cfi.sort.

◆ testTask()

def Config.TestModuleCommand.testTask (   self)

Definition at line 2270 of file Config.py.

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

◆ testTaskPlaceholder()

def Config.TestModuleCommand.testTaskPlaceholder (   self)

Definition at line 3083 of file Config.py.

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

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

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

Member Data Documentation

◆ a

Config.TestModuleCommand.a
static

Definition at line 2074 of file Config.py.

◆ b

Config.TestModuleCommand.b
static

Definition at line 2091 of file Config.py.

◆ c

Config.TestModuleCommand.c
static

Definition at line 2092 of file Config.py.

◆ d

Config.TestModuleCommand.d
static

Definition at line 2080 of file Config.py.

◆ e

Config.TestModuleCommand.e
static

Definition at line 2094 of file Config.py.

◆ f

Config.TestModuleCommand.f
static

Definition at line 2095 of file Config.py.

◆ g

Config.TestModuleCommand.g
static

Definition at line 2096 of file Config.py.

◆ p

Config.TestModuleCommand.p
static

Definition at line 2073 of file Config.py.

Referenced by Electron.Electron.ptErr().

◆ p2

Config.TestModuleCommand.p2
static

Definition at line 2078 of file Config.py.

◆ proc_mod_

Config.TestModuleCommand.proc_mod_

Definition at line 3279 of file Config.py.

◆ process

Config.TestModuleCommand.process
static

◆ r

Config.TestModuleCommand.r
static

Definition at line 2077 of file Config.py.

◆ s

Config.TestModuleCommand.s
static

Definition at line 2076 of file Config.py.

◆ s1

Config.TestModuleCommand.s1
static

Definition at line 2162 of file Config.py.

◆ s2

Config.TestModuleCommand.s2
static

Definition at line 2152 of file Config.py.

◆ s3

Config.TestModuleCommand.s3
static

Definition at line 2164 of file Config.py.

◆ schedule

Config.TestModuleCommand.schedule
static

Definition at line 2079 of file Config.py.

◆ task1

Config.TestModuleCommand.task1
static

Definition at line 2101 of file Config.py.

◆ task2

Config.TestModuleCommand.task2
static

Definition at line 2099 of file Config.py.

◆ task3

Config.TestModuleCommand.task3
static

Definition at line 2098 of file Config.py.

◆ task4

Config.TestModuleCommand.task4
static

Definition at line 2100 of file Config.py.

◆ task5

Config.TestModuleCommand.task5
static

Definition at line 2097 of file Config.py.

◆ tasks

Config.TestModuleCommand.tasks
static

Definition at line 2107 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:89285
str
#define str(s)
Definition: TestProcessor.cc:52
Service
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
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: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:93
Types.untracked
untracked
Definition: Types.py:35
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