4213 def testModifier(self):
4215 Process._firstProcess =
True 4217 self.assertRaises(RuntimeError,
lambda:
Process(
"test2", m1))
4219 Process._firstProcess =
True 4221 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4224 m1.toModify(p.a,_mod_fred)
4225 self.assertEqual(p.a.fred.value(),2)
4226 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4227 m1.toModify(p.b, wilma = 2)
4228 self.assertEqual(p.b.wilma.value(),2)
4229 self.assertTrue(p.isUsingModifier(m1))
4232 Process._firstProcess =
True 4234 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4235 m1.toModify(p.a,_mod_fred)
4236 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4237 m1.toModify(p.b, wilma = 2)
4238 self.assertEqual(p.a.fred.value(),1)
4239 self.assertEqual(p.b.wilma.value(),1)
4240 self.assertEqual(p.isUsingModifier(m1),
False)
4243 Process._firstProcess =
True 4245 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4246 m1.toModify(p.a, fred = int32(2))
4247 p.b = p.a.clone(wilma = int32(3))
4248 self.assertEqual(p.a.fred.value(),2)
4249 self.assertEqual(p.a.wilma.value(),1)
4250 self.assertEqual(p.b.fred.value(),2)
4251 self.assertEqual(p.b.wilma.value(),3)
4254 Process._firstProcess =
True 4256 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1), fintstones =
PSet(fred = int32(1)))
4257 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
4258 self.assertEqual(hasattr(p.a,
"fred"),
False)
4259 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
4260 self.assertEqual(p.a.wilma.value(),1)
4263 Process._firstProcess =
True 4265 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4266 m1.toModify(p.a, wilma = int32(2))
4267 self.assertEqual(p.a.fred.value(), 1)
4268 self.assertEqual(p.a.wilma.value(),2)
4271 Process._firstProcess =
True 4273 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
PSet(fred = int32(1), wilma = int32(1)))
4274 m1.toModify(p.a, flintstones = dict(fred = int32(2)))
4275 self.assertEqual(p.a.flintstones.fred.value(),2)
4276 self.assertEqual(p.a.flintstones.wilma.value(),1)
4279 Process._firstProcess =
True 4281 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
PSet(fred =
PSet(wilma = int32(1))))
4282 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4283 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
4286 Process._firstProcess =
True 4288 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(
PSet(fred = int32(1)),
PSet(wilma = int32(1))))
4289 m1.toModify(p.a, flintstones = {1:dict(wilma = int32(2))})
4290 self.assertEqual(p.a.flintstones[0].fred.value(),1)
4291 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4294 Process._firstProcess =
True 4296 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4297 m1.toModify(p.a, fred = {1:7})
4298 self.assertEqual(p.a.fred[0],1)
4299 self.assertEqual(p.a.fred[1],7)
4300 self.assertEqual(p.a.fred[2],3)
4303 Process._firstProcess =
True 4305 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4307 try: m1.toModify(p.a, fred = {5:7})
4308 except IndexError
as e: raised =
True 4309 self.assertEqual(raised,
True)
4312 Process._firstProcess =
True 4314 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(
PSet(fred = int32(1)),
PSet(wilma = int32(1))))
4316 try: m1.toModify(p.a, flintstones = dict(bogus = int32(37)))
4317 except TypeError
as e: raised =
True 4318 self.assertEqual(raised,
True)
4322 class ProcModifierMod(
object):
4324 self.proc_mod_ = modifier.makeProcessModifier(func)
4327 self.a = EDAnalyzer(
"Dummy")
4328 testMod = DummyMod()
4330 self.assertTrue(hasattr(p,
"a"))
4332 Process._firstProcess =
True 4334 testProcMod = ProcModifierMod(m1,_rem_a)
4336 p.extend(testProcMod)
4337 self.assertTrue(
not hasattr(p,
"a"))
4340 mc = ModifierChain(m1)
4341 Process._firstProcess =
True 4343 self.assertTrue(p.isUsingModifier(m1))
4344 self.assertTrue(p.isUsingModifier(mc))
4345 testMod = DummyMod()
4346 p.b = EDAnalyzer(
"Dummy2", fred = int32(1))
4347 m1.toModify(p.b, fred = int32(3))
4349 testProcMod = ProcModifierMod(m1,_rem_a)
4350 p.extend(testProcMod)
4351 self.assertTrue(
not hasattr(p,
"a"))
4352 self.assertEqual(p.b.fred.value(),3)
4356 mc = ModifierChain(m1,m2)
4357 mclone = mc.copyAndExclude([m2])
4358 self.assertTrue(
not mclone._isOrContains(m2))
4359 self.assertTrue(mclone._isOrContains(m1))
4361 mc2 = ModifierChain(mc,m3)
4362 mclone = mc2.copyAndExclude([m2])
4363 self.assertTrue(
not mclone._isOrContains(m2))
4364 self.assertTrue(mclone._isOrContains(m1))
4365 self.assertTrue(mclone._isOrContains(m3))
4369 Process._firstProcess =
True 4371 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4372 (m1 & m2).toModify(p.a, fred = int32(2))
4373 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4374 self.assertEqual(p.a.fred, 1)
4377 Process._firstProcess =
True 4379 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4380 (m1 & m2).toModify(p.a, fred = int32(2))
4381 self.assertEqual(p.a.fred, 2)
4385 Process._firstProcess =
True 4387 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4388 (m1 & m2 & m3).toModify(p.a, fred = int32(2))
4389 self.assertEqual(p.a.fred, 2)
4390 (m1 & (m2 & m3)).toModify(p.a, fred = int32(3))
4391 self.assertEqual(p.a.fred, 3)
4392 ((m1 & m2) & m3).toModify(p.a, fred = int32(4))
4393 self.assertEqual(p.a.fred, 4)
4397 Process._firstProcess =
True 4399 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4400 (~m1).toModify(p.a, fred=2)
4401 self.assertEqual(p.a.fred, 1)
4402 (~m2).toModify(p.a, wilma=2)
4403 self.assertEqual(p.a.wilma, 2)
4404 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
4405 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
4410 Process._firstProcess =
True 4412 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4413 (m1 | m2).toModify(p.a, fred=2)
4414 self.assertEqual(p.a.fred, 2)
4415 (m1 | m2 | m3).toModify(p.a, fred=3)
4416 self.assertEqual(p.a.fred, 3)
4417 (m3 | m2 | m1).toModify(p.a, fred=4)
4418 self.assertEqual(p.a.fred, 4)
4419 ((m1 | m2) | m3).toModify(p.a, fred=5)
4420 self.assertEqual(p.a.fred, 5)
4421 (m1 | (m2 | m3)).toModify(p.a, fred=6)
4422 self.assertEqual(p.a.fred, 6)
4423 (m2 | m3).toModify(p.a, fred=7)
4424 self.assertEqual(p.a.fred, 6)
4425 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4426 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4432 Process._firstProcess =
True 4434 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4435 (m1 & ~m2).toModify(p.a, fred=2)
4436 self.assertEqual(p.a.fred, 1)
4437 (m1 & ~m3).toModify(p.a, fred=2)
4438 self.assertEqual(p.a.fred, 2)
4439 (m1 | ~m2).toModify(p.a, fred=3)
4440 self.assertEqual(p.a.fred, 3)
4441 (~m1 | ~m2).toModify(p.a, fred=4)
4442 self.assertEqual(p.a.fred, 3)
4443 (~m3 & ~m4).toModify(p.a, fred=4)
4444 self.assertEqual(p.a.fred, 4)
4445 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4446 self.assertEqual(p.a.fred, 5)
4449 Process._firstProcess =
True 4451 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4452 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4453 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a, EDProducer(
"YourProducer")))
4455 p.b =EDAnalyzer(
"BAn")
4456 p.c =EDProducer(
"c")
4457 p.d =EDProducer(
"d")
4461 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4462 self.assertEqual(p.a.wilma.value(),3)
4463 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4464 self.assertEqual(hasattr(p,
"fred"),
False)
4465 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4466 p.e =EDProducer(
"e")
4467 m1.toReplaceWith(p.td, Task(p.e))
4468 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4470 p.b =EDAnalyzer(
"BAn")
4471 p.c =EDProducer(
"c")
4472 p.d =EDProducer(
"d")
4475 p.tc = ConditionalTask(p.c)
4476 p.td = ConditionalTask(p.d)
4478 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4479 self.assertEqual(p.a.wilma.value(),3)
4480 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4481 self.assertEqual(hasattr(p,
"fred"),
False)
4482 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4483 p.e =EDProducer(
"e")
4484 m1.toReplaceWith(p.td, ConditionalTask(p.e))
4485 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4488 Process._firstProcess =
True 4490 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4491 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4492 self.assertEqual(p.a.type_(),
"MyAnalyzer")
4498 Process._firstProcess =
True 4500 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4501 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4502 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4503 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4504 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4505 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4506 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4507 (m1 & m2).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer1"))
4508 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4509 (m1 & m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4510 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4511 (~m1).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4512 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4513 (~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4514 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
4515 (m1 | m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer3"))
4516 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4517 (m3 | m4).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer4"))
4518 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4523 Process._firstProcess =
True 4525 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4526 p.b = EDProducer(
"MyProducer", barney = int32(1), betty = int32(1))
4527 (m1 & m2).toModify(p.a, fred = 2).toModify(p.b, betty = 3)
4528 self.assertEqual(p.a.fred, 2)
4529 self.assertEqual(p.a.wilma, 1)
4530 self.assertEqual(p.b.barney, 1)
4531 self.assertEqual(p.b.betty, 3)
4532 (m1 | m3).toModify(p.a, wilma = 4).toModify(p.b, barney = 5)
4533 self.assertEqual(p.a.fred, 2)
4534 self.assertEqual(p.a.wilma, 4)
4535 self.assertEqual(p.b.barney, 5)
4536 self.assertEqual(p.b.betty, 3)
4537 (m2 & ~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer")).toModify(p.b, barney = 6)
4538 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4539 self.assertEqual(p.b.barney, 6)
4540 self.assertEqual(p.b.betty, 3)
4541 (m1 & ~m3).toModify(p.a, param=int32(42)).toReplaceWith(p.b, EDProducer(
"YourProducer"))
4542 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4543 self.assertEqual(p.a.param, 42)
4544 self.assertEqual(p.b.type_(),
"YourProducer")
4551 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
4552 self.assertEqual(a.foo2[0].type,
"Foo3")
4555 self.assertEqual(a.foo2[0].type,
"Foo3")
4556 self.assertEqual(a.foo4[0].type,
"Foo4")
4558 m.toModify(a, foo2 =
None)
4559 self.assertFalse(hasattr(a,
"foo2"))
4560 self.assertEqual(a.foo4[0].type,
"Foo4")
4563 self.assertFalse(hasattr(a,
"foo2"))
4564 self.assertFalse(hasattr(a,
"foo4"))
4565 self.assertTrue(hasattr(a,
"bar"))
4566 self.assertEqual(a.bar[0].type,
"Bar")
4569 sp = SwitchProducerTest(test1 = EDProducer(
"Foo",
4571 b =
PSet(c = int32(2))),
4572 test2 = EDProducer(
"Bar",
4574 bb =
PSet(cc = int32(12))))
4579 test1 = dict(a = 4, b = dict(c =
None)),
4580 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
4581 self.assertEqual(sp.test1.a.value(), 4)
4582 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
4583 self.assertEqual(sp.test2.aa.value(), 15)
4584 self.assertEqual(sp.test2.bb.cc.value(), 45)
4585 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
4587 m.toReplaceWith(sp.test1, EDProducer(
"Fred", x = int32(42)))
4588 self.assertEqual(sp.test1.type_(),
"Fred")
4589 self.assertEqual(sp.test1.x.value(), 42)
4590 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1, EDAnalyzer(
"Foo")))
4592 m.toModify(sp, test2 = EDProducer(
"Xyzzy", x = int32(24)))
4593 self.assertEqual(sp.test2.type_(),
"Xyzzy")
4594 self.assertEqual(sp.test2.x.value(), 24)
4595 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 = EDAnalyzer(
"Foo")))
4597 m.toModify(sp, test3 = EDProducer(
"Wilma", y = int32(24)))
4598 self.assertEqual(sp.test3.type_(),
"Wilma")
4599 self.assertEqual(sp.test3.y.value(), 24)
4600 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 = EDAnalyzer(
"Foo")))
4602 m.toModify(sp, test2 =
None)
4603 self.assertEqual(hasattr(sp,
"test2"),
False)
4605 m.toModify(sp, test2 = EDAlias(foo =
VPSet(
PSet(type =
string(
"int")))))
4606 self.assertTrue(hasattr(sp.test2,
"foo"))
4608 m.toReplaceWith(sp.test2, EDAlias(bar =
VPSet(
PSet(type =
string(
"int")))))
4609 self.assertTrue(hasattr(sp.test2,
"bar"))
4611 m.toModify(sp, test2 = EDAlias(xyzzy =
VPSet(
PSet(type =
string(
"int")))))
4612 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
4614 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2, EDProducer(
"Foo")))
4615 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)