4185 def testModifier(self):
4187 Process._firstProcess =
True 4189 self.assertRaises(RuntimeError,
lambda:
Process(
"test2", m1))
4191 Process._firstProcess =
True 4193 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4196 m1.toModify(p.a,_mod_fred)
4197 self.assertEqual(p.a.fred.value(),2)
4198 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4199 m1.toModify(p.b, wilma = 2)
4200 self.assertEqual(p.b.wilma.value(),2)
4201 self.assertTrue(p.isUsingModifier(m1))
4204 Process._firstProcess =
True 4206 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4207 m1.toModify(p.a,_mod_fred)
4208 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4209 m1.toModify(p.b, wilma = 2)
4210 self.assertEqual(p.a.fred.value(),1)
4211 self.assertEqual(p.b.wilma.value(),1)
4212 self.assertEqual(p.isUsingModifier(m1),
False)
4215 Process._firstProcess =
True 4217 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4218 m1.toModify(p.a, fred = int32(2))
4219 p.b = p.a.clone(wilma = int32(3))
4220 self.assertEqual(p.a.fred.value(),2)
4221 self.assertEqual(p.a.wilma.value(),1)
4222 self.assertEqual(p.b.fred.value(),2)
4223 self.assertEqual(p.b.wilma.value(),3)
4226 Process._firstProcess =
True 4228 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1), fintstones = PSet(fred = int32(1)))
4229 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
4230 self.assertEqual(hasattr(p.a,
"fred"),
False)
4231 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
4232 self.assertEqual(p.a.wilma.value(),1)
4235 Process._firstProcess =
True 4237 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4238 m1.toModify(p.a, wilma = int32(2))
4239 self.assertEqual(p.a.fred.value(), 1)
4240 self.assertEqual(p.a.wilma.value(),2)
4243 Process._firstProcess =
True 4245 p.a = EDAnalyzer(
"MyAnalyzer", flintstones = PSet(fred = int32(1), wilma = int32(1)))
4246 m1.toModify(p.a, flintstones = dict(fred = int32(2)))
4247 self.assertEqual(p.a.flintstones.fred.value(),2)
4248 self.assertEqual(p.a.flintstones.wilma.value(),1)
4251 Process._firstProcess =
True 4253 p.a = EDAnalyzer(
"MyAnalyzer", flintstones = PSet(fred = PSet(wilma = int32(1))))
4254 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4255 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
4258 Process._firstProcess =
True 4260 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
4261 m1.toModify(p.a, flintstones = {1:dict(wilma = int32(2))})
4262 self.assertEqual(p.a.flintstones[0].fred.value(),1)
4263 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4266 Process._firstProcess =
True 4268 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4269 m1.toModify(p.a, fred = {1:7})
4270 self.assertEqual(p.a.fred[0],1)
4271 self.assertEqual(p.a.fred[1],7)
4272 self.assertEqual(p.a.fred[2],3)
4275 Process._firstProcess =
True 4277 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4279 try: m1.toModify(p.a, fred = {5:7})
4280 except IndexError
as e: raised =
True 4281 self.assertEqual(raised,
True)
4284 Process._firstProcess =
True 4286 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
4288 try: m1.toModify(p.a, flintstones = dict(bogus = int32(37)))
4289 except TypeError
as e: raised =
True 4290 self.assertEqual(raised,
True)
4294 class ProcModifierMod(
object):
4296 self.proc_mod_ = modifier.makeProcessModifier(func)
4299 self.a = EDAnalyzer(
"Dummy")
4300 testMod = DummyMod()
4302 self.assertTrue(hasattr(p,
"a"))
4304 Process._firstProcess =
True 4306 testProcMod = ProcModifierMod(m1,_rem_a)
4308 p.extend(testProcMod)
4309 self.assertTrue(
not hasattr(p,
"a"))
4312 mc = ModifierChain(m1)
4313 Process._firstProcess =
True 4315 self.assertTrue(p.isUsingModifier(m1))
4316 self.assertTrue(p.isUsingModifier(mc))
4317 testMod = DummyMod()
4318 p.b = EDAnalyzer(
"Dummy2", fred = int32(1))
4319 m1.toModify(p.b, fred = int32(3))
4321 testProcMod = ProcModifierMod(m1,_rem_a)
4322 p.extend(testProcMod)
4323 self.assertTrue(
not hasattr(p,
"a"))
4324 self.assertEqual(p.b.fred.value(),3)
4328 mc = ModifierChain(m1,m2)
4329 mclone = mc.copyAndExclude([m2])
4330 self.assertTrue(
not mclone._isOrContains(m2))
4331 self.assertTrue(mclone._isOrContains(m1))
4333 mc2 = ModifierChain(mc,m3)
4334 mclone = mc2.copyAndExclude([m2])
4335 self.assertTrue(
not mclone._isOrContains(m2))
4336 self.assertTrue(mclone._isOrContains(m1))
4337 self.assertTrue(mclone._isOrContains(m3))
4341 Process._firstProcess =
True 4343 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4344 (m1 & m2).toModify(p.a, fred = int32(2))
4345 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4346 self.assertEqual(p.a.fred, 1)
4349 Process._firstProcess =
True 4351 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4352 (m1 & m2).toModify(p.a, fred = int32(2))
4353 self.assertEqual(p.a.fred, 2)
4357 Process._firstProcess =
True 4359 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4360 (m1 & m2 & m3).toModify(p.a, fred = int32(2))
4361 self.assertEqual(p.a.fred, 2)
4362 (m1 & (m2 & m3)).toModify(p.a, fred = int32(3))
4363 self.assertEqual(p.a.fred, 3)
4364 ((m1 & m2) & m3).toModify(p.a, fred = int32(4))
4365 self.assertEqual(p.a.fred, 4)
4369 Process._firstProcess =
True 4371 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4372 (~m1).toModify(p.a, fred=2)
4373 self.assertEqual(p.a.fred, 1)
4374 (~m2).toModify(p.a, wilma=2)
4375 self.assertEqual(p.a.wilma, 2)
4376 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
4377 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
4382 Process._firstProcess =
True 4384 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4385 (m1 | m2).toModify(p.a, fred=2)
4386 self.assertEqual(p.a.fred, 2)
4387 (m1 | m2 | m3).toModify(p.a, fred=3)
4388 self.assertEqual(p.a.fred, 3)
4389 (m3 | m2 | m1).toModify(p.a, fred=4)
4390 self.assertEqual(p.a.fred, 4)
4391 ((m1 | m2) | m3).toModify(p.a, fred=5)
4392 self.assertEqual(p.a.fred, 5)
4393 (m1 | (m2 | m3)).toModify(p.a, fred=6)
4394 self.assertEqual(p.a.fred, 6)
4395 (m2 | m3).toModify(p.a, fred=7)
4396 self.assertEqual(p.a.fred, 6)
4397 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4398 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4404 Process._firstProcess =
True 4406 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4407 (m1 & ~m2).toModify(p.a, fred=2)
4408 self.assertEqual(p.a.fred, 1)
4409 (m1 & ~m3).toModify(p.a, fred=2)
4410 self.assertEqual(p.a.fred, 2)
4411 (m1 | ~m2).toModify(p.a, fred=3)
4412 self.assertEqual(p.a.fred, 3)
4413 (~m1 | ~m2).toModify(p.a, fred=4)
4414 self.assertEqual(p.a.fred, 3)
4415 (~m3 & ~m4).toModify(p.a, fred=4)
4416 self.assertEqual(p.a.fred, 4)
4417 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4418 self.assertEqual(p.a.fred, 5)
4421 Process._firstProcess =
True 4423 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4424 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4425 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a, EDProducer(
"YourProducer")))
4427 p.b =EDAnalyzer(
"BAn")
4428 p.c =EDProducer(
"c")
4429 p.d =EDProducer(
"d")
4433 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4434 self.assertEqual(p.a.wilma.value(),3)
4435 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4436 self.assertEqual(hasattr(p,
"fred"),
False)
4437 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4438 p.e =EDProducer(
"e")
4439 m1.toReplaceWith(p.td, Task(p.e))
4440 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4442 p.b =EDAnalyzer(
"BAn")
4443 p.c =EDProducer(
"c")
4444 p.d =EDProducer(
"d")
4447 p.tc = ConditionalTask(p.c)
4448 p.td = ConditionalTask(p.d)
4450 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4451 self.assertEqual(p.a.wilma.value(),3)
4452 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4453 self.assertEqual(hasattr(p,
"fred"),
False)
4454 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4455 p.e =EDProducer(
"e")
4456 m1.toReplaceWith(p.td, ConditionalTask(p.e))
4457 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4460 Process._firstProcess =
True 4462 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4463 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4464 self.assertEqual(p.a.type_(),
"MyAnalyzer")
4470 Process._firstProcess =
True 4472 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4473 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4474 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4475 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4476 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4477 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4478 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4479 (m1 & m2).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer1"))
4480 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4481 (m1 & m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4482 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4483 (~m1).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4484 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4485 (~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4486 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
4487 (m1 | m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer3"))
4488 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4489 (m3 | m4).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer4"))
4490 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4495 Process._firstProcess =
True 4497 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4498 p.b = EDProducer(
"MyProducer", barney = int32(1), betty = int32(1))
4499 (m1 & m2).toModify(p.a, fred = 2).toModify(p.b, betty = 3)
4500 self.assertEqual(p.a.fred, 2)
4501 self.assertEqual(p.a.wilma, 1)
4502 self.assertEqual(p.b.barney, 1)
4503 self.assertEqual(p.b.betty, 3)
4504 (m1 | m3).toModify(p.a, wilma = 4).toModify(p.b, barney = 5)
4505 self.assertEqual(p.a.fred, 2)
4506 self.assertEqual(p.a.wilma, 4)
4507 self.assertEqual(p.b.barney, 5)
4508 self.assertEqual(p.b.betty, 3)
4509 (m2 & ~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer")).toModify(p.b, barney = 6)
4510 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4511 self.assertEqual(p.b.barney, 6)
4512 self.assertEqual(p.b.betty, 3)
4513 (m1 & ~m3).toModify(p.a, param=int32(42)).toReplaceWith(p.b, EDProducer(
"YourProducer"))
4514 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4515 self.assertEqual(p.a.param, 42)
4516 self.assertEqual(p.b.type_(),
"YourProducer")
4519 a = EDAlias(foo2 =
VPSet(PSet(type =
string(
"Foo2"))))
4523 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
4524 self.assertEqual(a.foo2[0].type,
"Foo3")
4526 m.toModify(a, foo4 =
VPSet(PSet(type =
string(
"Foo4"))))
4527 self.assertEqual(a.foo2[0].type,
"Foo3")
4528 self.assertEqual(a.foo4[0].type,
"Foo4")
4530 m.toModify(a, foo2 =
None)
4531 self.assertFalse(hasattr(a,
"foo2"))
4532 self.assertEqual(a.foo4[0].type,
"Foo4")
4534 m.toReplaceWith(a, EDAlias(bar =
VPSet(PSet(type =
string(
"Bar")))))
4535 self.assertFalse(hasattr(a,
"foo2"))
4536 self.assertFalse(hasattr(a,
"foo4"))
4537 self.assertTrue(hasattr(a,
"bar"))
4538 self.assertEqual(a.bar[0].type,
"Bar")
4541 sp = SwitchProducerTest(test1 = EDProducer(
"Foo",
4543 b = PSet(c = int32(2))),
4544 test2 = EDProducer(
"Bar",
4546 bb = PSet(cc = int32(12))))
4551 test1 = dict(a = 4, b = dict(c =
None)),
4552 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
4553 self.assertEqual(sp.test1.a.value(), 4)
4554 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
4555 self.assertEqual(sp.test2.aa.value(), 15)
4556 self.assertEqual(sp.test2.bb.cc.value(), 45)
4557 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
4559 m.toReplaceWith(sp.test1, EDProducer(
"Fred", x = int32(42)))
4560 self.assertEqual(sp.test1.type_(),
"Fred")
4561 self.assertEqual(sp.test1.x.value(), 42)
4562 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1, EDAnalyzer(
"Foo")))
4564 m.toModify(sp, test2 = EDProducer(
"Xyzzy", x = int32(24)))
4565 self.assertEqual(sp.test2.type_(),
"Xyzzy")
4566 self.assertEqual(sp.test2.x.value(), 24)
4567 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 = EDAnalyzer(
"Foo")))
4569 m.toModify(sp, test3 = EDProducer(
"Wilma", y = int32(24)))
4570 self.assertEqual(sp.test3.type_(),
"Wilma")
4571 self.assertEqual(sp.test3.y.value(), 24)
4572 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 = EDAnalyzer(
"Foo")))
4574 m.toModify(sp, test2 =
None)
4575 self.assertEqual(hasattr(sp,
"test2"),
False)
4577 m.toModify(sp, test2 = EDAlias(foo =
VPSet(PSet(type =
string(
"int")))))
4578 self.assertTrue(hasattr(sp.test2,
"foo"))
4580 m.toReplaceWith(sp.test2, EDAlias(bar =
VPSet(PSet(type =
string(
"int")))))
4581 self.assertTrue(hasattr(sp.test2,
"bar"))
4583 m.toModify(sp, test2 = EDAlias(xyzzy =
VPSet(PSet(type =
string(
"int")))))
4584 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
4586 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2, EDProducer(
"Foo")))
4587 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)