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 testConditionalTask (self)
 
def testConditionalTaskPlaceholder (self)
 
def testContains (self)
 
def testDelete (self)
 
def testExamples (self)
 
def testFinalPath (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 testProcessAccelerator (self)
 
def testProcessDumpPython (self)
 
def testProcessExtend (self)
 
def testProcessForProcessAccelerator (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 2171 of file Config.py.

Member Function Documentation

◆ setUp()

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

Definition at line 2172 of file Config.py.

2172  def setUp(self):
2173  """Nothing to do """
2174  None

◆ testCloneSequence()

def Config.TestModuleCommand.testCloneSequence (   self)

Definition at line 3236 of file Config.py.

References triggerObjects_cff.id, and str.

3236  def testCloneSequence(self):
3237  p = Process("test")
3238  a = EDAnalyzer("MyAnalyzer")
3239  p.a = a
3240  a.setLabel("a")
3241  b = EDAnalyzer("YOurAnalyzer")
3242  p.b = b
3243  b.setLabel("b")
3244  path = Path(a * b)
3245  p.path = Path(p.a*p.b)
3246  lookuptable = {id(a): p.a, id(b): p.b}
3247  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
3248  #lookuptable = p._cloneToObjectDict
3249  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
3250  self.assertEqual(str(path),str(p.path))
3251 
#define str(s)

◆ testConditionalTask()

def Config.TestModuleCommand.testConditionalTask (   self)

Definition at line 2958 of file Config.py.

2958  def testConditionalTask(self):
2959 
2960  # create some objects to use in tests
2961  edanalyzer = EDAnalyzer("a")
2962  edproducer = EDProducer("b")
2963  edproducer2 = EDProducer("b2")
2964  edproducer3 = EDProducer("b3")
2965  edproducer4 = EDProducer("b4")
2966  edproducer8 = EDProducer("b8")
2967  edproducer9 = EDProducer("b9")
2968  edfilter = EDFilter("c")
2969  service = Service("d")
2970  service3 = Service("d", v = untracked.uint32(3))
2971  essource = ESSource("e")
2972  esproducer = ESProducer("f")
2973  testTask2 = Task()
2974  testCTask2 = ConditionalTask()
2975 
2976  # test adding things to Tasks
2977  testTask1 = ConditionalTask(edproducer, edfilter)
2978  self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2979  testTask1.add(essource, service)
2980  testTask1.add(essource, esproducer)
2981  testTask1.add(testTask2)
2982  testTask1.add(testCTask2)
2983  coll = testTask1._collection
2984  self.assertTrue(edproducer in coll)
2985  self.assertTrue(edfilter in coll)
2986  self.assertTrue(service in coll)
2987  self.assertTrue(essource in coll)
2988  self.assertTrue(esproducer in coll)
2989  self.assertTrue(testTask2 in coll)
2990  self.assertTrue(testCTask2 in coll)
2991  self.assertTrue(len(coll) == 7)
2992  self.assertTrue(len(testTask2._collection) == 0)
2993 
2994  taskContents = []
2995  for i in testTask1:
2996  taskContents.append(i)
2997  self.assertEqual(taskContents, [edproducer, edfilter, essource, service, esproducer, testTask2, testCTask2])
2998 
2999  # test attaching Task to Process
3000  process = Process("test")
3001 
3002  process.mproducer = edproducer
3003  process.mproducer2 = edproducer2
3004  process.mfilter = edfilter
3005  process.messource = essource
3006  process.mesproducer = esproducer
3007  process.d = service
3008 
3009  testTask3 = ConditionalTask(edproducer, edproducer2)
3010  testTask1.add(testTask3)
3011  process.myTask1 = testTask1
3012 
3013  # test the validation that occurs when attaching a ConditionalTask to a Process
3014  # first a case that passes, then one the fails on an EDProducer
3015  # then one that fails on a service
3016  l = set()
3017  visitor = NodeNameVisitor(l)
3018  testTask1.visit(visitor)
3019  self.assertEqual(l, set(['mesproducer', 'mproducer', 'mproducer2', 'mfilter', 'd', 'messource']))
3020  l2 = testTask1.moduleNames()
3021  self.assertEqual(l2, set(['mesproducer', 'mproducer', 'mproducer2', 'mfilter', 'd', 'messource']))
3022 
3023  testTask4 = ConditionalTask(edproducer3)
3024  l.clear()
3025  self.assertRaises(RuntimeError, testTask4.visit, visitor)
3026  try:
3027  process.myTask4 = testTask4
3028  self.assertTrue(False)
3029  except RuntimeError:
3030  pass
3031 
3032  testTask5 = ConditionalTask(service3)
3033  l.clear()
3034  self.assertRaises(RuntimeError, testTask5.visit, visitor)
3035  try:
3036  process.myTask5 = testTask5
3037  self.assertTrue(False)
3038  except RuntimeError:
3039  pass
3040 
3041  process.d = service3
3042  process.myTask5 = testTask5
3043 
3044  # test placement into the Process and the tasks property
3045  expectedDict = { 'myTask1' : testTask1, 'myTask5' : testTask5 }
3046  expectedFixedDict = DictTypes.FixedKeysDict(expectedDict);
3047  self.assertEqual(process.conditionaltasks, expectedFixedDict)
3048  self.assertEqual(process.conditionaltasks['myTask1'], testTask1)
3049  self.assertEqual(process.myTask1, testTask1)
3050 
3051  # test replacing an EDProducer in a ConditionalTask when calling __settattr__
3052  # for the EDProducer on the Process.
3053  process.mproducer2 = edproducer4
3054  process.d = service
3055  l = list()
3056  visitor1 = ModuleNodeVisitor(l)
3057  testTask1.visit(visitor1)
3058  l.sort(key=lambda mod: mod.__str__())
3059  expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=lambda mod: mod.__str__())
3060  self.assertEqual(expectedList, l)
3061  process.myTask6 = ConditionalTask()
3062  process.myTask7 = ConditionalTask()
3063  process.mproducer8 = edproducer8
3064  process.myTask8 = ConditionalTask(process.mproducer8)
3065  process.myTask6.add(process.myTask7)
3066  process.myTask7.add(process.myTask8)
3067  process.myTask1.add(process.myTask6)
3068  process.myTask8.add(process.myTask5)
3069  self.assertEqual(process.myTask8.dumpPython(), "cms.ConditionalTask(process.mproducer8, process.myTask5)\n")
3070 
3071  testDict = process._itemsInDependencyOrder(process.conditionaltasks)
3072  expectedLabels = ["myTask5", "myTask8", "myTask7", "myTask6", "myTask1"]
3073  expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
3074  index = 0
3075  for testLabel, testTask in testDict.items():
3076  self.assertEqual(testLabel, expectedLabels[index])
3077  self.assertEqual(testTask, expectedTasks[index])
3078  index += 1
3079 
3080  pythonDump = testTask1.dumpPython(PrintOptions())
3081 
3082 
3083  expectedPythonDump = 'cms.ConditionalTask(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n'
3084  self.assertEqual(pythonDump, expectedPythonDump)
3085 
3086  process.myTask5 = ConditionalTask()
3087  self.assertEqual(process.myTask8.dumpPython(), "cms.ConditionalTask(process.mproducer8, process.myTask5)\n")
3088  process.myTask100 = ConditionalTask()
3089  process.mproducer9 = edproducer9
3090  sequence1 = Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
3091  sequence2 = Sequence(process.mproducer8 + process.mproducer9)
3092  process.sequence3 = Sequence((process.mproducer8 + process.mfilter))
3093  sequence4 = Sequence()
3094  process.path1 = Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
3095  process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
3096  process.path11 = Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
3097  process.path2 = Path(process.mproducer)
3098  process.path3 = Path(process.mproducer9+process.mproducer8,testTask2)
3099 
3100  self.assertEqual(process.path1.dumpPython(PrintOptions()), 'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)\n')
3101 
3102  self.assertEqual(process.path11.dumpPython(PrintOptions()), 'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask100, process.myTask5)\n')
3103 
3104  # test NodeNameVisitor and moduleNames
3105  l = set()
3106  nameVisitor = NodeNameVisitor(l)
3107  process.path1.visit(nameVisitor)
3108  self.assertTrue(l == set(['mproducer', 'd', 'mesproducer', None, 'mproducer9', 'mproducer8', 'messource', 'mproducer2', 'mfilter']))
3109  self.assertTrue(process.path1.moduleNames() == set(['mproducer', 'd', 'mesproducer', None, 'mproducer9', 'mproducer8', 'messource', 'mproducer2', 'mfilter']))
3110 
3111  # test copy
3112  process.mproducer10 = EDProducer("b10")
3113  process.path21 = process.path11.copy()
3114  process.path21.replace(process.mproducer, process.mproducer10)
3115 
3116  self.assertEqual(process.path11.dumpPython(PrintOptions()), 'cms.Path(process.mproducer+process.mproducer8+cms.Sequence(process.mproducer8, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask5)+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer), cms.Task(), process.myTask1, process.myTask100, process.myTask5)\n')
3117 
3118  # Some peculiarities of the way things work show up here. dumpPython sorts tasks and
3119  # removes duplication at the level of strings. The Task and Sequence objects themselves
3120  # remove duplicate tasks in their contents if the instances are the same (exact same python
3121  # object id which is not the same as the string representation being the same).
3122  # Also note that the mutating visitor replaces sequences and tasks that have
3123  # modified contents with their modified contents, it does not modify the sequence
3124  # or task itself.
3125  self.assertEqual(process.path21.dumpPython(PrintOptions()), 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.ConditionalTask(process.None, process.mproducer10), cms.ConditionalTask(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), cms.Task(), process.myTask100, process.myTask5)\n')
3126 
3127  process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
3128  self.assertEqual(process.path22.dumpPython(PrintOptions()), 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.ConditionalTask(process.None, process.mproducer10), cms.ConditionalTask(process.messource, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), cms.Task(), process.myTask100, process.myTask5)\n')
3129 
3130  process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
3131  self.assertEqual(process.path23.dumpPython(PrintOptions()), 'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.ConditionalTask(process.None), cms.ConditionalTask(process.mproducer2, process.mproducer8, process.myTask5), cms.Task(), process.myTask100, process.myTask5)\n')
3132 
3133  process = Process("Test")
3134 
3135  process.b = EDProducer("b")
3136  process.b2 = EDProducer("b2")
3137  process.b3 = EDProducer("b3")
3138  process.p = Path(process.b, ConditionalTask(process.b3, process.b2))
3139  p = TestMakePSet()
3140  process.fillProcessDesc(p)
3141  self.assertEqual(p.values["@all_modules"], (True, ['b', 'b2', 'b3']))
3142  self.assertEqual(p.values["@paths"], (True, ['p']))
3143  self.assertEqual(p.values["p"], (True, ['b','#','b2','b3','@']))
3144 
3145 

◆ testConditionalTaskPlaceholder()

def Config.TestModuleCommand.testConditionalTaskPlaceholder (   self)

Definition at line 3955 of file Config.py.

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

3955  def testConditionalTaskPlaceholder(self):
3956  p = Process("test")
3957  p.a = EDProducer("ma")
3958  p.b = EDAnalyzer("mb")
3959  p.t1 = ConditionalTask(ConditionalTaskPlaceholder("c"))
3960  p.t2 = ConditionalTask(p.a, ConditionalTaskPlaceholder("d"), p.t1)
3961  p.t3 = ConditionalTask(ConditionalTaskPlaceholder("e"))
3962  p.path1 = Path(p.b, p.t2, p.t3)
3963  p.t5 = ConditionalTask(p.a, ConditionalTaskPlaceholder("g"), ConditionalTaskPlaceholder("t4"))
3964  p.t4 = ConditionalTask(ConditionalTaskPlaceholder("f"))
3965  p.path2 = Path(p.b, p.t5)
3966  p.schedule = Schedule(p.path1, p.path2)
3967  p.c = EDProducer("mc")
3968  p.d = EDProducer("md")
3969  p.e = EDProducer("me")
3970  p.f = EDProducer("mf")
3971  p.g = EDProducer("mg")
3972  p.h = EDProducer("mh")
3973  p.i = EDProducer("mi")
3974  p.j = EDProducer("mj")
3975  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),
3976 """process.a = cms.EDProducer("ma")
3977 process.c = cms.EDProducer("mc")
3978 process.d = cms.EDProducer("md")
3979 process.e = cms.EDProducer("me")
3980 process.f = cms.EDProducer("mf")
3981 process.g = cms.EDProducer("mg")
3982 process.h = cms.EDProducer("mh")
3983 process.i = cms.EDProducer("mi")
3984 process.j = cms.EDProducer("mj")
3985 process.b = cms.EDAnalyzer("mb")
3986 process.t1 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("c"))
3987 process.t2 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("d"), process.a, process.t1)
3988 process.t3 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("e"))
3989 process.t5 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("g"), cms.ConditionalTaskPlaceholder("t4"), process.a)
3990 process.t4 = cms.ConditionalTask(cms.ConditionalTaskPlaceholder("f"))
3991 process.path1 = cms.Path(process.b, process.t2, process.t3)
3992 process.path2 = cms.Path(process.b, process.t5)
3993 process.schedule = cms.Schedule(*[ process.path1, process.path2 ])""")
3994  p.resolve()
3995  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),
3996 """process.a = cms.EDProducer("ma")
3997 process.c = cms.EDProducer("mc")
3998 process.d = cms.EDProducer("md")
3999 process.e = cms.EDProducer("me")
4000 process.f = cms.EDProducer("mf")
4001 process.g = cms.EDProducer("mg")
4002 process.h = cms.EDProducer("mh")
4003 process.i = cms.EDProducer("mi")
4004 process.j = cms.EDProducer("mj")
4005 process.b = cms.EDAnalyzer("mb")
4006 process.t1 = cms.ConditionalTask(process.c)
4007 process.t2 = cms.ConditionalTask(process.a, process.d, process.t1)
4008 process.t3 = cms.ConditionalTask(process.e)
4009 process.t4 = cms.ConditionalTask(process.f)
4010 process.t5 = cms.ConditionalTask(process.a, process.g, process.t4)
4011 process.path1 = cms.Path(process.b, process.t2, process.t3)
4012 process.path2 = cms.Path(process.b, process.t5)
4013 process.schedule = cms.Schedule(*[ process.path1, process.path2 ])""")
4014 
def _lineDiff(newString, oldString)
Definition: Config.py:2021
def dumpPython(process, name)

◆ testContains()

def Config.TestModuleCommand.testContains (   self)

Definition at line 3252 of file Config.py.

3252  def testContains(self):
3253 
3254  a = EDProducer("a")
3255  b = EDProducer("b")
3256  c = EDProducer("c")
3257  d = EDProducer("d")
3258  e = EDProducer("e")
3259  f = EDProducer("f")
3260  g = EDProducer("g")
3261  h = EDProducer("h")
3262  i = EDProducer("i")
3263  j = EDProducer("j")
3264  k = EDProducer("k")
3265  l = EDProducer("l")
3266  m = EDProducer("m")
3267  n = EDProducer("n")
3268 
3269  seq1 = Sequence(e)
3270  task1 = Task(g)
3271  ctask1 = ConditionalTask(h)
3272  path = Path(a * c * seq1, task1, ctask1)
3273 
3274  self.assertTrue(path.contains(a))
3275  self.assertFalse(path.contains(b))
3276  self.assertTrue(path.contains(c))
3277  self.assertFalse(path.contains(d))
3278  self.assertTrue(path.contains(e))
3279  self.assertFalse(path.contains(f))
3280  self.assertTrue(path.contains(g))
3281  self.assertTrue(path.contains(h))
3282 
3283  endpath = EndPath(h * i)
3284  self.assertFalse(endpath.contains(b))
3285  self.assertTrue(endpath.contains(i))
3286 
3287  seq = Sequence(a * c)
3288  self.assertFalse(seq.contains(b))
3289  self.assertTrue(seq.contains(c))
3290 
3291  task2 = Task(l)
3292  task = Task(j, k, task2)
3293  self.assertFalse(task.contains(b))
3294  self.assertTrue(task.contains(j))
3295  self.assertTrue(task.contains(k))
3296  self.assertTrue(task.contains(l))
3297 
3298  task3 = Task(m)
3299  path2 = Path(n)
3300  sch = Schedule(path, path2, tasks=[task,task3])
3301  self.assertFalse(sch.contains(b))
3302  self.assertTrue(sch.contains(a))
3303  self.assertTrue(sch.contains(c))
3304  self.assertTrue(sch.contains(e))
3305  self.assertTrue(sch.contains(g))
3306  self.assertTrue(sch.contains(n))
3307  self.assertTrue(sch.contains(j))
3308  self.assertTrue(sch.contains(k))
3309  self.assertTrue(sch.contains(l))
3310  self.assertTrue(sch.contains(m))
3311 
3312  ctask2 = ConditionalTask(l, task1)
3313  ctask = ConditionalTask(j, k, ctask2)
3314  self.assertFalse(ctask.contains(b))
3315  self.assertTrue(ctask.contains(j))
3316  self.assertTrue(ctask.contains(k))
3317  self.assertTrue(ctask.contains(l))
3318  self.assertTrue(ctask.contains(g))
3319 
def testContains(self)
Definition: helpers.py:415

