4174 def testModifier(self):
4176 Process._firstProcess =
True 4178 self.assertRaises(RuntimeError,
lambda:
Process(
"test2", m1))
4180 Process._firstProcess =
True 4182 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4185 m1.toModify(p.a,_mod_fred)
4186 self.assertEqual(p.a.fred.value(),2)
4187 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4188 m1.toModify(p.b, wilma = 2)
4189 self.assertEqual(p.b.wilma.value(),2)
4190 self.assertTrue(p.isUsingModifier(m1))
4193 Process._firstProcess =
True 4195 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4196 m1.toModify(p.a,_mod_fred)
4197 p.b = EDAnalyzer(
"YourAnalyzer", wilma = int32(1))
4198 m1.toModify(p.b, wilma = 2)
4199 self.assertEqual(p.a.fred.value(),1)
4200 self.assertEqual(p.b.wilma.value(),1)
4201 self.assertEqual(p.isUsingModifier(m1),
False)
4204 Process._firstProcess =
True 4206 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4207 m1.toModify(p.a, fred = int32(2))
4208 p.b = p.a.clone(wilma = int32(3))
4209 self.assertEqual(p.a.fred.value(),2)
4210 self.assertEqual(p.a.wilma.value(),1)
4211 self.assertEqual(p.b.fred.value(),2)
4212 self.assertEqual(p.b.wilma.value(),3)
4215 Process._firstProcess =
True 4217 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1), fintstones = PSet(fred = int32(1)))
4218 m1.toModify(p.a, fred =
None, fintstones = dict(fred =
None))
4219 self.assertEqual(hasattr(p.a,
"fred"),
False)
4220 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
4221 self.assertEqual(p.a.wilma.value(),1)
4224 Process._firstProcess =
True 4226 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4227 m1.toModify(p.a, wilma = int32(2))
4228 self.assertEqual(p.a.fred.value(), 1)
4229 self.assertEqual(p.a.wilma.value(),2)
4232 Process._firstProcess =
True 4234 p.a = EDAnalyzer(
"MyAnalyzer", flintstones = PSet(fred = int32(1), wilma = int32(1)))
4235 m1.toModify(p.a, flintstones = dict(fred = int32(2)))
4236 self.assertEqual(p.a.flintstones.fred.value(),2)
4237 self.assertEqual(p.a.flintstones.wilma.value(),1)
4240 Process._firstProcess =
True 4242 p.a = EDAnalyzer(
"MyAnalyzer", flintstones = PSet(fred = PSet(wilma = int32(1))))
4243 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
4244 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
4247 Process._firstProcess =
True 4249 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
4250 m1.toModify(p.a, flintstones = {1:dict(wilma = int32(2))})
4251 self.assertEqual(p.a.flintstones[0].fred.value(),1)
4252 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
4255 Process._firstProcess =
True 4257 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4258 m1.toModify(p.a, fred = {1:7})
4259 self.assertEqual(p.a.fred[0],1)
4260 self.assertEqual(p.a.fred[1],7)
4261 self.assertEqual(p.a.fred[2],3)
4264 Process._firstProcess =
True 4266 p.a = EDAnalyzer(
"MyAnalyzer", fred = vuint32(1,2,3))
4268 try: m1.toModify(p.a, fred = {5:7})
4269 except IndexError
as e: raised =
True 4270 self.assertEqual(raised,
True)
4273 Process._firstProcess =
True 4275 p.a = EDAnalyzer(
"MyAnalyzer", flintstones =
VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
4277 try: m1.toModify(p.a, flintstones = dict(bogus = int32(37)))
4278 except TypeError
as e: raised =
True 4279 self.assertEqual(raised,
True)
4283 class ProcModifierMod(
object):
4285 self.proc_mod_ = modifier.makeProcessModifier(func)
4288 self.a = EDAnalyzer(
"Dummy")
4289 testMod = DummyMod()
4291 self.assertTrue(hasattr(p,
"a"))
4293 Process._firstProcess =
True 4295 testProcMod = ProcModifierMod(m1,_rem_a)
4297 p.extend(testProcMod)
4298 self.assertTrue(
not hasattr(p,
"a"))
4301 mc = ModifierChain(m1)
4302 Process._firstProcess =
True 4304 self.assertTrue(p.isUsingModifier(m1))
4305 self.assertTrue(p.isUsingModifier(mc))
4306 testMod = DummyMod()
4307 p.b = EDAnalyzer(
"Dummy2", fred = int32(1))
4308 m1.toModify(p.b, fred = int32(3))
4310 testProcMod = ProcModifierMod(m1,_rem_a)
4311 p.extend(testProcMod)
4312 self.assertTrue(
not hasattr(p,
"a"))
4313 self.assertEqual(p.b.fred.value(),3)
4317 mc = ModifierChain(m1,m2)
4318 mclone = mc.copyAndExclude([m2])
4319 self.assertTrue(
not mclone._isOrContains(m2))
4320 self.assertTrue(mclone._isOrContains(m1))
4322 mc2 = ModifierChain(mc,m3)
4323 mclone = mc2.copyAndExclude([m2])
4324 self.assertTrue(
not mclone._isOrContains(m2))
4325 self.assertTrue(mclone._isOrContains(m1))
4326 self.assertTrue(mclone._isOrContains(m3))
4330 Process._firstProcess =
True 4332 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4333 (m1 & m2).toModify(p.a, fred = int32(2))
4334 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
4335 self.assertEqual(p.a.fred, 1)
4338 Process._firstProcess =
True 4340 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4341 (m1 & m2).toModify(p.a, fred = int32(2))
4342 self.assertEqual(p.a.fred, 2)
4346 Process._firstProcess =
True 4348 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4349 (m1 & m2 & m3).toModify(p.a, fred = int32(2))
4350 self.assertEqual(p.a.fred, 2)
4351 (m1 & (m2 & m3)).toModify(p.a, fred = int32(3))
4352 self.assertEqual(p.a.fred, 3)
4353 ((m1 & m2) & m3).toModify(p.a, fred = int32(4))
4354 self.assertEqual(p.a.fred, 4)
4358 Process._firstProcess =
True 4360 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4361 (~m1).toModify(p.a, fred=2)
4362 self.assertEqual(p.a.fred, 1)
4363 (~m2).toModify(p.a, wilma=2)
4364 self.assertEqual(p.a.wilma, 2)
4365 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
4366 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
4371 Process._firstProcess =
True 4373 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4374 (m1 | m2).toModify(p.a, fred=2)
4375 self.assertEqual(p.a.fred, 2)
4376 (m1 | m2 | m3).toModify(p.a, fred=3)
4377 self.assertEqual(p.a.fred, 3)
4378 (m3 | m2 | m1).toModify(p.a, fred=4)
4379 self.assertEqual(p.a.fred, 4)
4380 ((m1 | m2) | m3).toModify(p.a, fred=5)
4381 self.assertEqual(p.a.fred, 5)
4382 (m1 | (m2 | m3)).toModify(p.a, fred=6)
4383 self.assertEqual(p.a.fred, 6)
4384 (m2 | m3).toModify(p.a, fred=7)
4385 self.assertEqual(p.a.fred, 6)
4386 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
4387 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
4393 Process._firstProcess =
True 4395 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4396 (m1 & ~m2).toModify(p.a, fred=2)
4397 self.assertEqual(p.a.fred, 1)
4398 (m1 & ~m3).toModify(p.a, fred=2)
4399 self.assertEqual(p.a.fred, 2)
4400 (m1 | ~m2).toModify(p.a, fred=3)
4401 self.assertEqual(p.a.fred, 3)
4402 (~m1 | ~m2).toModify(p.a, fred=4)
4403 self.assertEqual(p.a.fred, 3)
4404 (~m3 & ~m4).toModify(p.a, fred=4)
4405 self.assertEqual(p.a.fred, 4)
4406 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
4407 self.assertEqual(p.a.fred, 5)
4410 Process._firstProcess =
True 4412 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4413 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4414 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a, EDProducer(
"YourProducer")))
4416 p.b =EDAnalyzer(
"BAn")
4417 p.c =EDProducer(
"c")
4418 p.d =EDProducer(
"d")
4422 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4423 self.assertEqual(p.a.wilma.value(),3)
4424 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4425 self.assertEqual(hasattr(p,
"fred"),
False)
4426 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4427 p.e =EDProducer(
"e")
4428 m1.toReplaceWith(p.td, Task(p.e))
4429 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4431 p.b =EDAnalyzer(
"BAn")
4432 p.c =EDProducer(
"c")
4433 p.d =EDProducer(
"d")
4436 p.tc = ConditionalTask(p.c)
4437 p.td = ConditionalTask(p.d)
4439 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
4440 self.assertEqual(p.a.wilma.value(),3)
4441 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4442 self.assertEqual(hasattr(p,
"fred"),
False)
4443 self.assertTrue(p.s.dumpPython() ==
"cms.Sequence(process.a+process.b, process.td)\n")
4444 p.e =EDProducer(
"e")
4445 m1.toReplaceWith(p.td, ConditionalTask(p.e))
4446 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
4449 Process._firstProcess =
True 4451 p.a =EDAnalyzer(
"MyAnalyzer", fred = int32(1))
4452 m1.toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer", wilma = int32(3)))
4453 self.assertEqual(p.a.type_(),
"MyAnalyzer")
4459 Process._firstProcess =
True 4461 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4462 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4463 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4464 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4465 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4466 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4467 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a, EDProducer(
"YourProducer")))
4468 (m1 & m2).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer1"))
4469 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4470 (m1 & m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4471 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4472 (~m1).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4473 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
4474 (~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer2"))
4475 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
4476 (m1 | m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer3"))
4477 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4478 (m3 | m4).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer4"))
4479 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
4484 Process._firstProcess =
True 4486 p.a = EDAnalyzer(
"MyAnalyzer", fred = int32(1), wilma = int32(1))
4487 p.b = EDProducer(
"MyProducer", barney = int32(1), betty = int32(1))
4488 (m1 & m2).toModify(p.a, fred = 2).toModify(p.b, betty = 3)
4489 self.assertEqual(p.a.fred, 2)
4490 self.assertEqual(p.a.wilma, 1)
4491 self.assertEqual(p.b.barney, 1)
4492 self.assertEqual(p.b.betty, 3)
4493 (m1 | m3).toModify(p.a, wilma = 4).toModify(p.b, barney = 5)
4494 self.assertEqual(p.a.fred, 2)
4495 self.assertEqual(p.a.wilma, 4)
4496 self.assertEqual(p.b.barney, 5)
4497 self.assertEqual(p.b.betty, 3)
4498 (m2 & ~m3).toReplaceWith(p.a, EDAnalyzer(
"YourAnalyzer")).toModify(p.b, barney = 6)
4499 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4500 self.assertEqual(p.b.barney, 6)
4501 self.assertEqual(p.b.betty, 3)
4502 (m1 & ~m3).toModify(p.a, param=int32(42)).toReplaceWith(p.b, EDProducer(
"YourProducer"))
4503 self.assertEqual(p.a.type_(),
"YourAnalyzer")
4504 self.assertEqual(p.a.param, 42)
4505 self.assertEqual(p.b.type_(),
"YourProducer")
4508 a = EDAlias(foo2 =
VPSet(PSet(type =
string(
"Foo2"))))
4512 m.toModify(a, foo2 = {0: dict(type =
"Foo3")})
4513 self.assertEqual(a.foo2[0].type,
"Foo3")
4515 m.toModify(a, foo4 =
VPSet(PSet(type =
string(
"Foo4"))))
4516 self.assertEqual(a.foo2[0].type,
"Foo3")
4517 self.assertEqual(a.foo4[0].type,
"Foo4")
4519 m.toModify(a, foo2 =
None)
4520 self.assertFalse(hasattr(a,
"foo2"))
4521 self.assertEqual(a.foo4[0].type,
"Foo4")
4523 m.toReplaceWith(a, EDAlias(bar =
VPSet(PSet(type =
string(
"Bar")))))
4524 self.assertFalse(hasattr(a,
"foo2"))
4525 self.assertFalse(hasattr(a,
"foo4"))
4526 self.assertTrue(hasattr(a,
"bar"))
4527 self.assertEqual(a.bar[0].type,
"Bar")
4530 sp = SwitchProducerTest(test1 = EDProducer(
"Foo",
4532 b = PSet(c = int32(2))),
4533 test2 = EDProducer(
"Bar",
4535 bb = PSet(cc = int32(12))))
4540 test1 = dict(a = 4, b = dict(c =
None)),
4541 test2 = dict(aa = 15, bb = dict(cc = 45, dd =
string(
"foo"))))
4542 self.assertEqual(sp.test1.a.value(), 4)
4543 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
4544 self.assertEqual(sp.test2.aa.value(), 15)
4545 self.assertEqual(sp.test2.bb.cc.value(), 45)
4546 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
4548 m.toReplaceWith(sp.test1, EDProducer(
"Fred", x = int32(42)))
4549 self.assertEqual(sp.test1.type_(),
"Fred")
4550 self.assertEqual(sp.test1.x.value(), 42)
4551 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1, EDAnalyzer(
"Foo")))
4553 m.toModify(sp, test2 = EDProducer(
"Xyzzy", x = int32(24)))
4554 self.assertEqual(sp.test2.type_(),
"Xyzzy")
4555 self.assertEqual(sp.test2.x.value(), 24)
4556 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 = EDAnalyzer(
"Foo")))
4558 m.toModify(sp, test3 = EDProducer(
"Wilma", y = int32(24)))
4559 self.assertEqual(sp.test3.type_(),
"Wilma")
4560 self.assertEqual(sp.test3.y.value(), 24)
4561 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 = EDAnalyzer(
"Foo")))
4563 m.toModify(sp, test2 =
None)
4564 self.assertEqual(hasattr(sp,
"test2"),
False)
4566 m.toModify(sp, test2 = EDAlias(foo =
VPSet(PSet(type =
string(
"int")))))
4567 self.assertTrue(hasattr(sp.test2,
"foo"))
4569 m.toReplaceWith(sp.test2, EDAlias(bar =
VPSet(PSet(type =
string(
"int")))))
4570 self.assertTrue(hasattr(sp.test2,
"bar"))
4572 m.toModify(sp, test2 = EDAlias(xyzzy =
VPSet(PSet(type =
string(
"int")))))
4573 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
4575 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2, EDProducer(
"Foo")))
4576 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)