◆ testDelete()

def Config.TestModuleCommand.testDelete (   self)

Definition at line 4015 of file Config.py.

References ConfigBuilder.dumpPython().

4015  def testDelete(self):
4016  p = Process("test")
4017  p.a = EDAnalyzer("MyAnalyzer")
4018  p.b = EDAnalyzer("YourAnalyzer")
4019  p.c = EDAnalyzer("OurAnalyzer")
4020  p.d = EDAnalyzer("OurAnalyzer")
4021  p.e = EDAnalyzer("OurAnalyzer")
4022  p.f = EDAnalyzer("OurAnalyzer")
4023  p.g = EDProducer("OurProducer")
4024  p.h = EDProducer("YourProducer")
4025  p.i = SwitchProducerTest(
4026  test1 = EDProducer("OneProducer"),
4027  test2 = EDProducer("TwoProducer")
4028  )
4029  p.t1 = Task(p.g, p.h, p.i)
4030  t2 = Task(p.g, p.h, p.i)
4031  t3 = Task(p.g, p.h)
4032  p.t4 = Task(p.h)
4033  p.ct1 = ConditionalTask(p.g, p.h, p.i)
4034  ct2 = ConditionalTask(p.g, p.h)
4035  ct3 = ConditionalTask(p.g, p.h)
4036  p.ct4 = ConditionalTask(p.h)
4037  p.s = Sequence(p.d+p.e)
4038  p.path1 = Path(p.a+p.f+p.s,t2,ct2)
4039  p.path2 = Path(p.a)
4040  p.path3 = Path(ct3, p.ct4)
4041  p.endpath2 = EndPath(p.b)
4042  p.endpath1 = EndPath(p.b+p.f)
4043  p.schedule = Schedule(p.path2, p.path3, p.endpath2, tasks=[t3, p.t4])
4044  self.assertTrue(hasattr(p, 'f'))
4045  self.assertTrue(hasattr(p, 'g'))
4046  self.assertTrue(hasattr(p, 'i'))
4047  del p.e
4048  del p.f
4049  del p.g
4050  del p.i
4051  self.assertFalse(hasattr(p, 'f'))
4052  self.assertFalse(hasattr(p, 'g'))
4053  self.assertEqual(p.t1.dumpPython(), 'cms.Task(process.h)\n')
4054  self.assertEqual(p.ct1.dumpPython(), 'cms.ConditionalTask(process.h)\n')
4055  self.assertEqual(p.s.dumpPython(), 'cms.Sequence(process.d)\n')
4056  self.assertEqual(p.path1.dumpPython(), 'cms.Path(process.a+process.s, cms.ConditionalTask(process.h), cms.Task(process.h))\n')
4057  self.assertEqual(p.endpath1.dumpPython(), 'cms.EndPath(process.b)\n')
4058  self.assertEqual(p.path3.dumpPython(), 'cms.Path(cms.ConditionalTask(process.h), process.ct4)\n')
4059  del p.s
4060  self.assertEqual(p.path1.dumpPython(), 'cms.Path(process.a+(process.d), cms.ConditionalTask(process.h), cms.Task(process.h))\n')
4061  self.assertEqual(p.schedule_().dumpPython(), 'cms.Schedule(*[ process.path2, process.path3, process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4062  del p.path2
4063  self.assertEqual(p.schedule_().dumpPython(), 'cms.Schedule(*[ process.path3, process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4064  del p.path3
4065  self.assertEqual(p.schedule_().dumpPython(), 'cms.Schedule(*[ process.endpath2 ], tasks=[cms.Task(process.h), process.t4])\n')
4066  del p.endpath2
4067  self.assertEqual(p.schedule_().dumpPython(), 'cms.Schedule(tasks=[cms.Task(process.h), process.t4])\n')
4068  del p.t4
4069  self.assertEqual(p.schedule_().dumpPython(), 'cms.Schedule(tasks=[cms.Task(process.h)])\n')
def dumpPython(process, name)

◆ testExamples()

def Config.TestModuleCommand.testExamples (   self)

Definition at line 3515 of file Config.py.

References Types.untracked.

3515  def testExamples(self):
3516  p = Process("Test")
3517  p.source = Source("PoolSource",fileNames = untracked(string("file:reco.root")))
3518  p.foos = EDProducer("FooProducer")
3519  p.bars = EDProducer("BarProducer", foos=InputTag("foos"))
3520  p.out = OutputModule("PoolOutputModule",fileName=untracked(string("file:foos.root")))
3521  p.bars.foos = 'Foosball'
3522  self.assertEqual(p.bars.foos, InputTag('Foosball'))
3523  p.p = Path(p.foos*p.bars)
3524  p.e = EndPath(p.out)
3525  p.add_(Service("MessageLogger"))
3526 
untracked
Definition: Types.py:34

◆ testFinalPath()

def Config.TestModuleCommand.testFinalPath (   self)

Definition at line 3197 of file Config.py.

References str.

3197  def testFinalPath(self):
3198  p = Process("test")
3199  p.a = OutputModule("MyOutputModule")
3200  p.b = OutputModule("YourOutputModule")
3201  p.c = OutputModule("OurOutputModule")
3202  path = FinalPath(p.a)
3203  path *= p.b
3204  path += p.c
3205  self.assertEqual(str(path),'a+b+c')
3206  path = FinalPath(p.a*p.b+p.c)
3207  self.assertEqual(str(path),'a+b+c')
3208  path = FinalPath(p.a+ p.b*p.c)
3209  self.assertEqual(str(path),'a+b+c')
3210  path = FinalPath(p.a*(p.b+p.c))
3211  self.assertEqual(str(path),'a+b+c')
3212  p.es = ESProducer("AnESProducer")
3213  self.assertRaises(TypeError,FinalPath,p.es)
3214 
3215  t = FinalPath()
3216  self.assertEqual(t.dumpPython(PrintOptions()), 'cms.FinalPath()\n')
3217 
3218  t = FinalPath(p.a)
3219  self.assertEqual(t.dumpPython(PrintOptions()), 'cms.FinalPath(process.a)\n')
3220 
3221  self.assertRaises(TypeError, FinalPath, Task())
3222  self.assertRaises(TypeError, FinalPath, p.a, Task())
3223 
3224  p.prod = EDProducer("prodName")
3225  p.t1 = Task(p.prod)
3226  self.assertRaises(TypeError, FinalPath, p.a, p.t1, Task(), p.t1)
3227 
3228  p.prod = EDProducer("prodName")
3229  p.t1 = ConditionalTask(p.prod)
3230  self.assertRaises(TypeError, FinalPath, p.a, p.t1, ConditionalTask(), p.t1)
3231 
3232  p.t = FinalPath(p.a)
3233  p.a = OutputModule("ReplacedOutputModule")
3234  self.assertEqual(p.t.dumpPython(PrintOptions()), 'cms.FinalPath(process.a)\n')
3235 
#define str(s)

◆ testFreeze()

def Config.TestModuleCommand.testFreeze (   self)

Definition at line 3547 of file Config.py.

3547  def testFreeze(self):
3548  process = Process("Freeze")
3549  m = EDProducer("M", p=PSet(i = int32(1)))
3550  m.p.i = 2
3551  process.m = m
3552  # should be frozen
3553  #self.assertRaises(ValueError, setattr, m.p, 'i', 3)
3554  #self.assertRaises(ValueError, setattr, m, 'p', PSet(i=int32(1)))
3555  #self.assertRaises(ValueError, setattr, m.p, 'j', 1)
3556  #self.assertRaises(ValueError, setattr, m, 'j', 1)
3557  # But OK to change through the process
3558  process.m.p.i = 4
3559  self.assertEqual(process.m.p.i.value(), 4)
3560  process.m.p = PSet(j=int32(1))
3561  # should work to clone it, though
3562  m2 = m.clone(p = PSet(i = int32(5)), j = int32(8))
3563  m2.p.i = 6
3564  m2.j = 8

◆ testGlobalReplace()

def Config.TestModuleCommand.testGlobalReplace (   self)

Definition at line 2652 of file Config.py.

2652  def testGlobalReplace(self):
2653  p = Process('test')
2654  p.a = EDAnalyzer("MyAnalyzer")
2655  old = p.a
2656  p.b = EDAnalyzer("YourAnalyzer")
2657  p.c = EDAnalyzer("OurAnalyzer")
2658  p.d = EDProducer("MyProducer")
2659  old2 = p.d
2660  p.t1 = Task(p.d)
2661  t2 = Task(p.d)
2662  t3 = Task(p.d)
2663  t4 = Task(p.d)
2664  t5 = Task(p.d)
2665  t6 = Task(p.d)
2666  p.ct1 = ConditionalTask(p.d)
2667  s = Sequence(p.a*p.b)
2668  p.s4 = Sequence(p.a*p.b, p.ct1)
2669  s.associate(t2)
2670  p.s4.associate(t2)
2671  p.p = Path(p.c+s+p.a)
2672  p.p2 = Path(p.c+p.s4+p.a, p.ct1)
2673  p.e3 = EndPath(p.c+s+p.a)
2674  new = EDAnalyzer("NewAnalyzer")
2675  new2 = EDProducer("NewProducer")
2676  visitor1 = NodeVisitor()
2677  p.p.visit(visitor1)
2678  self.assertTrue(visitor1.modules == set([old,old2,p.b,p.c]))
2679  p.schedule = Schedule(tasks=[t6])
2680  p.globalReplace("a",new)
2681  p.globalReplace("d",new2)
2682  visitor2 = NodeVisitor()
2683  p.p.visit(visitor2)
2684  self.assertTrue(visitor2.modules == set([new,new2,p.b,p.c]))
2685  self.assertEqual(p.p.dumpPython()[:-1], "cms.Path(process.c+process.a+process.b+process.a, cms.Task(process.d))")
2686  visitor_p2 = NodeVisitor()
2687  p.p2.visit(visitor_p2)
2688  self.assertTrue(visitor_p2.modules == set([new,new2,p.b,p.c]))
2689  self.assertEqual(p.p2.dumpPython()[:-1], "cms.Path(process.c+process.s4+process.a, process.ct1)")
2690  visitor3 = NodeVisitor()
2691  p.e3.visit(visitor3)
2692  self.assertTrue(visitor3.modules == set([new,new2,p.b,p.c]))
2693  visitor4 = NodeVisitor()
2694  p.s4.visit(visitor4)
2695  self.assertTrue(visitor4.modules == set([new,new2,p.b]))
2696  self.assertEqual(p.s4.dumpPython()[:-1],"cms.Sequence(process.a+process.b, cms.Task(process.d), process.ct1)")
2697  visitor5 = NodeVisitor()
2698  p.t1.visit(visitor5)
2699  self.assertTrue(visitor5.modules == set([new2]))
2700  visitor6 = NodeVisitor()
2701  listOfTasks = list(p.schedule._tasks)
2702  listOfTasks[0].visit(visitor6)
2703  self.assertTrue(visitor6.modules == set([new2]))
2704  visitor7 = NodeVisitor()
2705  p.ct1.visit(visitor7)
2706  self.assertTrue(visitor7.modules == set([new2]))
2707  visitor8 = NodeVisitor()
2708  listOfConditionalTasks = list(p.conditionaltasks.values())
2709  listOfConditionalTasks[0].visit(visitor8)
2710  self.assertTrue(visitor8.modules == set([new2]))
2711 
2712 
2713  p.d2 = EDProducer("YourProducer")
2714  p.schedule = Schedule(p.p, p.p2, p.e3, tasks=[p.t1])
2715  self.assertEqual(p.schedule.dumpPython()[:-1], "cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2716  p.p = Path(p.c+s)
2717  self.assertEqual(p.schedule.dumpPython()[:-1], "cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2718  p.e3 = EndPath(p.c)
2719  self.assertEqual(p.schedule.dumpPython()[:-1], "cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2720  p.t1 = Task(p.d2)
2721  self.assertEqual(p.schedule.dumpPython()[:-1], "cms.Schedule(*[ process.p, process.p2, process.e3 ], tasks=[process.t1])")
2722 

◆ testImplicitSchedule()

def Config.TestModuleCommand.testImplicitSchedule (   self)

Definition at line 3425 of file Config.py.

3425  def testImplicitSchedule(self):
3426  p = Process("test")
3427  p.a = EDAnalyzer("MyAnalyzer")
3428  p.b = EDAnalyzer("YourAnalyzer")
3429  p.c = EDAnalyzer("OurAnalyzer")
3430  p.path1 = Path(p.a)
3431  p.path2 = Path(p.b)
3432  self.assertTrue(p.schedule is None)
3433  pths = p.paths
3434  keys = pths.keys()
3435  self.assertEqual(pths[keys[0]],p.path1)
3436  self.assertEqual(pths[keys[1]],p.path2)
3437  p.prune()
3438  self.assertTrue(hasattr(p, 'a'))
3439  self.assertTrue(hasattr(p, 'b'))
3440  self.assertTrue(not hasattr(p, 'c'))
3441  self.assertTrue(hasattr(p, 'path1'))
3442  self.assertTrue(hasattr(p, 'path2'))
3443 
3444 
3445  p = Process("test")
3446  p.a = EDAnalyzer("MyAnalyzer")
3447  p.b = EDAnalyzer("YourAnalyzer")
3448  p.c = EDAnalyzer("OurAnalyzer")
3449  p.path2 = Path(p.b)
3450  p.path1 = Path(p.a)
3451  self.assertTrue(p.schedule is None)
3452  pths = p.paths
3453  keys = pths.keys()
3454  self.assertEqual(pths[keys[1]],p.path1)
3455  self.assertEqual(pths[keys[0]],p.path2)
3456 
3457 

◆ testMaxEvents()

def Config.TestModuleCommand.testMaxEvents (   self)

Definition at line 3500 of file Config.py.

3500  def testMaxEvents(self):
3501  p = Process("Test")
3502  p.maxEvents.input = 10
3503  self.assertEqual(p.maxEvents.input.value(),10)
3504  p = Process("Test")
3505  p.maxEvents.output = 10
3506  self.assertEqual(p.maxEvents.output.value(),10)
3507  p = Process("Test")
3508  p.maxEvents.output = PSet(out=untracked.int32(10))
3509  self.assertEqual(p.maxEvents.output.out.value(), 10)
3510  p = Process("Test")
3511  p.maxEvents = untracked.PSet(input = untracked.int32(5))
3512  self.assertEqual(p.maxEvents.input.value(), 5)
3513 
3514 

◆ testModifier()

def Config.TestModuleCommand.testModifier (   self)

Definition at line 4070 of file Config.py.

References submitPVValidationJobs.__init__(), and resolutioncreator_cfi.object.

4070  def testModifier(self):
4071  m1 = Modifier()
4072  Process._firstProcess = True
4073  p = Process("test")
4074  self.assertRaises(RuntimeError, lambda: Process("test2", m1))
4075  m1 = Modifier()
4076  Process._firstProcess = True
4077  p = Process("test",m1)
4078  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
4079  def _mod_fred(obj):
4080  obj.fred = 2
4081  m1.toModify(p.a,_mod_fred)
4082  self.assertEqual(p.a.fred.value(),2)
4083  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
4084  m1.toModify(p.b, wilma = 2)
4085  self.assertEqual(p.b.wilma.value(),2)
4086  self.assertTrue(p.isUsingModifier(m1))
4087  #check that Modifier not attached to a process doesn't run
4088  m1 = Modifier()
4089  Process._firstProcess = True
4090  p = Process("test")
4091  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
4092  m1.toModify(p.a,_mod_fred)
4093  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
4094  m1.toModify(p.b, wilma = 2)
4095  self.assertEqual(p.a.fred.value(),1)
4096  self.assertEqual(p.b.wilma.value(),1)
4097  self.assertEqual(p.isUsingModifier(m1),False)
4098  #make sure clones get the changes
4099  m1 = Modifier()
4100  Process._firstProcess = True
4101  p = Process("test",m1)
4102  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
4103  m1.toModify(p.a, fred = int32(2))
4104  p.b = p.a.clone(wilma = int32(3))
4105  self.assertEqual(p.a.fred.value(),2)
4106  self.assertEqual(p.a.wilma.value(),1)
4107  self.assertEqual(p.b.fred.value(),2)
4108  self.assertEqual(p.b.wilma.value(),3)
4109  #test removal of parameter
4110  m1 = Modifier()
4111  Process._firstProcess = True
4112  p = Process("test",m1)
4113  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1), fintstones = PSet(fred = int32(1)))
4114  m1.toModify(p.a, fred = None, fintstones = dict(fred = None))
4115  self.assertEqual(hasattr(p.a, "fred"), False)
4116  self.assertEqual(hasattr(p.a.fintstones, "fred"), False)
4117  self.assertEqual(p.a.wilma.value(),1)
4118  #test adding a parameter
4119  m1 = Modifier()
4120  Process._firstProcess = True
4121  p = Process("test",m1)
4122  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
4123  m1.toModify(p.a, wilma = int32(2))
4124  self.assertEqual(p.a.fred.value(), 1)
4125  self.assertEqual(p.a.wilma.value(),2)
4126  #test setting of value in PSet
4127  m1 = Modifier()
4128  Process._firstProcess = True
4129  p = Process("test",m1)
4130  p.a = EDAnalyzer("MyAnalyzer", flintstones = PSet(fred = int32(1), wilma = int32(1)))
4131  m1.toModify(p.a, flintstones = dict(fred = int32(2)))
4132  self.assertEqual(p.a.flintstones.fred.value(),2)
4133  self.assertEqual(p.a.flintstones.wilma.value(),1)
4134  #test proper exception from nonexisting parameter name
4135  m1 = Modifier()
4136  Process._firstProcess = True
4137  p = Process("test",m1)
4138  p.a = EDAnalyzer("MyAnalyzer", flintstones = PSet(fred = PSet(wilma = int32(1))))
4139  self.assertRaises(KeyError, lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4140  self.assertRaises(KeyError, lambda: m1.toModify(p.a, foo = 1))
4141  #test setting a value in a VPSet
4142  m1 = Modifier()
4143  Process._firstProcess = True
4144  p = Process("test",m1)
4145  p.a = EDAnalyzer("MyAnalyzer", flintstones = VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
4146  m1.toModify(p.a, flintstones = {1:dict(wilma = int32(2))})
4147  self.assertEqual(p.a.flintstones[0].fred.value(),1)
4148  self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4149  #test setting a value in a list of values
4150  m1 = Modifier()
4151  Process._firstProcess = True
4152  p = Process("test",m1)
4153  p.a = EDAnalyzer("MyAnalyzer", fred = vuint32(1,2,3))
4154  m1.toModify(p.a, fred = {1:7})
4155  self.assertEqual(p.a.fred[0],1)
4156  self.assertEqual(p.a.fred[1],7)
4157  self.assertEqual(p.a.fred[2],3)
4158  #test IndexError setting a value in a list to an item key not in the list
4159  m1 = Modifier()
4160  Process._firstProcess = True
4161  p = Process("test",m1)
4162  p.a = EDAnalyzer("MyAnalyzer", fred = vuint32(1,2,3))
4163  raised = False
4164  try: m1.toModify(p.a, fred = {5:7})
4165  except IndexError as e: raised = True
4166  self.assertEqual(raised, True)
4167  #test TypeError setting a value in a list using a key that is not an int
4168  m1 = Modifier()
4169  Process._firstProcess = True
4170  p = Process("test",m1)
4171  p.a = EDAnalyzer("MyAnalyzer", flintstones = VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
4172  raised = False
4173  try: m1.toModify(p.a, flintstones = dict(bogus = int32(37)))
4174  except TypeError as e: raised = True
4175  self.assertEqual(raised, True)
4176  #test that load causes process wide methods to run
4177  def _rem_a(proc):
4178  del proc.a
4179  class ProcModifierMod(object):
4180  def __init__(self,modifier,func):
4181  self.proc_mod_ = modifier.makeProcessModifier(func)
4182  class DummyMod(object):
4183  def __init__(self):
4184  self.a = EDAnalyzer("Dummy")
4185  testMod = DummyMod()
4186  p.extend(testMod)
4187  self.assertTrue(hasattr(p,"a"))
4188  m1 = Modifier()
4189  Process._firstProcess = True
4190  p = Process("test",m1)
4191  testProcMod = ProcModifierMod(m1,_rem_a)
4192  p.extend(testMod)
4193  p.extend(testProcMod)
4194  self.assertTrue(not hasattr(p,"a"))
4195  #test ModifierChain
4196  m1 = Modifier()
4197  mc = ModifierChain(m1)
4198  Process._firstProcess = True
4199  p = Process("test",mc)
4200  self.assertTrue(p.isUsingModifier(m1))
4201  self.assertTrue(p.isUsingModifier(mc))
4202  testMod = DummyMod()
4203  p.b = EDAnalyzer("Dummy2", fred = int32(1))
4204  m1.toModify(p.b, fred = int32(3))
4205  p.extend(testMod)
4206  testProcMod = ProcModifierMod(m1,_rem_a)
4207  p.extend(testProcMod)
4208  self.assertTrue(not hasattr(p,"a"))
4209  self.assertEqual(p.b.fred.value(),3)
4210  #check cloneAndExclude
4211  m1 = Modifier()
4212  m2 = Modifier()
4213  mc = ModifierChain(m1,m2)
4214  mclone = mc.copyAndExclude([m2])
4215  self.assertTrue(not mclone._isOrContains(m2))
4216  self.assertTrue(mclone._isOrContains(m1))
4217  m3 = Modifier()
4218  mc2 = ModifierChain(mc,m3)
4219  mclone = mc2.copyAndExclude([m2])
4220  self.assertTrue(not mclone._isOrContains(m2))
4221  self.assertTrue(mclone._isOrContains(m1))
4222  self.assertTrue(mclone._isOrContains(m3))
4223  #check combining
4224  m1 = Modifier()
4225  m2 = Modifier()
4226  Process._firstProcess = True
4227  p = Process("test",m1)
4228  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
4229  (m1 & m2).toModify(p.a, fred = int32(2))
4230  self.assertRaises(TypeError, lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4231  self.assertEqual(p.a.fred, 1)
4232  m1 = Modifier()
4233  m2 = Modifier()
4234  Process._firstProcess = True
4235  p = Process("test",m1,m2)
4236  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
4237  (m1 & m2).toModify(p.a, fred = int32(2))
4238  self.assertEqual(p.a.fred, 2)
4239  m1 = Modifier()
4240  m2 = Modifier()
4241  m3 = Modifier()
4242  Process._firstProcess = True
4243  p = Process("test",m1,m2,m3)
4244  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
4245  (m1 & m2 & m3).toModify(p.a, fred = int32(2))
4246  self.assertEqual(p.a.fred, 2)
4247  (m1 & (m2 & m3)).toModify(p.a, fred = int32(3))
4248  self.assertEqual(p.a.fred, 3)
4249  ((m1 & m2) & m3).toModify(p.a, fred = int32(4))
4250  self.assertEqual(p.a.fred, 4)
4251  #check inverse
4252  m1 = Modifier()
4253  m2 = Modifier()
4254  Process._firstProcess = True
4255  p = Process("test", m1)
4256  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
4257  (~m1).toModify(p.a, fred=2)
4258  self.assertEqual(p.a.fred, 1)
4259  (~m2).toModify(p.a, wilma=2)
4260  self.assertEqual(p.a.wilma, 2)
4261  self.assertRaises(TypeError, lambda: (~m1).toModify(p.a, 1, wilma=2))
4262  self.assertRaises(TypeError, lambda: (~m2).toModify(p.a, 1, wilma=2))
4263  # check or
4264  m1 = Modifier()
4265  m2 = Modifier()
4266  m3 = Modifier()
4267  Process._firstProcess = True
4268  p = Process("test", m1)
4269  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
4270  (m1 | m2).toModify(p.a, fred=2)
4271  self.assertEqual(p.a.fred, 2)
4272  (m1 | m2 | m3).toModify(p.a, fred=3)
4273  self.assertEqual(p.a.fred, 3)
4274  (m3 | m2 | m1).toModify(p.a, fred=4)
4275  self.assertEqual(p.a.fred, 4)
4276  ((m1 | m2) | m3).toModify(p.a, fred=5)
4277  self.assertEqual(p.a.fred, 5)
4278  (m1 | (m2 | m3)).toModify(p.a, fred=6)
4279  self.assertEqual(p.a.fred, 6)
4280  (m2 | m3).toModify(p.a, fred=7)
4281  self.assertEqual(p.a.fred, 6)
4282  self.assertRaises(TypeError, lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4283  self.assertRaises(TypeError, lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4284  # check combinations
4285  m1 = Modifier()
4286  m2 = Modifier()
4287  m3 = Modifier()
4288  m4 = Modifier()
4289  Process._firstProcess = True
4290  p = Process("test", m1, m2)
4291  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
4292  (m1 & ~m2).toModify(p.a, fred=2)
4293  self.assertEqual(p.a.fred, 1)
4294  (m1 & ~m3).toModify(p.a, fred=2)
4295  self.assertEqual(p.a.fred, 2)
4296  (m1 | ~m2).toModify(p.a, fred=3)
4297  self.assertEqual(p.a.fred, 3)
4298  (~m1 | ~m2).toModify(p.a, fred=4)
4299  self.assertEqual(p.a.fred, 3)
4300  (~m3 & ~m4).toModify(p.a, fred=4)
4301  self.assertEqual(p.a.fred, 4)
4302  ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4303  self.assertEqual(p.a.fred, 5)
4304  #check toReplaceWith
4305  m1 = Modifier()
4306  Process._firstProcess = True
4307  p = Process("test",m1)
4308  p.a =EDAnalyzer("MyAnalyzer", fred = int32(1))
4309  m1.toReplaceWith(p.a, EDAnalyzer("YourAnalyzer", wilma = int32(3)))
4310  self.assertRaises(TypeError, lambda: m1.toReplaceWith(p.a, EDProducer("YourProducer")))
4311  #Task
4312  p.b =EDAnalyzer("BAn")
4313  p.c =EDProducer("c")
4314  p.d =EDProducer("d")
4315  p.tc = Task(p.c)
4316  p.td = Task(p.d)
4317  p.s = Sequence(p.a, p.tc)
4318  m1.toReplaceWith(p.s, Sequence(p.a+p.b, p.td))
4319  self.assertEqual(p.a.wilma.value(),3)
4320  self.assertEqual(p.a.type_(),"YourAnalyzer")
4321  self.assertEqual(hasattr(p,"fred"),False)
4322  self.assertTrue(p.s.dumpPython() == "cms.Sequence(process.a+process.b, process.td)\n")
4323  p.e =EDProducer("e")
4324  m1.toReplaceWith(p.td, Task(p.e))
4325  self.assertTrue(p.td._collection == OrderedSet([p.e]))
4326  #ConditionalTask
4327  p.b =EDAnalyzer("BAn")
4328  p.c =EDProducer("c")
4329  p.d =EDProducer("d")
4330  del p.tc
4331  del p.td
4332  p.tc = ConditionalTask(p.c)
4333  p.td = ConditionalTask(p.d)
4334  p.s = Sequence(p.a, p.tc)
4335  m1.toReplaceWith(p.s, Sequence(p.a+p.b, p.td))
4336  self.assertEqual(p.a.wilma.value(),3)
4337  self.assertEqual(p.a.type_(),"YourAnalyzer")
4338  self.assertEqual(hasattr(p,"fred"),False)
4339  self.assertTrue(p.s.dumpPython() == "cms.Sequence(process.a+process.b, process.td)\n")
4340  p.e =EDProducer("e")
4341  m1.toReplaceWith(p.td, ConditionalTask(p.e))
4342  self.assertTrue(p.td._collection == OrderedSet([p.e]))
4343  #check toReplaceWith doesn't activate not chosen
4344  m1 = Modifier()
4345  Process._firstProcess = True
4346  p = Process("test")
4347  p.a =EDAnalyzer("MyAnalyzer", fred = int32(1))
4348  m1.toReplaceWith(p.a, EDAnalyzer("YourAnalyzer", wilma = int32(3)))
4349  self.assertEqual(p.a.type_(),"MyAnalyzer")
4350  #check toReplaceWith and and/not/or combinations
4351  m1 = Modifier()
4352  m2 = Modifier()
4353  m3 = Modifier()
4354  m4 = Modifier()
4355  Process._firstProcess = True
4356  p = Process("test", m1, m2)
4357  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
4358  self.assertRaises(TypeError, lambda: (m1 & m2).toReplaceWith(p.a, EDProducer("YourProducer")))
4359  self.assertRaises(TypeError, lambda: (m3 & m4).toReplaceWith(p.a, EDProducer("YourProducer")))
4360  self.assertRaises(TypeError, lambda: (~m3).toReplaceWith(p.a, EDProducer("YourProducer")))
4361  self.assertRaises(TypeError, lambda: (~m1).toReplaceWith(p.a, EDProducer("YourProducer")))
4362  self.assertRaises(TypeError, lambda: (m1 | m3).toReplaceWith(p.a, EDProducer("YourProducer")))
4363  self.assertRaises(TypeError, lambda: (m3 | m4).toReplaceWith(p.a, EDProducer("YourProducer")))
4364  (m1 & m2).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer1"))
4365  self.assertEqual(p.a.type_(), "YourAnalyzer1")
4366  (m1 & m3).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer2"))
4367  self.assertEqual(p.a.type_(), "YourAnalyzer1")
4368  (~m1).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer2"))
4369  self.assertEqual(p.a.type_(), "YourAnalyzer1")
4370  (~m3).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer2"))
4371  self.assertEqual(p.a.type_(), "YourAnalyzer2")
4372  (m1 | m3).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer3"))
4373  self.assertEqual(p.a.type_(), "YourAnalyzer3")
4374  (m3 | m4).toReplaceWith(p.a, EDAnalyzer("YourAnalyzer4"))
4375  self.assertEqual(p.a.type_(), "YourAnalyzer3")
4376 
4377  # EDAlias
4378  a = EDAlias(foo2 = VPSet(PSet(type = string("Foo2"))))
4379  m = Modifier()
4380  m._setChosen()
4381  # Modify parameters
4382  m.toModify(a, foo2 = {0: dict(type = "Foo3")})
4383  self.assertEqual(a.foo2[0].type, "Foo3")
4384  # Add an alias
4385  m.toModify(a, foo4 = VPSet(PSet(type = string("Foo4"))))
4386  self.assertEqual(a.foo2[0].type, "Foo3")
4387  self.assertEqual(a.foo4[0].type, "Foo4")
4388  # Remove an alias
4389  m.toModify(a, foo2 = None)
4390  self.assertFalse(hasattr(a, "foo2"))
4391  self.assertEqual(a.foo4[0].type, "Foo4")
4392  # Replace (doesn't work out of the box because EDAlias is not _Parameterizable
4393  m.toReplaceWith(a, EDAlias(bar = VPSet(PSet(type = string("Bar")))))
4394  self.assertFalse(hasattr(a, "foo2"))
4395  self.assertFalse(hasattr(a, "foo4"))
4396  self.assertTrue(hasattr(a, "bar"))
4397  self.assertEqual(a.bar[0].type, "Bar")
4398 
4399  # SwitchProducer
4400  sp = SwitchProducerTest(test1 = EDProducer("Foo",
4401  a = int32(1),
4402  b = PSet(c = int32(2))),
4403  test2 = EDProducer("Bar",
4404  aa = int32(11),
4405  bb = PSet(cc = int32(12))))
4406  m = Modifier()
4407  m._setChosen()
4408  # Modify parameters
4409  m.toModify(sp,
4410  test1 = dict(a = 4, b = dict(c = None)),
4411  test2 = dict(aa = 15, bb = dict(cc = 45, dd = string("foo"))))
4412  self.assertEqual(sp.test1.a.value(), 4)
4413  self.assertEqual(sp.test1.b.hasParameter("c"), False)
4414  self.assertEqual(sp.test2.aa.value(), 15)
4415  self.assertEqual(sp.test2.bb.cc.value(), 45)
4416  self.assertEqual(sp.test2.bb.dd.value(), "foo")
4417  # Replace a producer
4418  m.toReplaceWith(sp.test1, EDProducer("Fred", x = int32(42)))
4419  self.assertEqual(sp.test1.type_(), "Fred")
4420  self.assertEqual(sp.test1.x.value(), 42)
4421  self.assertRaises(TypeError, lambda: m.toReplaceWith(sp.test1, EDAnalyzer("Foo")))
4422  # Alternative way (only to be allow same syntax to be used as for adding)
4423  m.toModify(sp, test2 = EDProducer("Xyzzy", x = int32(24)))
4424  self.assertEqual(sp.test2.type_(), "Xyzzy")
4425  self.assertEqual(sp.test2.x.value(), 24)
4426  self.assertRaises(TypeError, lambda: m.toModify(sp, test2 = EDAnalyzer("Foo")))
4427  # Add a producer
4428  m.toModify(sp, test3 = EDProducer("Wilma", y = int32(24)))
4429  self.assertEqual(sp.test3.type_(), "Wilma")
4430  self.assertEqual(sp.test3.y.value(), 24)
4431  self.assertRaises(TypeError, lambda: m.toModify(sp, test4 = EDAnalyzer("Foo")))
4432  # Remove a producer
4433  m.toModify(sp, test2 = None)
4434  self.assertEqual(hasattr(sp, "test2"), False)
4435  # Add an alias
4436  m.toModify(sp, test2 = EDAlias(foo = VPSet(PSet(type = string("int")))))
4437  self.assertTrue(hasattr(sp.test2, "foo"))
4438  # Replace an alias
4439  m.toReplaceWith(sp.test2, EDAlias(bar = VPSet(PSet(type = string("int")))))
4440  self.assertTrue(hasattr(sp.test2, "bar"))
4441  # Alternative way
4442  m.toModify(sp, test2 = EDAlias(xyzzy = VPSet(PSet(type = string("int")))))
4443  self.assertTrue(hasattr(sp.test2, "xyzzy"))
4444  # Replace an alias with EDProducer
4445  self.assertRaises(TypeError, lambda: m.toReplaceWith(sp.test2, EDProducer("Foo")))
4446  m.toModify(sp, test2 = EDProducer("Foo"))
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

◆ testOptions()

def Config.TestModuleCommand.testOptions (   self)

Definition at line 3488 of file Config.py.

3488  def testOptions(self):
3489  p = Process('test')
3490  self.assertEqual(p.options.numberOfThreads.value(),1)
3491  p.options.numberOfThreads = 8
3492  self.assertEqual(p.options.numberOfThreads.value(),8)
3493  p.options = PSet()
3494  self.assertEqual(p.options.numberOfThreads.value(),1)
3495  p.options = dict(numberOfStreams =2,
3496  numberOfThreads =2)
3497  self.assertEqual(p.options.numberOfThreads.value(),2)
3498  self.assertEqual(p.options.numberOfStreams.value(),2)
3499 

◆ testOverride()

def Config.TestModuleCommand.testOverride (   self)

Definition at line 3465 of file Config.py.

3465  def testOverride(self):
3466  p = Process('test')
3467  a = EDProducer("A", a1=int32(0))
3468  self.assertTrue(not a.isModified())
3469  a.a1 = 1
3470  self.assertTrue(a.isModified())
3471  p.a = a
3472  self.assertEqual(p.a.a1.value(), 1)
3473  # try adding an unmodified module.
3474  # should accept it
3475  p.a = EDProducer("A", a1=int32(2))
3476  self.assertEqual(p.a.a1.value(), 2)
3477  # try adding a modified module. Should throw
3478  # no longer, since the same (modified) say, geometry
3479  # could come from more than one cff
3480  b = EDProducer("A", a1=int32(3))
3481  b.a1 = 4
3482  #self.assertRaises(RuntimeError, setattr, *(p,'a',b))
3483  ps1 = PSet(a = int32(1))
3484  ps2 = PSet(a = int32(2))
3485  self.assertRaises(ValueError, EDProducer, 'C', ps1, ps2)
3486  self.assertRaises(ValueError, EDProducer, 'C', ps1, a=int32(3))
3487 

◆ testParameterizable()

def Config.TestModuleCommand.testParameterizable (   self)

Definition at line 2175 of file Config.py.

2175  def testParameterizable(self):
2176  p = _Parameterizable()
2177  self.assertEqual(len(p.parameterNames_()),0)
2178  p.a = int32(1)
2179  self.assertTrue('a' in p.parameterNames_())
2180  self.assertEqual(p.a.value(), 1)
2181  p.a = 10
2182  self.assertEqual(p.a.value(), 10)
2183  p.a = untracked(int32(1))
2184  self.assertEqual(p.a.value(), 1)
2185  self.assertFalse(p.a.isTracked())
2186  p.a = untracked.int32(1)
2187  self.assertEqual(p.a.value(), 1)
2188  self.assertFalse(p.a.isTracked())
2189  p = _Parameterizable(foo=int32(10), bar = untracked(double(1.0)))
2190  self.assertEqual(p.foo.value(), 10)
2191  self.assertEqual(p.bar.value(),1.0)
2192  self.assertFalse(p.bar.isTracked())
2193  self.assertRaises(TypeError,setattr,(p,'c',1))
2194  p = _Parameterizable(a=PSet(foo=int32(10), bar = untracked(double(1.0))))
2195  self.assertEqual(p.a.foo.value(),10)
2196  self.assertEqual(p.a.bar.value(),1.0)
2197  p.b = untracked(PSet(fii = int32(1)))
2198  self.assertEqual(p.b.fii.value(),1)
2199  self.assertFalse(p.b.isTracked())
2200  #test the fact that values can be shared
2201  v = int32(10)
2202  p=_Parameterizable(a=v)
2203  v.setValue(11)
2204  self.assertEqual(p.a.value(),11)
2205  p.a = 12
2206  self.assertEqual(p.a.value(),12)
2207  self.assertEqual(v.value(),12)
untracked
Definition: Types.py:34

◆ testPath()

def Config.TestModuleCommand.testPath (   self)

Definition at line 3146 of file Config.py.

References SequenceTypes.ignore(), and str.

3146  def testPath(self):
3147  p = Process("test")
3148  p.a = EDAnalyzer("MyAnalyzer")
3149  p.b = EDAnalyzer("YourAnalyzer")
3150  p.c = EDAnalyzer("OurAnalyzer")
3151  path = Path(p.a)
3152  path *= p.b
3153  path += p.c
3154  self.assertEqual(str(path),'a+b+c')
3155  path = Path(p.a*p.b+p.c)
3156  self.assertEqual(str(path),'a+b+c')
3157 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences
3158 # self.assertEqual(str(path),'((a*b)+c)')
3159  path = Path(p.a+ p.b*p.c)
3160  self.assertEqual(str(path),'a+b+c')
3161  path = Path(p.a*(p.b+p.c))
3162  self.assertEqual(str(path),'a+b+c')
3163  path = Path(p.a*(p.b+~p.c))
3164  pathx = Path(p.a*(p.b+ignore(p.c)))
3165  self.assertEqual(str(path),'a+b+~c')
3166  p.es = ESProducer("AnESProducer")
3167  self.assertRaises(TypeError,Path,p.es)
3168 
3169  t = Path()
3170  self.assertEqual(t.dumpPython(PrintOptions()), 'cms.Path()\n')
3171 
3172  t = Path(p.a)
3173  self.assertEqual(t.dumpPython(PrintOptions()), 'cms.Path(process.a)\n')
3174 
3175  t = Path(Task())
3176  self.assertEqual(t.dumpPython(PrintOptions()), 'cms.Path(cms.Task())\n')
3177 
3178  t = Path(p.a, Task())
3179  self.assertEqual(t.dumpPython(PrintOptions()), 'cms.Path(process.a, cms.Task())\n')
3180 
3181  p.prod = EDProducer("prodName")
3182  p.t1 = Task(p.prod)
3183  t = Path(p.a, p.t1, Task(), p.t1)
3184  self.assertEqual(t.dumpPython(PrintOptions()), 'cms.Path(process.a, cms.Task(), process.t1)\n')
3185 
3186  t = Path(ConditionalTask())
3187  self.assertEqual(t.dumpPython(PrintOptions()), 'cms.Path(cms.ConditionalTask())\n')
3188 
3189  t = Path(p.a, ConditionalTask())
3190  self.assertEqual(t.dumpPython(PrintOptions()), 'cms.Path(process.a, cms.ConditionalTask())\n')
3191 
3192  p.prod = EDProducer("prodName")
3193  p.t1 = ConditionalTask(p.prod)
3194  t = Path(p.a, p.t1, Task(), p.t1)
3195  self.assertEqual(t.dumpPython(PrintOptions()), 'cms.Path(process.a, cms.Task(), process.t1)\n')
3196 
def ignore(seq)
#define str(s)

◆ testPrefers()

def Config.TestModuleCommand.testPrefers (   self)

Definition at line 3527 of file Config.py.

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

3527  def testPrefers(self):
3528  p = Process("Test")
3529  p.add_(ESSource("ForceSource"))
3530  p.juicer = ESProducer("JuicerProducer")
3531  p.prefer("ForceSource")
3532  p.prefer("juicer")
3533  self.assertEqual(_lineDiff(p.dumpPython(), Process('Test').dumpPython()),
3534 """process.juicer = cms.ESProducer("JuicerProducer")
3535 process.ForceSource = cms.ESSource("ForceSource")
3536 process.prefer("ForceSource")
3537 process.prefer("juicer")""")
3538  p.prefer("juicer",fooRcd=vstring("Foo"))
3539  self.assertEqual(_lineDiff(p.dumpPython(), Process('Test').dumpPython()),
3540 """process.juicer = cms.ESProducer("JuicerProducer")
3541 process.ForceSource = cms.ESSource("ForceSource")
3542 process.prefer("ForceSource")
3543 process.prefer("juicer",
3544  fooRcd = cms.vstring('Foo')
3545 )""")
3546 
def _lineDiff(newString, oldString)
Definition: Config.py:2021
def dumpPython(process, name)

◆ testProcessAccelerator()

def Config.TestModuleCommand.testProcessAccelerator (   self)

Definition at line 4478 of file Config.py.

4478  def testProcessAccelerator(self):
4479  proc = Process("TEST")
4480  p = TestMakePSet()
4481  proc.fillProcessDesc(p)
4482  self.assertTrue(["cpu"], p.values["@available_accelerators"][1])
4483  self.assertFalse(p.values["@selected_accelerators"][0])
4484  self.assertTrue(["cpu"], p.values["@selected_accelerators"][1])
4485 
4486  proc = Process("TEST")
4487  self.assertRaises(TypeError, setattr, proc, "processAcceleratorTest", ProcessAcceleratorTest())
4488  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4489  del proc.MessageLogger # remove boilerplate unnecessary for this test case
4490  self.assertEqual(proc.dumpPython(),
4491 """import FWCore.ParameterSet.Config as cms
4492 from test import ProcessAcceleratorTest
4493 
4494 process = cms.Process("TEST")
4495 
4496 process.maxEvents = cms.untracked.PSet(
4497  input = cms.optional.untracked.int32,
4498  output = cms.optional.untracked.allowed(cms.int32,cms.PSet)
4499 )
4500 
4501 process.maxLuminosityBlocks = cms.untracked.PSet(
4502  input = cms.untracked.int32(-1)
4503 )
4504 
4505 process.options = cms.untracked.PSet(
4506  FailPath = cms.untracked.vstring(),
4507  IgnoreCompletely = cms.untracked.vstring(),
4508  Rethrow = cms.untracked.vstring(),
4509  SkipEvent = cms.untracked.vstring(),
4510  accelerators = cms.untracked.vstring('*'),
4511  allowUnscheduled = cms.obsolete.untracked.bool,
4512  canDeleteEarly = cms.untracked.vstring(),
4513  deleteNonConsumedUnscheduledModules = cms.untracked.bool(True),
4514  dumpOptions = cms.untracked.bool(False),
4515  emptyRunLumiMode = cms.obsolete.untracked.string,
4516  eventSetup = cms.untracked.PSet(
4517  forceNumberOfConcurrentIOVs = cms.untracked.PSet(
4518  allowAnyLabel_=cms.required.untracked.uint32
4519  ),
4520  numberOfConcurrentIOVs = cms.untracked.uint32(0)
4521  ),
4522  fileMode = cms.untracked.string('FULLMERGE'),
4523  forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
4524  makeTriggerResults = cms.obsolete.untracked.bool,
4525  numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0),
4526  numberOfConcurrentRuns = cms.untracked.uint32(1),
4527  numberOfStreams = cms.untracked.uint32(0),
4528  numberOfThreads = cms.untracked.uint32(1),
4529  printDependencies = cms.untracked.bool(False),
4530  sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
4531  throwIfIllegalParameter = cms.untracked.bool(True),
4532  wantSummary = cms.untracked.bool(False)
4533 )
4534 
4535 process.ProcessAcceleratorTest = ProcessAcceleratorTest(
4536  enabled = ['test1', 'test2', 'anothertest3']
4537 )
4538 
4539 
4540 """)
4541  p = TestMakePSet()
4542  proc.fillProcessDesc(p)
4543  self.assertEqual(["*"], p.values["options"][1].values["accelerators"][1])
4544  self.assertFalse(p.values["options"][1].values["accelerators"][0])
4545  self.assertTrue(["anothertest3", "cpu", "test1", "test2"], p.values["@selected_accelerators"][1])
4546  self.assertEqual("AcceleratorTestService", p.values["services"][1][0].values["@service_type"][1])
4547  self.assertFalse(p.values["@available_accelerators"][0])
4548  self.assertTrue(["anothertest3", "cpu", "test1", "test2"], p.values["@available_accelerators"][1])
4549 
4550  proc = Process("TEST")
4551  proc.ProcessAcceleratorTest = ProcessAcceleratorTest(enabled=["test1"])
4552  p = TestMakePSet()
4553  proc.fillProcessDesc(p)
4554  self.assertEqual(["cpu", "test1"], p.values["@selected_accelerators"][1])
4555  self.assertEqual(["cpu", "test1"], p.values["@available_accelerators"][1])
4556 
4557  proc = Process("TEST")
4558  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4559  proc.options.accelerators = ["test2"]
4560  p = TestMakePSet()
4561  proc.fillProcessDesc(p)
4562  self.assertEqual(["test2"], p.values["@selected_accelerators"][1])
4563  self.assertEqual(["anothertest3", "cpu", "test1", "test2"], p.values["@available_accelerators"][1])
4564 
4565  proc = Process("TEST")
4566  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4567  proc.options.accelerators = ["test*"]
4568  proc.fillProcessDesc(p)
4569  self.assertEqual(["test1", "test2"], p.values["@selected_accelerators"][1])
4570  self.assertEqual(["anothertest3", "cpu", "test1", "test2"], p.values["@available_accelerators"][1])
4571 
4572  proc = Process("TEST")
4573  proc.ProcessAcceleratorTest = ProcessAcceleratorTest(enabled=["test1"])
4574  proc.options.accelerators = ["test2"]
4575  p = TestMakePSet()
4576  proc.fillProcessDesc(p)
4577  self.assertEqual([], p.values["@selected_accelerators"][1])
4578  self.assertEqual(["cpu", "test1"], p.values["@available_accelerators"][1])
4579 
4580  proc = Process("TEST")
4581  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4582  proc.options.accelerators = ["cpu*"]
4583  p = TestMakePSet()
4584  proc.fillProcessDesc(p)
4585  self.assertEqual(["cpu"], p.values["@selected_accelerators"][1])
4586  self.assertEqual(["anothertest3", "cpu", "test1", "test2"], p.values["@available_accelerators"][1])
4587 
4588  proc = Process("TEST")
4589  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4590  proc.options.accelerators = ["test3"]
4591  p = TestMakePSet()
4592  self.assertRaises(ValueError, proc.fillProcessDesc, p)
4593 
4594  proc = Process("TEST")
4595  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4596  proc.options.accelerators = ["*", "test1"]
4597  p = TestMakePSet()
4598  self.assertRaises(ValueError, proc.fillProcessDesc, p)
4599 
4600  proc = Process("TEST")
4601  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4602  proc.ProcessAcceleratorTest2 = ProcessAcceleratorTest2()
4603  p = TestMakePSet()
4604  proc.fillProcessDesc(p)
4605  self.assertEqual(["anothertest3", "anothertest4", "cpu", "test1", "test2"], p.values["@selected_accelerators"][1])
4606  self.assertEqual(["anothertest3", "anothertest4", "cpu", "test1", "test2"], p.values["@available_accelerators"][1])
4607 
4608  proc = Process("TEST")
4609  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4610  proc.ProcessAcceleratorTest2 = ProcessAcceleratorTest2()
4611  proc.options.accelerators = ["*test3", "c*"]
4612  p = TestMakePSet()
4613  proc.fillProcessDesc(p)
4614  self.assertEqual(["anothertest3", "cpu"], p.values["@selected_accelerators"][1])
4615  self.assertEqual(["anothertest3", "anothertest4", "cpu", "test1", "test2"], p.values["@available_accelerators"][1])
4616 
4617  proc = Process("TEST")
4618  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4619  proc.sp = SwitchProducerTest2(test2 = EDProducer("Foo",
4620  a = int32(1),
4621  b = PSet(c = int32(2))),
4622  test1 = EDProducer("Bar",
4623  aa = int32(11),
4624  bb = PSet(cc = int32(12))))
4625  proc.p = Path(proc.sp)
4626  p = TestMakePSet()
4627  proc.fillProcessDesc(p)
4628  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
4629 
4630  proc = Process("TEST")
4631  proc.ProcessAcceleratorTest = ProcessAcceleratorTest(enabled=["test1"])
4632  proc.sp = SwitchProducerTest2(test2 = EDProducer("Foo",
4633  a = int32(1),
4634  b = PSet(c = int32(2))),
4635  test1 = EDProducer("Bar",
4636  aa = int32(11),
4637  bb = PSet(cc = int32(12))))
4638  proc.p = Path(proc.sp)
4639  p = TestMakePSet()
4640  proc.fillProcessDesc(p)
4641  self.assertEqual((False, "sp@test1"), p.values["sp"][1].values["@chosen_case"])
4642 
4643  proc = Process("TEST")
4644  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4645  proc.options.accelerators = ["test1"]
4646  proc.sp = SwitchProducerTest2(test2 = EDProducer("Foo",
4647  a = int32(1),
4648  b = PSet(c = int32(2))),
4649  test1 = EDProducer("Bar",
4650  aa = int32(11),
4651  bb = PSet(cc = int32(12))))
4652  proc.p = Path(proc.sp)
4653  p = TestMakePSet()
4654  proc.fillProcessDesc(p)
4655  self.assertEqual((False, "sp@test1"), p.values["sp"][1].values["@chosen_case"])
4656 
4657  proc = Process("TEST")
4658  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4659  proc.options.accelerators = ["test*"]
4660  proc.sp = SwitchProducerTest2(test2 = EDProducer("Foo",
4661  a = int32(1),
4662  b = PSet(c = int32(2))),
4663  test1 = EDProducer("Bar",
4664  aa = int32(11),
4665  bb = PSet(cc = int32(12))))
4666  proc.p = Path(proc.sp)
4667  p = TestMakePSet()
4668  proc.fillProcessDesc(p)
4669  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
4670 
4671  proc = Process("TEST")
4672  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4673  proc.options.accelerators = ["anothertest3"]
4674  proc.sp = SwitchProducerTest2(test2 = EDProducer("Foo",
4675  a = int32(1),
4676  b = PSet(c = int32(2))),
4677  test1 = EDProducer("Bar",
4678  aa = int32(11),
4679  bb = PSet(cc = int32(12))))
4680  proc.p = Path(proc.sp)
4681  p = TestMakePSet()
4682  self.assertRaises(RuntimeError, proc.fillProcessDesc, p)
4683 
4684  import pickle
4685  proc = Process("TEST")
4686  proc.ProcessAcceleratorTest = ProcessAcceleratorTest()
4687  proc.sp = SwitchProducerTest2(test2 = EDProducer("Foo",
4688  a = int32(1),
4689  b = PSet(c = int32(2))),
4690  test1 = EDProducer("Bar",
4691  aa = int32(11),
4692  bb = PSet(cc = int32(12))))
4693  proc.p = Path(proc.sp)
4694  pkl = pickle.dumps(proc)
4695  unpkl = pickle.loads(pkl)
4696  p = TestMakePSet()
4697  unpkl.fillProcessDesc(p)
4698  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
4699  self.assertEqual(["anothertest3", "cpu", "test1", "test2"], p.values["@available_accelerators"][1])
4700  unpkl = pickle.loads(pkl)
4701  unpkl.ProcessAcceleratorTest.setEnabled(["test1"])
4702  p = TestMakePSet()
4703  unpkl.fillProcessDesc(p)
4704  self.assertEqual((False, "sp@test1"), p.values["sp"][1].values["@chosen_case"])
4705  self.assertEqual(["cpu", "test1"], p.values["@available_accelerators"][1])
4706 
4707  unittest.main()

◆ testProcessDumpPython()

def Config.TestModuleCommand.testProcessDumpPython (   self)

Definition at line 2335 of file Config.py.

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

2335  def testProcessDumpPython(self):
2336  self.assertEqual(Process("test").dumpPython(),
2337 """import FWCore.ParameterSet.Config as cms
2338 
2339 process = cms.Process("test")
2340 
2341 process.maxEvents = cms.untracked.PSet(
2342  input = cms.optional.untracked.int32,
2343  output = cms.optional.untracked.allowed(cms.int32,cms.PSet)
2344 )
2345 
2346 process.maxLuminosityBlocks = cms.untracked.PSet(
2347  input = cms.untracked.int32(-1)
2348 )
2349 
2350 process.options = cms.untracked.PSet(
2351  FailPath = cms.untracked.vstring(),
2352  IgnoreCompletely = cms.untracked.vstring(),
2353  Rethrow = cms.untracked.vstring(),
2354  SkipEvent = cms.untracked.vstring(),
2355  accelerators = cms.untracked.vstring('*'),
2356  allowUnscheduled = cms.obsolete.untracked.bool,
2357  canDeleteEarly = cms.untracked.vstring(),
2358  deleteNonConsumedUnscheduledModules = cms.untracked.bool(True),
2359  dumpOptions = cms.untracked.bool(False),
2360  emptyRunLumiMode = cms.obsolete.untracked.string,
2361  eventSetup = cms.untracked.PSet(
2362  forceNumberOfConcurrentIOVs = cms.untracked.PSet(
2363  allowAnyLabel_=cms.required.untracked.uint32
2364  ),
2365  numberOfConcurrentIOVs = cms.untracked.uint32(0)
2366  ),
2367  fileMode = cms.untracked.string('FULLMERGE'),
2368  forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
2369  makeTriggerResults = cms.obsolete.untracked.bool,
2370  numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0),
2371  numberOfConcurrentRuns = cms.untracked.uint32(1),
2372  numberOfStreams = cms.untracked.uint32(0),
2373  numberOfThreads = cms.untracked.uint32(1),
2374  printDependencies = cms.untracked.bool(False),
2375  sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
2376  throwIfIllegalParameter = cms.untracked.bool(True),
2377  wantSummary = cms.untracked.bool(False)
2378 )
2379 
2380 process.MessageLogger = cms.Service("MessageLogger",
2381  cerr = cms.untracked.PSet(
2382  FwkReport = cms.untracked.PSet(
2383  limit = cms.untracked.int32(10000000),
2384  reportEvery = cms.untracked.int32(1)
2385  ),
2386  FwkSummary = cms.untracked.PSet(
2387  limit = cms.untracked.int32(10000000),
2388  reportEvery = cms.untracked.int32(1)
2389  ),
2390  INFO = cms.untracked.PSet(
2391  limit = cms.untracked.int32(0)
2392  ),
2393  Root_NoDictionary = cms.untracked.PSet(
2394  limit = cms.untracked.int32(0)
2395  ),
2396  default = cms.untracked.PSet(
2397  limit = cms.untracked.int32(10000000)
2398  ),
2399  enable = cms.untracked.bool(True),
2400  enableStatistics = cms.untracked.bool(True),
2401  lineLength = cms.optional.untracked.int32,
2402  noLineBreaks = cms.optional.untracked.bool,
2403  noTimeStamps = cms.untracked.bool(False),
2404  resetStatistics = cms.untracked.bool(False),
2405  statisticsThreshold = cms.untracked.string('WARNING'),
2406  threshold = cms.untracked.string('INFO'),
2407  allowAnyLabel_=cms.optional.untracked.PSetTemplate(
2408  limit = cms.optional.untracked.int32,
2409  reportEvery = cms.untracked.int32(1),
2410  timespan = cms.optional.untracked.int32
2411  )
2412  ),
2413  cout = cms.untracked.PSet(
2414  enable = cms.untracked.bool(False),
2415  enableStatistics = cms.untracked.bool(False),
2416  lineLength = cms.optional.untracked.int32,
2417  noLineBreaks = cms.optional.untracked.bool,
2418  noTimeStamps = cms.optional.untracked.bool,
2419  resetStatistics = cms.untracked.bool(False),
2420  statisticsThreshold = cms.optional.untracked.string,
2421  threshold = cms.optional.untracked.string,
2422  allowAnyLabel_=cms.optional.untracked.PSetTemplate(
2423  limit = cms.optional.untracked.int32,
2424  reportEvery = cms.untracked.int32(1),
2425  timespan = cms.optional.untracked.int32
2426  )
2427  ),
2428  debugModules = cms.untracked.vstring(),
2429  default = cms.untracked.PSet(
2430  limit = cms.optional.untracked.int32,
2431  lineLength = cms.untracked.int32(80),
2432  noLineBreaks = cms.untracked.bool(False),
2433  noTimeStamps = cms.untracked.bool(False),
2434  reportEvery = cms.untracked.int32(1),
2435  statisticsThreshold = cms.untracked.string('INFO'),
2436  threshold = cms.untracked.string('INFO'),
2437  timespan = cms.optional.untracked.int32,
2438  allowAnyLabel_=cms.optional.untracked.PSetTemplate(
2439  limit = cms.optional.untracked.int32,
2440  reportEvery = cms.untracked.int32(1),
2441  timespan = cms.optional.untracked.int32
2442  )
2443  ),
2444  files = cms.untracked.PSet(
2445  allowAnyLabel_=cms.optional.untracked.PSetTemplate(
2446  enableStatistics = cms.untracked.bool(False),
2447  extension = cms.optional.untracked.string,
2448  filename = cms.optional.untracked.string,
2449  lineLength = cms.optional.untracked.int32,
2450  noLineBreaks = cms.optional.untracked.bool,
2451  noTimeStamps = cms.optional.untracked.bool,
2452  output = cms.optional.untracked.string,
2453  resetStatistics = cms.untracked.bool(False),
2454  statisticsThreshold = cms.optional.untracked.string,
2455  threshold = cms.optional.untracked.string,
2456  allowAnyLabel_=cms.optional.untracked.PSetTemplate(
2457  limit = cms.optional.untracked.int32,
2458  reportEvery = cms.untracked.int32(1),
2459  timespan = cms.optional.untracked.int32
2460  )
2461  )
2462  ),
2463  suppressDebug = cms.untracked.vstring(),
2464  suppressFwkInfo = cms.untracked.vstring(),
2465  suppressInfo = cms.untracked.vstring(),
2466  suppressWarning = cms.untracked.vstring(),
2467  allowAnyLabel_=cms.optional.untracked.PSetTemplate(
2468  limit = cms.optional.untracked.int32,
2469  reportEvery = cms.untracked.int32(1),
2470  timespan = cms.optional.untracked.int32
2471  )
2472 )
2473 
2474 
2475 """)
2476  p = Process("test")
2477  p.a = EDAnalyzer("MyAnalyzer")
2478  p.p = Path(p.a)
2479  p.s = Sequence(p.a)
2480  p.r = Sequence(p.s)
2481  p.p2 = Path(p.s)
2482  p.schedule = Schedule(p.p2,p.p)
2483  d=p.dumpPython()
2484  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2485 """process.a = cms.EDAnalyzer("MyAnalyzer")
2486 process.s = cms.Sequence(process.a)
2487 process.r = cms.Sequence(process.s)
2488 process.p = cms.Path(process.a)
2489 process.p2 = cms.Path(process.s)
2490 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
2491  #Reverse order of 'r' and 's'
2492  p = Process("test")
2493  p.a = EDAnalyzer("MyAnalyzer")
2494  p.p = Path(p.a)
2495  p.r = Sequence(p.a)
2496  p.s = Sequence(p.r)
2497  p.p2 = Path(p.r)
2498  p.schedule = Schedule(p.p2,p.p)
2499  p.b = EDAnalyzer("YourAnalyzer")
2500  d=p.dumpPython()
2501  self.assertEqual(_lineDiff(d,Process("test").dumpPython()),
2502 """process.a = cms.EDAnalyzer("MyAnalyzer")
2503 process.b = cms.EDAnalyzer("YourAnalyzer")
2504 process.r = cms.Sequence(process.a)
2505 process.s = cms.Sequence(process.r)
2506 process.p = cms.Path(process.a)
2507 process.p2 = cms.Path(process.r)
2508 process.schedule = cms.Schedule(*[ process.p2, process.p ])""")
def _lineDiff(newString, oldString)
Definition: Config.py:2021
def dumpPython(process, name)

◆ testProcessExtend()

def Config.TestModuleCommand.testProcessExtend (   self)

Definition at line 2240 of file Config.py.

References submitPVValidationJobs.__init__(), resolutioncreator_cfi.object, and str.

2240  def testProcessExtend(self):
2241  class FromArg(object):
2242  def __init__(self,*arg,**args):
2243  for name in args.keys():
2244  self.__dict__[name]=args[name]
2245 
2246  a=EDAnalyzer("MyAnalyzer")
2247  t=EDAnalyzer("MyAnalyzer")
2248  t.setLabel("foo")
2249  s1 = Sequence(a)
2250  s2 = Sequence(s1)
2251  s3 = Sequence(s2)
2252  d = FromArg(
2253  a=a,
2254  b=Service("Full"),
2255  c=Path(a),
2256  d=s2,
2257  e=s1,
2258  f=s3,
2259  g=Sequence(s1+s2+s3)
2260  )
2261  p = Process("Test")
2262  p.extend(d)
2263  self.assertEqual(p.a.type_(),"MyAnalyzer")
2264  self.assertEqual(p.a.label_(),"a")
2265  self.assertRaises(AttributeError,getattr,p,'b')
2266  self.assertEqual(p.Full.type_(),"Full")
2267  self.assertEqual(str(p.c),'a')
2268  self.assertEqual(str(p.d),'a')
2269 
2270  z1 = FromArg(
2271  a=a,
2272  b=Service("Full"),
2273  c=Path(a),
2274  d=s2,
2275  e=s1,
2276  f=s3,
2277  s4=s3,
2278  g=Sequence(s1+s2+s3)
2279  )
2280 
2281  p1 = Process("Test")
2282  #p1.extend(z1)
2283  self.assertRaises(ValueError, p1.extend, z1)
2284 
2285  z2 = FromArg(
2286  a=a,
2287  b=Service("Full"),
2288  c=Path(a),
2289  d=s2,
2290  e=s1,
2291  f=s3,
2292  aaa=copy.deepcopy(a),
2293  s4=copy.deepcopy(s3),
2294  g=Sequence(s1+s2+s3),
2295  t=t
2296  )
2297  p2 = Process("Test")
2298  p2.extend(z2)
2299  #self.assertRaises(ValueError, p2.extend, z2)
2300  self.assertEqual(p2.s4.label_(),"s4")
2301  #p2.s4.setLabel("foo")
2302  self.assertRaises(ValueError, p2.s4.setLabel, "foo")
2303  p2.s4.setLabel("s4")
2304  p2.s4.setLabel(None)
2305  p2.s4.setLabel("foo")
2306  p2._Process__setObjectLabel(p2.s4, "foo")
2307  p2._Process__setObjectLabel(p2.s4, None)
2308  p2._Process__setObjectLabel(p2.s4, "bar")
2309 
2310 
2311  p = Process('test')
2312  p.a = EDProducer("MyProducer")
2313  p.t = Task(p.a)
2314  p.p = Path(p.t)
2315  self.assertRaises(ValueError, p.extend, FromArg(a = EDProducer("YourProducer")))
2316  self.assertRaises(ValueError, p.extend, FromArg(a = EDAlias()))
2317  self.assertRaises(ValueError, p.__setattr__, "a", EDAlias())
2318 
2319  p = Process('test')
2320  p.a = EDProducer("MyProducer")
2321  p.t = ConditionalTask(p.a)
2322  p.p = Path(p.t)
2323  self.assertRaises(ValueError, p.extend, FromArg(a = EDProducer("YourProducer")))
2324  self.assertRaises(ValueError, p.extend, FromArg(a = EDAlias()))
2325  self.assertRaises(ValueError, p.__setattr__, "a", EDAlias())
2326 
2327  p = Process('test')
2328  p.a = EDProducer("MyProducer")
2329  p.s = Sequence(p.a)
2330  p.p = Path(p.s)
2331  self.assertRaises(ValueError, p.extend, FromArg(a = EDProducer("YourProducer")))
2332  self.assertRaises(ValueError, p.extend, FromArg(a = EDAlias()))
2333  self.assertRaises(ValueError, p.__setattr__, "a", EDAlias())
2334 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
#define str(s)

◆ testProcessForProcessAccelerator()

def Config.TestModuleCommand.testProcessForProcessAccelerator (   self)

Definition at line 4464 of file Config.py.

4464  def testProcessForProcessAccelerator(self):
4465  proc = Process("TEST")
4466  p = ProcessForProcessAccelerator(proc)
4467  p.TestService = Service("TestService")
4468  self.assertTrue(hasattr(proc, "TestService"))
4469  self.assertEqual(proc.TestService.type_(), "TestService")
4470  self.assertRaises(TypeError, setattr, p, "a", EDProducer("Foo"))
4471  p.add_(Service("TestServiceTwo"))
4472  self.assertTrue(hasattr(proc, "TestServiceTwo"))
4473  self.assertEqual(proc.TestServiceTwo.type_(), "TestServiceTwo")
4474  p.TestService.foo = untracked.uint32(42)
4475  self.assertEqual(proc.TestService.foo.value(), 42)
4476  proc.mod = EDProducer("Producer")
4477  self.assertRaises(TypeError, getattr, p, "mod")

◆ testProcessFragment()

def Config.TestModuleCommand.testProcessFragment (   self)

Definition at line 4447 of file Config.py.

4447  def testProcessFragment(self):
4448  #check defaults are not overwritten
4449  f = ProcessFragment('Fragment')
4450  p = Process('PROCESS')
4451  p.maxEvents.input = 10
4452  p.options.numberOfThreads = 4
4453  p.maxLuminosityBlocks.input = 2
4454  p.extend(f)
4455  self.assertEqual(p.maxEvents.input.value(),10)
4456  self.assertEqual(p.options.numberOfThreads.value(), 4)
4457  self.assertEqual(p.maxLuminosityBlocks.input.value(),2)
4458  #general checks
4459  f = ProcessFragment("Fragment")
4460  f.fltr = EDFilter("Foo")
4461  p = Process('PROCESS')
4462  p.extend(f)
4463  self.assertTrue(hasattr(p,'fltr'))

◆ testProcessInsertion()

def Config.TestModuleCommand.testProcessInsertion (   self)

Definition at line 2215 of file Config.py.

2215  def testProcessInsertion(self):
2216  p = Process("test")
2217  p.a = EDAnalyzer("MyAnalyzer")
2218  self.assertTrue( 'a' in p.analyzers_() )
2219  self.assertTrue( 'a' in p.analyzers)
2220  p.add_(Service("SomeService"))
2221  self.assertTrue('SomeService' in p.services_())
2222  self.assertEqual(p.SomeService.type_(), "SomeService")
2223  p.Tracer = Service("Tracer")
2224  self.assertTrue('Tracer' in p.services_())
2225  self.assertRaises(TypeError, setattr, *(p,'b',"this should fail"))
2226  self.assertRaises(TypeError, setattr, *(p,'bad',Service("MessageLogger")))
2227  self.assertRaises(ValueError, setattr, *(p,'bad',Source("PoolSource")))
2228  p.out = OutputModule("Outer")
2229  self.assertEqual(p.out.type_(), 'Outer')
2230  self.assertTrue( 'out' in p.outputModules_() )
2231 
2232  p.geom = ESSource("GeomProd")
2233  self.assertTrue('geom' in p.es_sources_())
2234  p.add_(ESSource("ConfigDB"))
2235  self.assertTrue('ConfigDB' in p.es_sources_())
2236 
2237  p.aliasfoo1 = EDAlias(foo1 = VPSet(PSet(type = string("Foo1"))))
2238  self.assertTrue('aliasfoo1' in p.aliases_())
2239 

◆ testPrune()

def Config.TestModuleCommand.testPrune (   self)

Definition at line 3724 of file Config.py.

3724  def testPrune(self):
3725  p = Process("test")
3726  p.a = EDAnalyzer("MyAnalyzer")
3727  p.b = EDAnalyzer("YourAnalyzer")
3728  p.c = EDAnalyzer("OurAnalyzer")
3729  p.d = EDAnalyzer("OurAnalyzer")
3730  p.e = EDProducer("MyProducer")
3731  p.f = EDProducer("YourProducer")
3732  p.g = EDProducer("TheirProducer")
3733  p.h = EDProducer("OnesProducer")
3734  p.s = Sequence(p.d)
3735  p.t1 = Task(p.e)
3736  p.t2 = Task(p.f)
3737  p.t3 = Task(p.g, p.t1)
3738  p.ct1 = ConditionalTask(p.h)
3739  p.ct2 = ConditionalTask(p.f)
3740  p.ct3 = ConditionalTask(p.ct1)
3741  p.path1 = Path(p.a, p.t3, p.ct3)
3742  p.path2 = Path(p.b)
3743  self.assertTrue(p.schedule is None)
3744  pths = p.paths
3745  keys = pths.keys()
3746  self.assertEqual(pths[keys[0]],p.path1)
3747  self.assertEqual(pths[keys[1]],p.path2)
3748  p.pset1 = PSet(parA = string("pset1"))
3749  p.pset2 = untracked.PSet(parA = string("pset2"))
3750  p.vpset1 = VPSet()
3751  p.vpset2 = untracked.VPSet()
3752  p.prune()
3753  self.assertTrue(hasattr(p, 'a'))
3754  self.assertTrue(hasattr(p, 'b'))
3755  self.assertTrue(not hasattr(p, 'c'))
3756  self.assertTrue(not hasattr(p, 'd'))
3757  self.assertTrue(hasattr(p, 'e'))
3758  self.assertTrue(not hasattr(p, 'f'))
3759  self.assertTrue(hasattr(p, 'g'))
3760  self.assertTrue(hasattr(p, 'h'))
3761  self.assertTrue(not hasattr(p, 's'))
3762  self.assertTrue(hasattr(p, 't1'))
3763  self.assertTrue(not hasattr(p, 't2'))
3764  self.assertTrue(hasattr(p, 't3'))
3765  self.assertTrue(hasattr(p, 'path1'))
3766  self.assertTrue(hasattr(p, 'path2'))
3767 # self.assertTrue(not hasattr(p, 'pset1'))
3768 # self.assertTrue(hasattr(p, 'pset2'))
3769 # self.assertTrue(not hasattr(p, 'vpset1'))
3770 # self.assertTrue(not hasattr(p, 'vpset2'))
3771 
3772  p = Process("test")
3773  p.a = EDAnalyzer("MyAnalyzer")
3774  p.b = EDAnalyzer("YourAnalyzer")
3775  p.c = EDAnalyzer("OurAnalyzer")
3776  p.d = EDAnalyzer("OurAnalyzer")
3777  p.e = EDAnalyzer("OurAnalyzer")
3778  p.f = EDProducer("MyProducer")
3779  p.g = EDProducer("YourProducer")
3780  p.h = EDProducer("TheirProducer")
3781  p.i = EDProducer("OurProducer")
3782  p.j = EDProducer("OurProducer")
3783  p.k = EDProducer("OurProducer")
3784  p.l = EDProducer("OurProducer")
3785  p.t1 = Task(p.f)
3786  p.t2 = Task(p.g)
3787  p.t3 = Task(p.h)
3788  p.t4 = Task(p.i)
3789  p.ct1 = Task(p.f)
3790  p.ct2 = Task(p.j)
3791  p.ct3 = Task(p.k)
3792  p.ct4 = Task(p.l)
3793  p.s = Sequence(p.d, p.t1, p.ct1)
3794  p.s2 = Sequence(p.b, p.t2, p.ct2)
3795  p.s3 = Sequence(p.e)
3796  p.path1 = Path(p.a, p.t3, p.ct3)
3797  p.path2 = Path(p.b)
3798  p.path3 = Path(p.b+p.s2)
3799  p.path4 = Path(p.b+p.s3)
3800  p.schedule = Schedule(p.path1,p.path2,p.path3)
3801  p.schedule.associate(p.t4)
3802  pths = p.paths
3803  keys = pths.keys()
3804  self.assertEqual(pths[keys[0]],p.path1)
3805  self.assertEqual(pths[keys[1]],p.path2)
3806  p.prune()
3807  self.assertTrue(hasattr(p, 'a'))
3808  self.assertTrue(hasattr(p, 'b'))
3809  self.assertTrue(not hasattr(p, 'c'))
3810  self.assertTrue(not hasattr(p, 'd'))
3811  self.assertTrue(not hasattr(p, 'e'))
3812  self.assertTrue(not hasattr(p, 'f'))
3813  self.assertTrue(hasattr(p, 'g'))
3814  self.assertTrue(hasattr(p, 'h'))
3815  self.assertTrue(hasattr(p, 'i'))
3816  self.assertTrue(hasattr(p, 'j'))
3817  self.assertTrue(hasattr(p, 'k'))
3818  self.assertTrue(not hasattr(p, 'l'))
3819  self.assertTrue(not hasattr(p, 't1'))
3820  self.assertTrue(hasattr(p, 't2'))
3821  self.assertTrue(hasattr(p, 't3'))
3822  self.assertTrue(hasattr(p, 't4'))
3823  self.assertTrue(not hasattr(p, 'ct1'))
3824  self.assertTrue(hasattr(p, 'ct2'))
3825  self.assertTrue(hasattr(p, 'ct3'))
3826  self.assertTrue(not hasattr(p, 'ct4'))
3827  self.assertTrue(not hasattr(p, 's'))
3828  self.assertTrue(hasattr(p, 's2'))
3829  self.assertTrue(not hasattr(p, 's3'))
3830  self.assertTrue(hasattr(p, 'path1'))
3831  self.assertTrue(hasattr(p, 'path2'))
3832  self.assertTrue(hasattr(p, 'path3'))
3833  self.assertTrue(not hasattr(p, 'path4'))
3834  #test SequencePlaceholder
3835  p = Process("test")
3836  p.a = EDAnalyzer("MyAnalyzer")
3837  p.b = EDAnalyzer("YourAnalyzer")
3838  p.s = Sequence(SequencePlaceholder("a")+p.b)
3839  p.pth = Path(p.s)
3840  p.prune()
3841  self.assertTrue(hasattr(p, 'a'))
3842  self.assertTrue(hasattr(p, 'b'))
3843  self.assertTrue(hasattr(p, 's'))
3844  self.assertTrue(hasattr(p, 'pth'))
3845  #test unresolved SequencePlaceholder
3846  p = Process("test")
3847  p.b = EDAnalyzer("YourAnalyzer")
3848  p.s = Sequence(SequencePlaceholder("a")+p.b)
3849  p.pth = Path(p.s)
3850  p.prune(keepUnresolvedSequencePlaceholders=True)
3851  self.assertTrue(hasattr(p, 'b'))
3852  self.assertTrue(hasattr(p, 's'))
3853  self.assertTrue(hasattr(p, 'pth'))
3854  self.assertEqual(p.s.dumpPython(),'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
3855  #test TaskPlaceholder
3856  p = Process("test")
3857  p.a = EDProducer("MyProducer")
3858  p.b = EDProducer("YourProducer")
3859  p.s = Task(TaskPlaceholder("a"),p.b)
3860  p.pth = Path(p.s)
3861  p.prune()
3862  self.assertTrue(hasattr(p, 'a'))
3863  self.assertTrue(hasattr(p, 'b'))
3864  self.assertTrue(hasattr(p, 's'))
3865  self.assertTrue(hasattr(p, 'pth'))
3866  #test ConditionalTaskPlaceholder
3867  p = Process("test")
3868  p.a = EDProducer("MyProducer")
3869  p.b = EDProducer("YourProducer")
3870  p.s = ConditionalTask(ConditionalTaskPlaceholder("a"),p.b)
3871  p.pth = Path(p.s)
3872  p.prune()
3873  self.assertTrue(hasattr(p, 'a'))
3874  self.assertTrue(hasattr(p, 'b'))
3875  self.assertTrue(hasattr(p, 's'))
3876  self.assertTrue(hasattr(p, 'pth'))
3877  #test unresolved SequencePlaceholder
3878  p = Process("test")
3879  p.b = EDProducer("YourAnalyzer")
3880  p.s = Task(TaskPlaceholder("a"),p.b)
3881  p.pth = Path(p.s)
3882  p.prune(keepUnresolvedSequencePlaceholders=True)
3883  self.assertTrue(hasattr(p, 'b'))
3884  self.assertTrue(hasattr(p, 's'))
3885  self.assertTrue(hasattr(p, 'pth'))
3886  self.assertEqual(p.s.dumpPython(),'cms.Task(cms.TaskPlaceholder("a"), process.b)\n')

◆ testRefToPSet()

def Config.TestModuleCommand.testRefToPSet (   self)

Definition at line 3600 of file Config.py.

3600  def testRefToPSet(self):
3601  proc = Process("test")
3602  proc.top = PSet(a = int32(1))
3603  proc.ref = PSet(refToPSet_ = string("top"))
3604  proc.ref2 = PSet( a = int32(1), b = PSet( refToPSet_ = string("top")))
3605  proc.ref3 = PSet(refToPSet_ = string("ref"))
3606  proc.ref4 = VPSet(PSet(refToPSet_ = string("top")),
3607  PSet(refToPSet_ = string("ref2")))
3608  p = TestMakePSet()
3609  proc.fillProcessDesc(p)
3610  self.assertEqual((True,1),p.values["ref"][1].values["a"])
3611  self.assertEqual((True,1),p.values["ref3"][1].values["a"])
3612  self.assertEqual((True,1),p.values["ref2"][1].values["a"])
3613  self.assertEqual((True,1),p.values["ref2"][1].values["b"][1].values["a"])
3614  self.assertEqual((True,1),p.values["ref4"][1][0].values["a"])
3615  self.assertEqual((True,1),p.values["ref4"][1][1].values["a"])

◆ testSchedule()

def Config.TestModuleCommand.testSchedule (   self)

Definition at line 3320 of file Config.py.

3320  def testSchedule(self):
3321  p = Process("test")
3322  p.a = EDAnalyzer("MyAnalyzer")
3323  p.b = EDAnalyzer("YourAnalyzer")
3324  p.c = EDAnalyzer("OurAnalyzer")
3325  p.d = EDAnalyzer("OurAnalyzer")
3326  p.path1 = Path(p.a)
3327  p.path2 = Path(p.b)
3328  p.path3 = Path(p.d)
3329 
3330  s = Schedule(p.path1,p.path2)
3331  self.assertEqual(s[0],p.path1)
3332  self.assertEqual(s[1],p.path2)
3333  p.schedule = s
3334  self.assertTrue('b' in p.schedule.moduleNames())
3335  self.assertTrue(hasattr(p, 'b'))
3336  self.assertTrue(hasattr(p, 'c'))
3337  self.assertTrue(hasattr(p, 'd'))
3338  self.assertTrue(hasattr(p, 'path1'))
3339  self.assertTrue(hasattr(p, 'path2'))
3340  self.assertTrue(hasattr(p, 'path3'))
3341  p.prune()
3342  self.assertTrue('b' in p.schedule.moduleNames())
3343  self.assertTrue(hasattr(p, 'b'))
3344  self.assertTrue(not hasattr(p, 'c'))
3345  self.assertTrue(not hasattr(p, 'd'))
3346  self.assertTrue(hasattr(p, 'path1'))
3347  self.assertTrue(hasattr(p, 'path2'))
3348  self.assertTrue(not hasattr(p, 'path3'))
3349 
3350  self.assertTrue(len(p.schedule._tasks) == 0)
3351 
3352  p = Process("test")
3353  p.a = EDAnalyzer("MyAnalyzer")
3354  p.b = EDAnalyzer("YourAnalyzer")
3355  p.c = EDAnalyzer("OurAnalyzer")
3356  p.d = EDAnalyzer("dAnalyzer")
3357  p.e = EDProducer("eProducer")
3358  p.f = EDProducer("fProducer")
3359  p.Tracer = Service("Tracer")
3360  p.path1 = Path(p.a)
3361  p.path2 = Path(p.b)
3362  p.path3 = Path(p.d)
3363  p.task1 = Task(p.e)
3364  p.task2 = Task(p.f, p.Tracer)
3365  s = Schedule(p.path1,p.path2,tasks=[p.task1,p.task2,p.task1])
3366  self.assertEqual(s[0],p.path1)
3367  self.assertEqual(s[1],p.path2)
3368  self.assertTrue(len(s._tasks) == 2)
3369  self.assertTrue(p.task1 in s._tasks)
3370  self.assertTrue(p.task2 in s._tasks)
3371  listOfTasks = list(s._tasks)
3372  self.assertTrue(len(listOfTasks) == 2)
3373  self.assertTrue(p.task1 == listOfTasks[0])
3374  self.assertTrue(p.task2 == listOfTasks[1])
3375  p.schedule = s
3376  self.assertTrue('b' in p.schedule.moduleNames())
3377 
3378  process2 = Process("test")
3379  process2.a = EDAnalyzer("MyAnalyzer")
3380  process2.e = EDProducer("eProducer")
3381  process2.path1 = Path(process2.a)
3382  process2.task1 = Task(process2.e)
3383  process2.schedule = Schedule(process2.path1,tasks=process2.task1)
3384  listOfTasks = list(process2.schedule._tasks)
3385  self.assertTrue(listOfTasks[0] == process2.task1)
3386 
3387  # test Schedule copy
3388  s2 = s.copy()
3389  self.assertEqual(s2[0],p.path1)
3390  self.assertEqual(s2[1],p.path2)
3391  self.assertTrue(len(s2._tasks) == 2)
3392  self.assertTrue(p.task1 in s2._tasks)
3393  self.assertTrue(p.task2 in s2._tasks)
3394  listOfTasks = list(s2._tasks)
3395  self.assertTrue(len(listOfTasks) == 2)
3396  self.assertTrue(p.task1 == listOfTasks[0])
3397  self.assertTrue(p.task2 == listOfTasks[1])
3398 
3399  names = s.moduleNames()
3400  self.assertTrue(names == set(['a', 'b', 'e', 'Tracer', 'f']))
3401  #adding a path not attached to the Process should cause an exception
3402  p = Process("test")
3403  p.a = EDAnalyzer("MyAnalyzer")
3404  path1 = Path(p.a)
3405  s = Schedule(path1)
3406  self.assertRaises(RuntimeError, lambda : p.setSchedule_(s) )
3407 
3408  #make sure anonymous sequences work
3409  p = Process("test")
3410  p.a = EDAnalyzer("MyAnalyzer")
3411  p.b = EDAnalyzer("MyOtherAnalyzer")
3412  p.c = EDProducer("MyProd")
3413  path1 = Path(p.c*Sequence(p.a+p.b))
3414  s = Schedule(path1)
3415  self.assertTrue('a' in s.moduleNames())
3416  self.assertTrue('b' in s.moduleNames())
3417  self.assertTrue('c' in s.moduleNames())
3418  p.path1 = path1
3419  p.schedule = s
3420  p.prune()
3421  self.assertTrue('a' in s.moduleNames())
3422  self.assertTrue('b' in s.moduleNames())
3423  self.assertTrue('c' in s.moduleNames())
3424 

◆ testSecSource()

def Config.TestModuleCommand.testSecSource (   self)

Definition at line 2647 of file Config.py.

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

2647  def testSecSource(self):
2648  p = Process('test')
2649  p.a = SecSource("MySecSource")
2650  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),'process.a = cms.SecSource("MySecSource")')
2651 
def _lineDiff(newString, oldString)
Definition: Config.py:2021
def dumpPython(process, name)

◆ testSequence()

def Config.TestModuleCommand.testSequence (   self)

Definition at line 2723 of file Config.py.

References str.

2723  def testSequence(self):
2724  p = Process('test')
2725  p.a = EDAnalyzer("MyAnalyzer")
2726  p.b = EDAnalyzer("YourAnalyzer")
2727  p.c = EDAnalyzer("OurAnalyzer")
2728  p.s = Sequence(p.a*p.b)
2729  self.assertEqual(str(p.s),'a+b')
2730  self.assertEqual(p.s.label_(),'s')
2731  path = Path(p.c+p.s)
2732  self.assertEqual(str(path),'c+a+b')
2733  p._validateSequence(path, 'p1')
2734  notInProcess = EDAnalyzer('NotInProcess')
2735  p2 = Path(p.c+p.s*notInProcess)
2736  self.assertRaises(RuntimeError, p._validateSequence, p2, 'p2')
2737 
#define str(s)

◆ testSequence2()

def Config.TestModuleCommand.testSequence2 (   self)

Definition at line 2738 of file Config.py.

2738  def testSequence2(self):
2739  p = Process('test')
2740  p.a = EDAnalyzer("MyAnalyzer")
2741  p.b = EDAnalyzer("YourAnalyzer")
2742  p.c = EDAnalyzer("OurAnalyzer")
2743  testseq = Sequence(p.a*p.b)
2744  p.s = testseq
2745  #p.y = testseq
2746  self.assertRaises(ValueError, p.__setattr__, "y", testseq)
2747 

◆ testServiceInProcess()

def Config.TestModuleCommand.testServiceInProcess (   self)

Definition at line 2748 of file Config.py.

2748  def testServiceInProcess(self):
2749  service = Service("d")
2750  self.assertFalse(service._inProcess)
2751  process = Process("test")
2752  process.d = service
2753  self.assertTrue(service._inProcess)
2754  service2 = Service("d")
2755  process.d = service2
2756  self.assertFalse(service._inProcess)
2757  self.assertTrue(service2._inProcess)
2758  del process.d
2759  self.assertFalse(service2._inProcess)
2760 

◆ testSubProcess()

def Config.TestModuleCommand.testSubProcess (   self)

Definition at line 3565 of file Config.py.

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

3565  def testSubProcess(self):
3566  process = Process("Parent")
3567  subProcess = Process("Child")
3568  subProcess.a = EDProducer("A")
3569  subProcess.p = Path(subProcess.a)
3570  subProcess.add_(Service("Foo"))
3571  process.addSubProcess(SubProcess(subProcess))
3572  d = process.dumpPython()
3573  equalD ="""parentProcess = process
3574 process.a = cms.EDProducer("A")
3575 process.Foo = cms.Service("Foo")
3576 process.p = cms.Path(process.a)
3577 childProcess = process
3578 process = parentProcess
3579 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet(
3580 ), outputCommands = cms.untracked.vstring()))"""
3581  equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcesses_()[0])))
3582  # SubProcesses are dumped before Services, so in order to
3583  # craft the dump of the Parent and Child manually the dump
3584  # of the Parent needs to be split at the MessageLogger
3585  # boundary (now when it is part of Process by default),
3586  # and insert the dump of the Child between the top part of
3587  # the Parent (before MessageLogger) and the bottom part of
3588  # the Parent (after and including MessageLogger)
3589  messageLoggerSplit = 'process.MessageLogger = cms.Service'
3590  parentDumpSplit = Process('Parent').dumpPython().split(messageLoggerSplit)
3591  childProcess = Process('Child')
3592  del childProcess.MessageLogger
3593  combinedDump = parentDumpSplit[0] + childProcess.dumpPython() + messageLoggerSplit + parentDumpSplit[1]
3594  self.assertEqual(_lineDiff(d, combinedDump), equalD)
3595  p = TestMakePSet()
3596  process.fillProcessDesc(p)
3597  self.assertEqual((True,['a']),p.values["subProcesses"][1][0].values["process"][1].values['@all_modules'])
3598  self.assertEqual((True,['p']),p.values["subProcesses"][1][0].values["process"][1].values['@paths'])
3599  self.assertEqual({'@service_type':(True,'Foo')}, p.values["subProcesses"][1][0].values["process"][1].values["services"][1][0].values)
def _lineDiff(newString, oldString)
Definition: Config.py:2021
def dumpPython(process, name)
#define str(s)

◆ testSwitchProducer()

def Config.TestModuleCommand.testSwitchProducer (   self)

Definition at line 3616 of file Config.py.

References jetUpdater_cfi.sort.

3616  def testSwitchProducer(self):
3617  proc = Process("test")
3618  proc.sp = SwitchProducerTest(test2 = EDProducer("Foo",
3619  a = int32(1),
3620  b = PSet(c = int32(2))),
3621  test1 = EDProducer("Bar",
3622  aa = int32(11),
3623  bb = PSet(cc = int32(12))))
3624  self.assertEqual(proc.sp.label_(), "sp")
3625  self.assertEqual(proc.sp.test1.label_(), "sp@test1")
3626  self.assertEqual(proc.sp.test2.label_(), "sp@test2")
3627 
3628  proc.a = EDProducer("A")
3629  proc.s = Sequence(proc.a + proc.sp)
3630  proc.t = Task(proc.a, proc.sp)
3631  proc.p = Path()
3632  proc.p.associate(proc.t)
3633  p = TestMakePSet()
3634  proc.fillProcessDesc(p)
3635  self.assertEqual((True,"EDProducer"), p.values["sp"][1].values["@module_edm_type"])
3636  self.assertEqual((True, "SwitchProducer"), p.values["sp"][1].values["@module_type"])
3637  self.assertEqual((True, "sp"), p.values["sp"][1].values["@module_label"])
3638  all_cases = copy.deepcopy(p.values["sp"][1].values["@all_cases"])
3639  all_cases[1].sort() # names of all cases come via dict, i.e. their order is undefined
3640  self.assertEqual((True, ["sp@test1", "sp@test2"]), all_cases)
3641  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
3642  self.assertEqual(["a", "sp", "sp@test1", "sp@test2"], p.values["@all_modules"][1])
3643  self.assertEqual((True,"EDProducer"), p.values["sp@test1"][1].values["@module_edm_type"])
3644  self.assertEqual((True,"Bar"), p.values["sp@test1"][1].values["@module_type"])
3645  self.assertEqual((True,"EDProducer"), p.values["sp@test2"][1].values["@module_edm_type"])
3646  self.assertEqual((True,"Foo"), p.values["sp@test2"][1].values["@module_type"])
3647  dump = proc.dumpPython()
3648  self.assertEqual(dump.find('@'), -1)
3649  self.assertEqual(specialImportRegistry.getSpecialImports(), ["from test import SwitchProducerTest"])
3650  self.assertTrue(dump.find("\nfrom test import SwitchProducerTest\n") != -1)
3651 
3652  # EDAlias as non-chosen case
3653  proc = Process("test")
3654  proc.sp = SwitchProducerTest(test2 = EDProducer("Foo",
3655  a = int32(1),
3656  b = PSet(c = int32(2))),
3657  test1 = EDAlias(a = VPSet(PSet(type = string("Bar")))))
3658  proc.a = EDProducer("A")
3659  proc.s = Sequence(proc.a + proc.sp)
3660  proc.t = Task(proc.a, proc.sp)
3661  proc.p = Path()
3662  proc.p.associate(proc.t)
3663  p = TestMakePSet()
3664  proc.fillProcessDesc(p)
3665  self.assertEqual((True,"EDProducer"), p.values["sp"][1].values["@module_edm_type"])
3666  self.assertEqual((True, "SwitchProducer"), p.values["sp"][1].values["@module_type"])
3667  self.assertEqual((True, "sp"), p.values["sp"][1].values["@module_label"])
3668  all_cases = copy.deepcopy(p.values["sp"][1].values["@all_cases"])
3669  all_cases[1].sort()
3670  self.assertEqual((True, ["sp@test1", "sp@test2"]), all_cases)
3671  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
3672  self.assertEqual(["a", "sp", "sp@test2"], p.values["@all_modules"][1])
3673  self.assertEqual(["sp@test1"], p.values["@all_aliases"][1])
3674  self.assertEqual((True,"EDProducer"), p.values["sp@test2"][1].values["@module_edm_type"])
3675  self.assertEqual((True,"Foo"), p.values["sp@test2"][1].values["@module_type"])
3676  self.assertEqual((True,"EDAlias"), p.values["sp@test1"][1].values["@module_edm_type"])
3677  self.assertEqual((True,"Bar"), p.values["sp@test1"][1].values["a"][1][0].values["type"])
3678 
3679  # EDAlias as chosen case
3680  proc = Process("test")
3681  proc.sp = SwitchProducerTest(test1 = EDProducer("Foo",
3682  a = int32(1),
3683  b = PSet(c = int32(2))),
3684  test2 = EDAlias(a = VPSet(PSet(type = string("Bar")))))
3685  proc.a = EDProducer("A")
3686  proc.s = Sequence(proc.a + proc.sp)
3687  proc.t = Task(proc.a, proc.sp)
3688  proc.p = Path()
3689  proc.p.associate(proc.t)
3690  p = TestMakePSet()
3691  proc.fillProcessDesc(p)
3692  self.assertEqual((True,"EDProducer"), p.values["sp"][1].values["@module_edm_type"])
3693  self.assertEqual((True, "SwitchProducer"), p.values["sp"][1].values["@module_type"])
3694  self.assertEqual((True, "sp"), p.values["sp"][1].values["@module_label"])
3695  self.assertEqual((True, ["sp@test1", "sp@test2"]), p.values["sp"][1].values["@all_cases"])
3696  self.assertEqual((False, "sp@test2"), p.values["sp"][1].values["@chosen_case"])
3697  self.assertEqual(["a", "sp", "sp@test1"], p.values["@all_modules"][1])
3698  self.assertEqual(["sp@test2"], p.values["@all_aliases"][1])
3699  self.assertEqual((True,"EDProducer"), p.values["sp@test1"][1].values["@module_edm_type"])
3700  self.assertEqual((True,"Foo"), p.values["sp@test1"][1].values["@module_type"])
3701  self.assertEqual((True,"EDAlias"), p.values["sp@test2"][1].values["@module_edm_type"])
3702  self.assertEqual((True,"Bar"), p.values["sp@test2"][1].values["a"][1][0].values["type"])
3703 
3704  # ConditionalTask
3705  proc = Process("test")
3706  proc.spct = SwitchProducerTest(test2 = EDProducer("Foo",
3707  a = int32(1),
3708  b = PSet(c = int32(2))),
3709  test1 = EDProducer("Bar",
3710  aa = int32(11),
3711  bb = PSet(cc = int32(12))),
3712  test3 = EDAlias(a = VPSet(PSet(type = string("Bar")))))
3713  proc.spp = proc.spct.clone()
3714  proc.a = EDProducer("A")
3715  proc.ct = ConditionalTask(proc.spct)
3716  proc.p = Path(proc.a, proc.ct)
3717  proc.pp = Path(proc.a + proc.spp)
3718  p = TestMakePSet()
3719  proc.fillProcessDesc(p)
3720  self.assertEqual(["a", "spct", "spct@test1", "spct@test2", "spp", "spp@test1", "spp@test2"], p.values["@all_modules"][1])
3721  self.assertEqual(["a", "#", "spct", "spct@test1", "spct@test2", "@"], p.values["p"][1])
3722  self.assertEqual(["a", "spp", "#", "spp@test1", "spp@test2", "@"], p.values["pp"][1])
3723 

◆ testTask()

def Config.TestModuleCommand.testTask (   self)

Definition at line 2761 of file Config.py.

2761  def testTask(self):
2762 
2763  # create some objects to use in tests
2764  edanalyzer = EDAnalyzer("a")
2765  edproducer = EDProducer("b")
2766  edproducer2 = EDProducer("b2")
2767  edproducer3 = EDProducer("b3")
2768  edproducer4 = EDProducer("b4")
2769  edproducer8 = EDProducer("b8")
2770  edproducer9 = EDProducer("b9")
2771  edfilter = EDFilter("c")
2772  service = Service("d")
2773  service3 = Service("d", v = untracked.uint32(3))
2774  essource = ESSource("e")
2775  esproducer = ESProducer("f")
2776  testTask2 = Task()
2777 
2778  # test adding things to Tasks
2779  testTask1 = Task(edproducer, edfilter)
2780  self.assertRaises(RuntimeError, testTask1.add, edanalyzer)
2781  testTask1.add(essource, service)
2782  testTask1.add(essource, esproducer)
2783  testTask1.add(testTask2)
2784  coll = testTask1._collection
2785  self.assertTrue(edproducer in coll)
2786  self.assertTrue(edfilter in coll)
2787  self.assertTrue(service in coll)
2788  self.assertTrue(essource in coll)
2789  self.assertTrue(esproducer in coll)
2790  self.assertTrue(testTask2 in coll)
2791  self.assertTrue(len(coll) == 6)
2792  self.assertTrue(len(testTask2._collection) == 0)
2793 
2794  taskContents = []
2795  for i in testTask1:
2796  taskContents.append(i)
2797  self.assertTrue(taskContents == [edproducer, edfilter, essource, service, esproducer, testTask2])
2798 
2799  # test attaching Task to Process
2800  process = Process("test")
2801 
2802  process.mproducer = edproducer
2803  process.mproducer2 = edproducer2
2804  process.mfilter = edfilter
2805  process.messource = essource
2806  process.mesproducer = esproducer
2807  process.d = service
2808 
2809  testTask3 = Task(edproducer, edproducer2)
2810  testTask1.add(testTask3)
2811  process.myTask1 = testTask1
2812 
2813  # test the validation that occurs when attaching a Task to a Process
2814  # first a case that passes, then one the fails on an EDProducer
2815  # then one that fails on a service
2816  l = set()
2817  visitor = NodeNameVisitor(l)
2818  testTask1.visit(visitor)
2819  self.assertTrue(l == set(['mesproducer', 'mproducer', 'mproducer2', 'mfilter', 'd', 'messource']))
2820  l2 = testTask1.moduleNames
2821  self.assertTrue(l == set(['mesproducer', 'mproducer', 'mproducer2', 'mfilter', 'd', 'messource']))
2822 
2823  testTask4 = Task(edproducer3)
2824  l.clear()
2825  self.assertRaises(RuntimeError, testTask4.visit, visitor)
2826  try:
2827  process.myTask4 = testTask4
2828  self.assertTrue(False)
2829  except RuntimeError:
2830  pass
2831 
2832  testTask5 = Task(service3)
2833  l.clear()
2834  self.assertRaises(RuntimeError, testTask5.visit, visitor)
2835  try:
2836  process.myTask5 = testTask5
2837  self.assertTrue(False)
2838  except RuntimeError:
2839  pass
2840 
2841  process.d = service3
2842  process.myTask5 = testTask5
2843 
2844  # test placement into the Process and the tasks property
2845  expectedDict = { 'myTask1' : testTask1, 'myTask5' : testTask5 }
2846  expectedFixedDict = DictTypes.FixedKeysDict(expectedDict);
2847  self.assertTrue(process.tasks == expectedFixedDict)
2848  self.assertTrue(process.tasks['myTask1'] == testTask1)
2849  self.assertTrue(process.myTask1 == testTask1)
2850 
2851  # test replacing an EDProducer in a Task when calling __settattr__
2852  # for the EDProducer on the Process.
2853  process.mproducer2 = edproducer4
2854  process.d = service
2855  l = list()
2856  visitor1 = ModuleNodeVisitor(l)
2857  testTask1.visit(visitor1)
2858  l.sort(key=lambda mod: mod.__str__())
2859  expectedList = sorted([edproducer,essource,esproducer,service,edfilter,edproducer,edproducer4],key=lambda mod: mod.__str__())
2860  self.assertTrue(expectedList == l)
2861  process.myTask6 = Task()
2862  process.myTask7 = Task()
2863  process.mproducer8 = edproducer8
2864  process.myTask8 = Task(process.mproducer8)
2865  process.myTask6.add(process.myTask7)
2866  process.myTask7.add(process.myTask8)
2867  process.myTask1.add(process.myTask6)
2868  process.myTask8.add(process.myTask5)
2869 
2870  testDict = process._itemsInDependencyOrder(process.tasks)
2871  expectedLabels = ["myTask5", "myTask8", "myTask7", "myTask6", "myTask1"]
2872  expectedTasks = [process.myTask5, process.myTask8, process.myTask7, process.myTask6, process.myTask1]
2873  index = 0
2874  for testLabel, testTask in testDict.items():
2875  self.assertTrue(testLabel == expectedLabels[index])
2876  self.assertTrue(testTask == expectedTasks[index])
2877  index += 1
2878 
2879  pythonDump = testTask1.dumpPython(PrintOptions())
2880 
2881 
2882  expectedPythonDump = 'cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer, process.mproducer2, process.myTask6)\n'
2883  self.assertTrue(pythonDump == expectedPythonDump)
2884 
2885  process.myTask5 = Task()
2886  process.myTask100 = Task()
2887  process.mproducer9 = edproducer9
2888  sequence1 = Sequence(process.mproducer8, process.myTask1, process.myTask5, testTask2, testTask3)
2889  sequence2 = Sequence(process.mproducer8 + process.mproducer9)
2890  process.sequence3 = Sequence((process.mproducer8 + process.mfilter))
2891  sequence4 = Sequence()
2892  process.path1 = Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+sequence4)
2893  process.path1.associate(process.myTask1, process.myTask5, testTask2, testTask3)
2894  process.path11 = Path(process.mproducer+process.mproducer8+sequence1+sequence2+process.sequence3+ sequence4,process.myTask1, process.myTask5, testTask2, testTask3, process.myTask100)
2895  process.path2 = Path(process.mproducer)
2896  process.path3 = Path(process.mproducer9+process.mproducer8,testTask2)
2897 
2898  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')
2899 
2900  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')
2901 
2902  # test NodeNameVisitor and moduleNames
2903  l = set()
2904  nameVisitor = NodeNameVisitor(l)
2905  process.path1.visit(nameVisitor)
2906  self.assertTrue(l == set(['mproducer', 'd', 'mesproducer', None, 'mproducer9', 'mproducer8', 'messource', 'mproducer2', 'mfilter']))
2907  self.assertTrue(process.path1.moduleNames() == set(['mproducer', 'd', 'mesproducer', None, 'mproducer9', 'mproducer8', 'messource', 'mproducer2', 'mfilter']))
2908 
2909  # test copy
2910  process.mproducer10 = EDProducer("b10")
2911  process.path21 = process.path11.copy()
2912  process.path21.replace(process.mproducer, process.mproducer10)
2913 
2914  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')
2915 
2916  # Some peculiarities of the way things work show up here. dumpPython sorts tasks and
2917  # removes duplication at the level of strings. The Task and Sequence objects themselves
2918  # remove duplicate tasks in their contents if the instances are the same (exact same python
2919  # object id which is not the same as the string representation being the same).
2920  # Also note that the mutating visitor replaces sequences and tasks that have
2921  # modified contents with their modified contents, it does not modify the sequence
2922  # or task itself.
2923  self.assertTrue(process.path21.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
2924 
2925  process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
2926  self.assertTrue(process.path22.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.messource, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
2927 
2928  process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
2929  self.assertTrue(process.path23.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None), cms.Task(process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')
2930 
2931  process.a = EDAnalyzer("MyAnalyzer")
2932  process.b = OutputModule("MyOutputModule")
2933  process.c = EDFilter("MyFilter")
2934  process.d = EDProducer("MyProducer")
2935  process.e = ESProducer("MyESProducer")
2936  process.f = ESSource("MyESSource")
2937  process.g = ESProducer("g")
2938  process.path24 = Path(process.a+process.b+process.c+process.d)
2939  process.path25 = process.path24.copyAndExclude([process.a,process.b,process.c])
2940  self.assertTrue(process.path25.dumpPython() == 'cms.Path(process.d)\n')
2941  #print process.path3
2942  #print process.dumpPython()
2943 
2944  process.path200 = EndPath(Sequence(process.c,Task(process.e)))
2945  process.path200.replace(process.c,process.b)
2946  process.path200.replace(process.e,process.f)
2947  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.b, cms.Task(process.f))\n")
2948  process.path200.replace(process.b,process.c)
2949  process.path200.replace(process.f,process.e)
2950  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.c, cms.Task(process.e))\n")
2951  process.path200.replace(process.c,process.a)
2952  process.path200.replace(process.e,process.g)
2953  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.a, cms.Task(process.g))\n")
2954  process.path200.replace(process.a,process.c)
2955  process.path200.replace(process.g,process.e)
2956  self.assertEqual(process.path200.dumpPython(), "cms.EndPath(process.c, cms.Task(process.e))\n")
2957 
testTask
Definition: TestTask.py:3

◆ testTaskPlaceholder()

def Config.TestModuleCommand.testTaskPlaceholder (   self)

Definition at line 3887 of file Config.py.

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

3887  def testTaskPlaceholder(self):
3888  p = Process("test")
3889  p.a = EDProducer("ma")
3890  p.b = EDAnalyzer("mb")
3891  p.t1 = Task(TaskPlaceholder("c"))
3892  p.t2 = Task(p.a, TaskPlaceholder("d"), p.t1)
3893  p.t3 = Task(TaskPlaceholder("e"))
3894  p.path1 = Path(p.b, p.t2, p.t3)
3895  p.t5 = Task(p.a, TaskPlaceholder("g"), TaskPlaceholder("t4"))
3896  p.t4 = Task(TaskPlaceholder("f"))
3897  p.endpath1 = EndPath(p.b, p.t5)
3898  p.t6 = Task(TaskPlaceholder("h"))
3899  p.t7 = Task(p.a, TaskPlaceholder("i"), p.t6)
3900  p.t8 = Task(TaskPlaceholder("j"))
3901  p.schedule = Schedule(p.path1, p.endpath1,tasks=[p.t7,p.t8])
3902  p.c = EDProducer("mc")
3903  p.d = EDProducer("md")
3904  p.e = EDProducer("me")
3905  p.f = EDProducer("mf")
3906  p.g = EDProducer("mg")
3907  p.h = EDProducer("mh")
3908  p.i = EDProducer("mi")
3909  p.j = EDProducer("mj")
3910  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),
3911 """process.a = cms.EDProducer("ma")
3912 process.c = cms.EDProducer("mc")
3913 process.d = cms.EDProducer("md")
3914 process.e = cms.EDProducer("me")
3915 process.f = cms.EDProducer("mf")
3916 process.g = cms.EDProducer("mg")
3917 process.h = cms.EDProducer("mh")
3918 process.i = cms.EDProducer("mi")
3919 process.j = cms.EDProducer("mj")
3920 process.b = cms.EDAnalyzer("mb")
3921 process.t1 = cms.Task(cms.TaskPlaceholder("c"))
3922 process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1)
3923 process.t3 = cms.Task(cms.TaskPlaceholder("e"))
3924 process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a)
3925 process.t4 = cms.Task(cms.TaskPlaceholder("f"))
3926 process.t6 = cms.Task(cms.TaskPlaceholder("h"))
3927 process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6)
3928 process.t8 = cms.Task(cms.TaskPlaceholder("j"))
3929 process.path1 = cms.Path(process.b, process.t2, process.t3)
3930 process.endpath1 = cms.EndPath(process.b, process.t5)
3931 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
3932  p.resolve()
3933  self.assertEqual(_lineDiff(p.dumpPython(),Process('test').dumpPython()),
3934 """process.a = cms.EDProducer("ma")
3935 process.c = cms.EDProducer("mc")
3936 process.d = cms.EDProducer("md")
3937 process.e = cms.EDProducer("me")
3938 process.f = cms.EDProducer("mf")
3939 process.g = cms.EDProducer("mg")
3940 process.h = cms.EDProducer("mh")
3941 process.i = cms.EDProducer("mi")
3942 process.j = cms.EDProducer("mj")
3943 process.b = cms.EDAnalyzer("mb")
3944 process.t1 = cms.Task(process.c)
3945 process.t2 = cms.Task(process.a, process.d, process.t1)
3946 process.t3 = cms.Task(process.e)
3947 process.t4 = cms.Task(process.f)
3948 process.t6 = cms.Task(process.h)
3949 process.t7 = cms.Task(process.a, process.i, process.t6)
3950 process.t8 = cms.Task(process.j)
3951 process.t5 = cms.Task(process.a, process.g, process.t4)
3952 process.path1 = cms.Path(process.b, process.t2, process.t3)
3953 process.endpath1 = cms.EndPath(process.b, process.t5)
3954 process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
def _lineDiff(newString, oldString)
Definition: Config.py:2021
def dumpPython(process, name)

◆ testTypedParameterizable()

def Config.TestModuleCommand.testTypedParameterizable (   self)

Definition at line 2208 of file Config.py.

2208  def testTypedParameterizable(self):
2209  p = _TypedParameterizable("blah", b=int32(1))
2210  #see if copy works deeply
2211  other = p.copy()
2212  other.b = 2
2213  self.assertNotEqual(p.b,other.b)
2214 

◆ testUsing()

def Config.TestModuleCommand.testUsing (   self)

Definition at line 3458 of file Config.py.

3458  def testUsing(self):
3459  p = Process('test')
3460  p.block = PSet(a = int32(1))
3461  p.modu = EDAnalyzer('Analyzer', p.block, b = int32(2))
3462  self.assertEqual(p.modu.a.value(),1)
3463  self.assertEqual(p.modu.b.value(),2)
3464 

Member Data Documentation

◆ a

Config.TestModuleCommand.a
static

Definition at line 2511 of file Config.py.

◆ b

Config.TestModuleCommand.b
static

Definition at line 2528 of file Config.py.

◆ c

Config.TestModuleCommand.c
static

Definition at line 2529 of file Config.py.

◆ d

Config.TestModuleCommand.d
static

Definition at line 2517 of file Config.py.

◆ e

Config.TestModuleCommand.e
static

Definition at line 2531 of file Config.py.

◆ f

Config.TestModuleCommand.f
static

Definition at line 2532 of file Config.py.

◆ g

Config.TestModuleCommand.g
static

Definition at line 2533 of file Config.py.

◆ p

Config.TestModuleCommand.p
static

Definition at line 2510 of file Config.py.

Referenced by Electron.Electron.ptErr().

◆ p2

Config.TestModuleCommand.p2
static

Definition at line 2515 of file Config.py.

◆ proc_mod_

Config.TestModuleCommand.proc_mod_

Definition at line 4181 of file Config.py.

◆ process

Config.TestModuleCommand.process
static

◆ r

Config.TestModuleCommand.r
static

Definition at line 2514 of file Config.py.

◆ s

Config.TestModuleCommand.s
static

Definition at line 2513 of file Config.py.

◆ s1

Config.TestModuleCommand.s1
static

Definition at line 2634 of file Config.py.

◆ s2

Config.TestModuleCommand.s2
static

Definition at line 2624 of file Config.py.

◆ s3

Config.TestModuleCommand.s3
static

Definition at line 2636 of file Config.py.

◆ schedule

Config.TestModuleCommand.schedule
static

Definition at line 2516 of file Config.py.

◆ task1

Config.TestModuleCommand.task1
static

Definition at line 2538 of file Config.py.

◆ task2

Config.TestModuleCommand.task2
static

Definition at line 2536 of file Config.py.

◆ task3

Config.TestModuleCommand.task3
static

Definition at line 2535 of file Config.py.

◆ task4

Config.TestModuleCommand.task4
static

Definition at line 2537 of file Config.py.

◆ task5

Config.TestModuleCommand.task5
static

Definition at line 2534 of file Config.py.

◆ tasks

Config.TestModuleCommand.tasks
static

Definition at line 2544 of file Config.py.