CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes
Config.TestModuleCommand Class Reference
Inheritance diagram for Config.TestModuleCommand:

Public Member Functions

def setUp
 
def testCloneSequence
 
def testExamples
 
def testFreeze
 
def testGlobalReplace
 
def testImplicitSchedule
 
def testModifier
 
def testOverride
 
def testParameterizable
 
def testPath
 
def testPrefers
 
def testProcessDumpPython
 
def testProcessExtend
 
def testProcessInsertion
 
def testPrune
 
def testRefToPSet
 
def testSchedule
 
def testSecSource
 
def testSequence
 
def testSequence2
 
def testSubProcess
 
def testTypedParameterizable
 
def testUsing
 

Public Attributes

 a
 
 proc_mod_
 

Static Public Attributes

tuple d = p.dumpPython()
 
tuple p = Process("test")
 
tuple s = Sequence(p.a)
 

Detailed Description

Definition at line 1318 of file Config.py.

Member Function Documentation

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

Definition at line 1319 of file Config.py.

1320  def setUp(self):
1321  """Nothing to do """
None
def Config.TestModuleCommand.testCloneSequence (   self)

Definition at line 1614 of file Config.py.

1615  def testCloneSequence(self):
1616  p = Process("test")
1617  a = EDAnalyzer("MyAnalyzer")
1618  p.a = a
1619  a.setLabel("a")
1620  b = EDAnalyzer("YOurAnalyzer")
1621  p.b = b
1622  b.setLabel("b")
1623  path = Path(a * b)
1624  p.path = Path(p.a*p.b)
1625  lookuptable = {id(a): p.a, id(b): p.b}
1626  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1627  #lookuptable = p._cloneToObjectDict
1628  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1629  self.assertEqual(str(path),str(p.path))
def Config.TestModuleCommand.testExamples (   self)

Definition at line 1747 of file Config.py.

References Types.untracked.

1748  def testExamples(self):
1749  p = Process("Test")
1750  p.source = Source("PoolSource",fileNames = untracked(string("file:reco.root")))
1751  p.foos = EDProducer("FooProducer")
1752  p.bars = EDProducer("BarProducer", foos=InputTag("foos"))
1753  p.out = OutputModule("PoolOutputModule",fileName=untracked(string("file:foos.root")))
1754  p.bars.foos = 'Foosball'
1755  self.assertEqual(p.bars.foos, InputTag('Foosball'))
1756  p.p = Path(p.foos*p.bars)
1757  p.e = EndPath(p.out)
1758  p.add_(Service("MessageLogger"))
tuple untracked
Definition: Types.py:27
def Config.TestModuleCommand.testFreeze (   self)

Definition at line 1813 of file Config.py.

1814  def testFreeze(self):
1815  process = Process("Freeze")
1816  m = EDProducer("M", p=PSet(i = int32(1)))
1817  m.p.i = 2
1818  process.m = m
1819  # should be frozen
1820  #self.assertRaises(ValueError, setattr, m.p, 'i', 3)
1821  #self.assertRaises(ValueError, setattr, m, 'p', PSet(i=int32(1)))
1822  #self.assertRaises(ValueError, setattr, m.p, 'j', 1)
1823  #self.assertRaises(ValueError, setattr, m, 'j', 1)
1824  # But OK to change through the process
1825  process.m.p.i = 4
1826  self.assertEqual(process.m.p.i.value(), 4)
1827  process.m.p = PSet(j=int32(1))
1828  # should work to clone it, though
1829  m2 = m.clone(p = PSet(i = int32(5)), j = int32(8))
1830  m2.p.i = 6
m2.j = 8
def Config.TestModuleCommand.testGlobalReplace (   self)

Definition at line 1557 of file Config.py.

1558  def testGlobalReplace(self):
1559  p = Process('test')
1560  p.a = EDAnalyzer("MyAnalyzer")
1561  p.b = EDAnalyzer("YourAnalyzer")
1562  p.c = EDAnalyzer("OurAnalyzer")
1563  p.s = Sequence(p.a*p.b)
1564  p.p = Path(p.c+p.s+p.a)
1565  new = EDAnalyzer("NewAnalyzer")
1566  p.globalReplace("a",new)
def Config.TestModuleCommand.testImplicitSchedule (   self)

Definition at line 1684 of file Config.py.

1685  def testImplicitSchedule(self):
1686  p = Process("test")
1687  p.a = EDAnalyzer("MyAnalyzer")
1688  p.b = EDAnalyzer("YourAnalyzer")
1689  p.c = EDAnalyzer("OurAnalyzer")
1690  p.path1 = Path(p.a)
1691  p.path2 = Path(p.b)
1692  self.assert_(p.schedule is None)
1693  pths = p.paths
1694  keys = pths.keys()
1695  self.assertEqual(pths[keys[0]],p.path1)
1696  self.assertEqual(pths[keys[1]],p.path2)
1697  p.prune()
1698  self.assert_(hasattr(p, 'a'))
1699  self.assert_(hasattr(p, 'b'))
1700  self.assert_(not hasattr(p, 'c'))
1701  self.assert_(hasattr(p, 'path1'))
1702  self.assert_(hasattr(p, 'path2'))
1703 
1704 
1705  p = Process("test")
1706  p.a = EDAnalyzer("MyAnalyzer")
1707  p.b = EDAnalyzer("YourAnalyzer")
1708  p.c = EDAnalyzer("OurAnalyzer")
1709  p.path2 = Path(p.b)
1710  p.path1 = Path(p.a)
1711  self.assert_(p.schedule is None)
1712  pths = p.paths
1713  keys = pths.keys()
1714  self.assertEqual(pths[keys[1]],p.path1)
1715  self.assertEqual(pths[keys[0]],p.path2)
1716 
def Config.TestModuleCommand.testModifier (   self)

Definition at line 1970 of file Config.py.

References cmsPerfStripChart.dict.

1971  def testModifier(self):
1972  m1 = Modifier()
1973  p = Process("test",m1)
1974  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1975  def _mod_fred(obj):
1976  obj.fred = 2
1977  m1.toModify(p.a,_mod_fred)
1978  self.assertEqual(p.a.fred.value(),2)
1979  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1980  m1.toModify(p.b, wilma = 2)
1981  self.assertEqual(p.b.wilma.value(),2)
1982  #check that Modifier not attached to a process doesn't run
1983  m1 = Modifier()
1984  p = Process("test")
1985  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1986  m1.toModify(p.a,_mod_fred)
1987  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1988  m1.toModify(p.b, wilma = 2)
1989  self.assertEqual(p.a.fred.value(),1)
1990  self.assertEqual(p.b.wilma.value(),1)
1991  #make sure clones get the changes
1992  m1 = Modifier()
1993  p = Process("test",m1)
1994  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
1995  m1.toModify(p.a, fred = int32(2))
1996  p.b = p.a.clone(wilma = int32(3))
1997  self.assertEqual(p.a.fred.value(),2)
1998  self.assertEqual(p.a.wilma.value(),1)
1999  self.assertEqual(p.b.fred.value(),2)
2000  self.assertEqual(p.b.wilma.value(),3)
2001  #test removal of parameter
2002  m1 = Modifier()
2003  p = Process("test",m1)
2004  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
2005  m1.toModify(p.a, fred = None)
2006  self.assertEqual(hasattr(p.a, "fred"), False)
2007  self.assertEqual(p.a.wilma.value(),1)
2008  #test adding a parameter
2009  m1 = Modifier()
2010  p = Process("test",m1)
2011  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
2012  m1.toModify(p.a, wilma = int32(2))
2013  self.assertEqual(p.a.fred.value(), 1)
2014  self.assertEqual(p.a.wilma.value(),2)
2015  #test setting of value in PSet
2016  m1 = Modifier()
2017  p = Process("test",m1)
2018  p.a = EDAnalyzer("MyAnalyzer", flintstones = PSet(fred = int32(1), wilma = int32(1)))
2019  m1.toModify(p.a, flintstones = dict(fred = int32(2)))
2020  self.assertEqual(p.a.flintstones.fred.value(),2)
2021  self.assertEqual(p.a.flintstones.wilma.value(),1)
2022  #test that load causes process wide methods to run
2023  def _rem_a(proc):
2024  del proc.a
2025  class ProcModifierMod(object):
2026  def __init__(self,modifier,func):
2027  self.proc_mod_ = modifier.makeProcessModifier(func)
2028  class DummyMod(object):
2029  def __init__(self):
2030  self.a = EDAnalyzer("Dummy")
2031  testMod = DummyMod()
2032  p.extend(testMod)
2033  self.assert_(hasattr(p,"a"))
2034  m1 = Modifier()
2035  p = Process("test",m1)
2036  testProcMod = ProcModifierMod(m1,_rem_a)
2037  p.extend(testMod)
2038  p.extend(testProcMod)
2039  self.assert_(not hasattr(p,"a"))
2040  #test ModifierChain
2041  m1 = Modifier()
2042  mc = ModifierChain(m1)
2043  p = Process("test",mc)
2044  testMod = DummyMod()
2045  p.b = EDAnalyzer("Dummy2", fred = int32(1))
2046  m1.toModify(p.b, fred = int32(3))
2047  p.extend(testMod)
2048  testProcMod = ProcModifierMod(m1,_rem_a)
2049  p.extend(testProcMod)
2050  self.assert_(not hasattr(p,"a"))
2051  self.assertEqual(p.b.fred.value(),3)
2052  #check combining
2053  m1 = Modifier()
2054  m2 = Modifier()
2055  p = Process("test",m1)
2056  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
2057  (m1 & m2).toModify(p.a, fred = int32(2))
2058  self.assertEqual(p.a.fred, 1)
2059  m1 = Modifier()
2060  m2 = Modifier()
2061  p = Process("test",m1,m2)
2062  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
2063  (m1 & m2).toModify(p.a, fred = int32(2))
2064  self.assertEqual(p.a.fred, 2)
2065  m1 = Modifier()
2066  m2 = Modifier()
2067  m3 = Modifier()
2068  p = Process("test",m1,m2,m3)
2069  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
2070  (m1 & m2 & m3).toModify(p.a, fred = int32(2))
2071  self.assertEqual(p.a.fred, 2)
2072  #check toReplaceWith
2073  m1 = Modifier()
2074  p = Process("test",m1)
2075  p.a =EDAnalyzer("MyAnalyzer", fred = int32(1))
2076  m1.toReplaceWith(p.a, EDAnalyzer("YourAnalyzer", wilma = int32(3)))
2077  p.b =EDAnalyzer("BAn")
2078  p.s = Sequence(p.a)
2079  m1.toReplaceWith(p.s, Sequence(p.a+p.b))
2080  self.assertEqual(p.a.wilma.value(),3)
2081  self.assertEqual(p.a.type_(),"YourAnalyzer")
2082  self.assertEqual(hasattr(p,"fred"),False)
2083  self.assertEqual(p.s.dumpPython(""),"cms.Sequence(process.a+process.b)\n")
2084  #check toReplaceWith doesn't activate not chosen
2085  m1 = Modifier()
2086  p = Process("test")
2087  p.a =EDAnalyzer("MyAnalyzer", fred = int32(1))
2088  m1.toReplaceWith(p.a, EDAnalyzer("YourAnalyzer", wilma = int32(3)))
2089  self.assertEqual(p.a.type_(),"MyAnalyzer")
unittest.main()
def Config.TestModuleCommand.testOverride (   self)

Definition at line 1724 of file Config.py.

1725  def testOverride(self):
1726  p = Process('test')
1727  a = EDProducer("A", a1=int32(0))
1728  self.assert_(not a.isModified())
1729  a.a1 = 1
1730  self.assert_(a.isModified())
1731  p.a = a
1732  self.assertEqual(p.a.a1.value(), 1)
1733  # try adding an unmodified module.
1734  # should accept it
1735  p.a = EDProducer("A", a1=int32(2))
1736  self.assertEqual(p.a.a1.value(), 2)
1737  # try adding a modified module. Should throw
1738  # no longer, since the same (modified) say, geometry
1739  # could come from more than one cff
1740  b = EDProducer("A", a1=int32(3))
1741  b.a1 = 4
1742  #self.assertRaises(RuntimeError, setattr, *(p,'a',b))
1743  ps1 = PSet(a = int32(1))
1744  ps2 = PSet(a = int32(2))
1745  self.assertRaises(ValueError, EDProducer, 'C', ps1, ps2)
1746  self.assertRaises(ValueError, EDProducer, 'C', ps1, a=int32(3))
def Config.TestModuleCommand.testParameterizable (   self)

Definition at line 1322 of file Config.py.

1323  def testParameterizable(self):
1324  p = _Parameterizable()
1325  self.assertEqual(len(p.parameterNames_()),0)
1326  p.a = int32(1)
1327  self.assert_('a' in p.parameterNames_())
1328  self.assertEqual(p.a.value(), 1)
1329  p.a = 10
1330  self.assertEqual(p.a.value(), 10)
1331  p.a = untracked(int32(1))
1332  self.assertEqual(p.a.value(), 1)
1333  self.failIf(p.a.isTracked())
1334  p.a = untracked.int32(1)
1335  self.assertEqual(p.a.value(), 1)
1336  self.failIf(p.a.isTracked())
1337  p = _Parameterizable(foo=int32(10), bar = untracked(double(1.0)))
1338  self.assertEqual(p.foo.value(), 10)
1339  self.assertEqual(p.bar.value(),1.0)
1340  self.failIf(p.bar.isTracked())
1341  self.assertRaises(TypeError,setattr,(p,'c',1))
1342  p = _Parameterizable(a=PSet(foo=int32(10), bar = untracked(double(1.0))))
1343  self.assertEqual(p.a.foo.value(),10)
1344  self.assertEqual(p.a.bar.value(),1.0)
1345  p.b = untracked(PSet(fii = int32(1)))
1346  self.assertEqual(p.b.fii.value(),1)
1347  self.failIf(p.b.isTracked())
1348  #test the fact that values can be shared
1349  v = int32(10)
1350  p=_Parameterizable(a=v)
1351  v.setValue(11)
1352  self.assertEqual(p.a.value(),11)
1353  p.a = 12
1354  self.assertEqual(p.a.value(),12)
self.assertEqual(v.value(),12)
tuple untracked
Definition: Types.py:27
def Config.TestModuleCommand.testPath (   self)

Definition at line 1592 of file Config.py.

1593  def testPath(self):
1594  p = Process("test")
1595  p.a = EDAnalyzer("MyAnalyzer")
1596  p.b = EDAnalyzer("YourAnalyzer")
1597  p.c = EDAnalyzer("OurAnalyzer")
1598  path = Path(p.a)
1599  path *= p.b
1600  path += p.c
1601  self.assertEqual(str(path),'a+b+c')
1602  path = Path(p.a*p.b+p.c)
1603  self.assertEqual(str(path),'a+b+c')
1604 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences
1605 # self.assertEqual(str(path),'((a*b)+c)')
1606  path = Path(p.a+ p.b*p.c)
1607  self.assertEqual(str(path),'a+b+c')
1608  path = Path(p.a*(p.b+p.c))
1609  self.assertEqual(str(path),'a+b+c')
1610  path = Path(p.a*(p.b+~p.c))
1611  self.assertEqual(str(path),'a+b+~c')
1612  p.es = ESProducer("AnESProducer")
1613  self.assertRaises(TypeError,Path,p.es)
def Config.TestModuleCommand.testPrefers (   self)

Definition at line 1759 of file Config.py.

1760  def testPrefers(self):
1761  p = Process("Test")
1762  p.add_(ESSource("ForceSource"))
1763  p.juicer = ESProducer("JuicerProducer")
1764  p.prefer("ForceSource")
1765  p.prefer("juicer")
1766  self.assertEqual(p.dumpConfig(),
1767 """process Test = {
1768  es_module juicer = JuicerProducer {
1769  }
1770  es_source = ForceSource {
1771  }
1772  es_prefer = ForceSource {
1773  }
1774  es_prefer juicer = JuicerProducer {
1775  }
1776 }
1777 """)
1778  p.prefer("juicer",fooRcd=vstring("Foo"))
1779  self.assertEqual(p.dumpConfig(),
1780 """process Test = {
1781  es_module juicer = JuicerProducer {
1782  }
1783  es_source = ForceSource {
1784  }
1785  es_prefer = ForceSource {
1786  }
1787  es_prefer juicer = JuicerProducer {
1788  vstring fooRcd = {
1789  'Foo'
1790  }
1791 
1792  }
1793 }
1794 """)
1795  self.assertEqual(p.dumpPython(),
1796 """import FWCore.ParameterSet.Config as cms
1797 
1798 process = cms.Process("Test")
1799 
1800 process.juicer = cms.ESProducer("JuicerProducer")
1801 
1802 
1803 process.ForceSource = cms.ESSource("ForceSource")
1804 
1805 
1806 process.prefer("ForceSource")
1807 
1808 process.prefer("juicer",
1809  fooRcd = cms.vstring('Foo')
1810 )
1811 
1812 """)
def Config.TestModuleCommand.testProcessDumpPython (   self)

Definition at line 1457 of file Config.py.

1458  def testProcessDumpPython(self):
1459  p = Process("test")
1460  p.a = EDAnalyzer("MyAnalyzer")
1461  p.p = Path(p.a)
1462  p.s = Sequence(p.a)
1463  p.r = Sequence(p.s)
1464  p.p2 = Path(p.s)
1465  p.schedule = Schedule(p.p2,p.p)
1466  d=p.dumpPython()
1467  self.assertEqual(d,
1468 """import FWCore.ParameterSet.Config as cms
1469 
1470 process = cms.Process("test")
1471 
1472 process.a = cms.EDAnalyzer("MyAnalyzer")
1473 
1474 
1475 process.s = cms.Sequence(process.a)
1476 
1477 
1478 process.r = cms.Sequence(process.s)
1479 
1480 
1481 process.p = cms.Path(process.a)
1482 
1483 
1484 process.p2 = cms.Path(process.s)
1485 
1486 
1487 process.schedule = cms.Schedule(*[ process.p2, process.p ])
1488 """)
1489  #Reverse order of 'r' and 's'
1490  p = Process("test")
1491  p.a = EDAnalyzer("MyAnalyzer")
1492  p.p = Path(p.a)
1493  p.r = Sequence(p.a)
1494  p.s = Sequence(p.r)
1495  p.p2 = Path(p.r)
1496  p.schedule = Schedule(p.p2,p.p)
1497  p.b = EDAnalyzer("YourAnalyzer")
1498  d=p.dumpPython()
1499  self.assertEqual(d,
1500 """import FWCore.ParameterSet.Config as cms
1501 
1502 process = cms.Process("test")
1503 
1504 process.a = cms.EDAnalyzer("MyAnalyzer")
1505 
1506 
1507 process.b = cms.EDAnalyzer("YourAnalyzer")
1508 
1509 
1510 process.r = cms.Sequence(process.a)
1511 
1512 
1513 process.s = cms.Sequence(process.r)
1514 
1515 
1516 process.p = cms.Path(process.a)
1517 
1518 
1519 process.p2 = cms.Path(process.r)
1520 
1521 
1522 process.schedule = cms.Schedule(*[ process.p2, process.p ])
""")
def Config.TestModuleCommand.testProcessExtend (   self)

Definition at line 1387 of file Config.py.

1388  def testProcessExtend(self):
1389  class FromArg(object):
1390  def __init__(self,*arg,**args):
1391  for name in args.iterkeys():
1392  self.__dict__[name]=args[name]
1393 
1394  a=EDAnalyzer("MyAnalyzer")
1395  t=EDAnalyzer("MyAnalyzer")
1396  t.setLabel("foo")
1397  s1 = Sequence(a)
1398  s2 = Sequence(s1)
1399  s3 = Sequence(s2)
1400  d = FromArg(
1401  a=a,
1402  b=Service("Full"),
1403  c=Path(a),
1404  d=s2,
1405  e=s1,
1406  f=s3,
1407  g=Sequence(s1+s2+s3)
1408  )
1409  p = Process("Test")
1410  p.extend(d)
1411  self.assertEqual(p.a.type_(),"MyAnalyzer")
1412  self.assertEqual(p.a.label_(),"a")
1413  self.assertRaises(AttributeError,getattr,p,'b')
1414  self.assertEqual(p.Full.type_(),"Full")
1415  self.assertEqual(str(p.c),'a')
1416  self.assertEqual(str(p.d),'a')
1417 
1418  z1 = FromArg(
1419  a=a,
1420  b=Service("Full"),
1421  c=Path(a),
1422  d=s2,
1423  e=s1,
1424  f=s3,
1425  s4=s3,
1426  g=Sequence(s1+s2+s3)
1427  )
1428 
1429  p1 = Process("Test")
1430  #p1.extend(z1)
1431  self.assertRaises(ValueError, p1.extend, z1)
1432 
1433  z2 = FromArg(
1434  a=a,
1435  b=Service("Full"),
1436  c=Path(a),
1437  d=s2,
1438  e=s1,
1439  f=s3,
1440  aaa=copy.deepcopy(a),
1441  s4=copy.deepcopy(s3),
1442  g=Sequence(s1+s2+s3),
1443  t=t
1444  )
1445  p2 = Process("Test")
1446  p2.extend(z2)
1447  #self.assertRaises(ValueError, p2.extend, z2)
1448  self.assertEqual(p2.s4.label_(),"s4")
1449  #p2.s4.setLabel("foo")
1450  self.assertRaises(ValueError, p2.s4.setLabel, "foo")
1451  p2.s4.setLabel("s4")
1452  p2.s4.setLabel(None)
1453  p2.s4.setLabel("foo")
1454  p2._Process__setObjectLabel(p2.s4, "foo")
1455  p2._Process__setObjectLabel(p2.s4, None)
1456  p2._Process__setObjectLabel(p2.s4, "bar")
def Config.TestModuleCommand.testProcessInsertion (   self)

Definition at line 1362 of file Config.py.

1363  def testProcessInsertion(self):
1364  p = Process("test")
1365  p.a = EDAnalyzer("MyAnalyzer")
1366  self.assert_( 'a' in p.analyzers_() )
1367  self.assert_( 'a' in p.analyzers)
1368  p.add_(Service("MessageLogger"))
1369  self.assert_('MessageLogger' in p.services_())
1370  self.assertEqual(p.MessageLogger.type_(), "MessageLogger")
1371  p.Tracer = Service("Tracer")
1372  self.assert_('Tracer' in p.services_())
1373  self.assertRaises(TypeError, setattr, *(p,'b',"this should fail"))
1374  self.assertRaises(TypeError, setattr, *(p,'bad',Service("MessageLogger")))
1375  self.assertRaises(ValueError, setattr, *(p,'bad',Source("PoolSource")))
1376  p.out = OutputModule("Outer")
1377  self.assertEqual(p.out.type_(), 'Outer')
1378  self.assert_( 'out' in p.outputModules_() )
1379 
1380  p.geom = ESSource("GeomProd")
1381  self.assert_('geom' in p.es_sources_())
1382  p.add_(ESSource("ConfigDB"))
1383  self.assert_('ConfigDB' in p.es_sources_())
1384 
1385  p.aliasfoo1 = EDAlias(foo1 = VPSet(PSet(type = string("Foo1"))))
1386  self.assert_('aliasfoo1' in p.aliases_())
def Config.TestModuleCommand.testPrune (   self)

Definition at line 1887 of file Config.py.

1888  def testPrune(self):
1889  p = Process("test")
1890  p.a = EDAnalyzer("MyAnalyzer")
1891  p.b = EDAnalyzer("YourAnalyzer")
1892  p.c = EDAnalyzer("OurAnalyzer")
1893  p.d = EDAnalyzer("OurAnalyzer")
1894  p.s = Sequence(p.d)
1895  p.path1 = Path(p.a)
1896  p.path2 = Path(p.b)
1897  self.assert_(p.schedule is None)
1898  pths = p.paths
1899  keys = pths.keys()
1900  self.assertEqual(pths[keys[0]],p.path1)
1901  self.assertEqual(pths[keys[1]],p.path2)
1902  p.pset1 = PSet(parA = string("pset1"))
1903  p.pset2 = untracked.PSet(parA = string("pset2"))
1904  p.vpset1 = VPSet()
1905  p.vpset2 = untracked.VPSet()
1906  p.prune()
1907  self.assert_(hasattr(p, 'a'))
1908  self.assert_(hasattr(p, 'b'))
1909  self.assert_(not hasattr(p, 'c'))
1910  self.assert_(not hasattr(p, 'd'))
1911  self.assert_(not hasattr(p, 's'))
1912  self.assert_(hasattr(p, 'path1'))
1913  self.assert_(hasattr(p, 'path2'))
1914 # self.assert_(not hasattr(p, 'pset1'))
1915 # self.assert_(hasattr(p, 'pset2'))
1916 # self.assert_(not hasattr(p, 'vpset1'))
1917 # self.assert_(not hasattr(p, 'vpset2'))
1918 
1919  p = Process("test")
1920  p.a = EDAnalyzer("MyAnalyzer")
1921  p.b = EDAnalyzer("YourAnalyzer")
1922  p.c = EDAnalyzer("OurAnalyzer")
1923  p.d = EDAnalyzer("OurAnalyzer")
1924  p.e = EDAnalyzer("OurAnalyzer")
1925  p.s = Sequence(p.d)
1926  p.s2 = Sequence(p.b)
1927  p.s3 = Sequence(p.e)
1928  p.path1 = Path(p.a)
1929  p.path2 = Path(p.b)
1930  p.path3 = Path(p.b+p.s2)
1931  p.path4 = Path(p.b+p.s3)
1932  p.schedule = Schedule(p.path1,p.path2,p.path3)
1933  pths = p.paths
1934  keys = pths.keys()
1935  self.assertEqual(pths[keys[0]],p.path1)
1936  self.assertEqual(pths[keys[1]],p.path2)
1937  p.prune()
1938  self.assert_(hasattr(p, 'a'))
1939  self.assert_(hasattr(p, 'b'))
1940  self.assert_(not hasattr(p, 'c'))
1941  self.assert_(not hasattr(p, 'd'))
1942  self.assert_(not hasattr(p, 'e'))
1943  self.assert_(not hasattr(p, 's'))
1944  self.assert_(hasattr(p, 's2'))
1945  self.assert_(not hasattr(p, 's3'))
1946  self.assert_(hasattr(p, 'path1'))
1947  self.assert_(hasattr(p, 'path2'))
1948  self.assert_(hasattr(p, 'path3'))
1949  self.assert_(not hasattr(p, 'path4'))
1950  #test SequencePlaceholder
1951  p = Process("test")
1952  p.a = EDAnalyzer("MyAnalyzer")
1953  p.b = EDAnalyzer("YourAnalyzer")
1954  p.s = Sequence(SequencePlaceholder("a")+p.b)
1955  p.pth = Path(p.s)
1956  p.prune()
1957  self.assert_(hasattr(p, 'a'))
1958  self.assert_(hasattr(p, 'b'))
1959  self.assert_(hasattr(p, 's'))
1960  self.assert_(hasattr(p, 'pth'))
1961  #test unresolved SequencePlaceholder
1962  p = Process("test")
1963  p.b = EDAnalyzer("YourAnalyzer")
1964  p.s = Sequence(SequencePlaceholder("a")+p.b)
1965  p.pth = Path(p.s)
1966  p.prune(keepUnresolvedSequencePlaceholders=True)
1967  self.assert_(hasattr(p, 'b'))
1968  self.assert_(hasattr(p, 's'))
1969  self.assert_(hasattr(p, 'pth'))
self.assertEqual(p.s.dumpPython(''),'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
def Config.TestModuleCommand.testRefToPSet (   self)

Definition at line 1871 of file Config.py.

1872  def testRefToPSet(self):
1873  proc = Process("test")
1874  proc.top = PSet(a = int32(1))
1875  proc.ref = PSet(refToPSet_ = string("top"))
1876  proc.ref2 = PSet( a = int32(1), b = PSet( refToPSet_ = string("top")))
1877  proc.ref3 = PSet(refToPSet_ = string("ref"))
1878  proc.ref4 = VPSet(PSet(refToPSet_ = string("top")),
1879  PSet(refToPSet_ = string("ref2")))
1880  p = TestMakePSet()
1881  proc.fillProcessDesc(p)
1882  self.assertEqual((True,1),p.values["ref"][1].values["a"])
1883  self.assertEqual((True,1),p.values["ref3"][1].values["a"])
1884  self.assertEqual((True,1),p.values["ref2"][1].values["a"])
1885  self.assertEqual((True,1),p.values["ref2"][1].values["b"][1].values["a"])
1886  self.assertEqual((True,1),p.values["ref4"][1][0].values["a"])
self.assertEqual((True,1),p.values["ref4"][1][1].values["a"])
def Config.TestModuleCommand.testSchedule (   self)

Definition at line 1630 of file Config.py.

1631  def testSchedule(self):
1632  p = Process("test")
1633  p.a = EDAnalyzer("MyAnalyzer")
1634  p.b = EDAnalyzer("YourAnalyzer")
1635  p.c = EDAnalyzer("OurAnalyzer")
1636  p.d = EDAnalyzer("OurAnalyzer")
1637  p.path1 = Path(p.a)
1638  p.path2 = Path(p.b)
1639  p.path3 = Path(p.d)
1640 
1641  s = Schedule(p.path1,p.path2)
1642  self.assertEqual(s[0],p.path1)
1643  self.assertEqual(s[1],p.path2)
1644  p.schedule = s
1645  self.assert_('b' in p.schedule.moduleNames())
1646  self.assert_(hasattr(p, 'b'))
1647  self.assert_(hasattr(p, 'c'))
1648  self.assert_(hasattr(p, 'd'))
1649  self.assert_(hasattr(p, 'path1'))
1650  self.assert_(hasattr(p, 'path2'))
1651  self.assert_(hasattr(p, 'path3'))
1652  p.prune()
1653  self.assert_('b' in p.schedule.moduleNames())
1654  self.assert_(hasattr(p, 'b'))
1655  self.assert_(not hasattr(p, 'c'))
1656  self.assert_(not hasattr(p, 'd'))
1657  self.assert_(hasattr(p, 'path1'))
1658  self.assert_(hasattr(p, 'path2'))
1659  self.assert_(not hasattr(p, 'path3'))
1660 
1661  #adding a path not attached to the Process should cause an exception
1662  p = Process("test")
1663  p.a = EDAnalyzer("MyAnalyzer")
1664  path1 = Path(p.a)
1665  s = Schedule(path1)
1666  self.assertRaises(RuntimeError, lambda : p.setSchedule_(s) )
1667 
1668  #make sure anonymous sequences work
1669  p = Process("test")
1670  p.a = EDAnalyzer("MyAnalyzer")
1671  p.b = EDAnalyzer("MyOtherAnalyzer")
1672  p.c = EDProducer("MyProd")
1673  path1 = Path(p.c*Sequence(p.a+p.b))
1674  s = Schedule(path1)
1675  self.assert_('a' in s.moduleNames())
1676  self.assert_('b' in s.moduleNames())
1677  self.assert_('c' in s.moduleNames())
1678  p.path1 = path1
1679  p.schedule = s
1680  p.prune()
1681  self.assert_('a' in s.moduleNames())
1682  self.assert_('b' in s.moduleNames())
1683  self.assert_('c' in s.moduleNames())
def Config.TestModuleCommand.testSecSource (   self)

Definition at line 1552 of file Config.py.

References python.rootplot.root2matplotlib.replace().

1553  def testSecSource(self):
1554  p = Process('test')
1555  p.a = SecSource("MySecSource")
1556  self.assertEqual(p.dumpPython().replace('\n',''),'import FWCore.ParameterSet.Config as cmsprocess = cms.Process("test")process.a = cms.SecSource("MySecSource")')
def Config.TestModuleCommand.testSequence (   self)

Definition at line 1567 of file Config.py.

1568  def testSequence(self):
1569  p = Process('test')
1570  p.a = EDAnalyzer("MyAnalyzer")
1571  p.b = EDAnalyzer("YourAnalyzer")
1572  p.c = EDAnalyzer("OurAnalyzer")
1573  p.s = Sequence(p.a*p.b)
1574  self.assertEqual(str(p.s),'a+b')
1575  self.assertEqual(p.s.label_(),'s')
1576  path = Path(p.c+p.s)
1577  self.assertEqual(str(path),'c+a+b')
1578  p._validateSequence(path, 'p1')
1579  notInProcess = EDAnalyzer('NotInProcess')
1580  p2 = Path(p.c+p.s*notInProcess)
1581  self.assertRaises(RuntimeError, p._validateSequence, p2, 'p2')
def Config.TestModuleCommand.testSequence2 (   self)

Definition at line 1582 of file Config.py.

1583  def testSequence2(self):
1584  p = Process('test')
1585  p.a = EDAnalyzer("MyAnalyzer")
1586  p.b = EDAnalyzer("YourAnalyzer")
1587  p.c = EDAnalyzer("OurAnalyzer")
1588  testseq = Sequence(p.a*p.b)
1589  p.s = testseq
1590  #p.y = testseq
1591  self.assertRaises(ValueError, p.__setattr__, "y", testseq)
def Config.TestModuleCommand.testSubProcess (   self)

Definition at line 1831 of file Config.py.

References cond.hash.

1832  def testSubProcess(self):
1833  process = Process("Parent")
1834  subProcess = Process("Child")
1835  subProcess.a = EDProducer("A")
1836  subProcess.p = Path(subProcess.a)
1837  subProcess.add_(Service("Foo"))
1838  process.addSubProcess(SubProcess(subProcess))
1839  d = process.dumpPython()
1840  equalD ="""import FWCore.ParameterSet.Config as cms
1841 
1842 process = cms.Process("Parent")
1843 
1844 parentProcess = process
1845 import FWCore.ParameterSet.Config as cms
1846 
1847 process = cms.Process("Child")
1848 
1849 process.a = cms.EDProducer("A")
1850 
1851 
1852 process.p = cms.Path(process.a)
1853 
1854 
1855 process.Foo = cms.Service("Foo")
1856 
1857 
1858 childProcess = process
1859 process = parentProcess
1860 process.addSubProcess(cms.SubProcess(process = childProcess, SelectEvents = cms.untracked.PSet(
1861 
1862 ), outputCommands = cms.untracked.vstring()))
1863 
1864 """
1865  equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcesses_()[0])))
1866  self.assertEqual(d,equalD)
1867  p = TestMakePSet()
1868  process.fillProcessDesc(p)
1869  self.assertEqual((True,['a']),p.values["subProcesses"][1][0].values["process"][1].values['@all_modules'])
1870  self.assertEqual((True,['p']),p.values["subProcesses"][1][0].values["process"][1].values['@paths'])
self.assertEqual({'@service_type':(True,'Foo')}, p.values["subProcesses"][1][0].values["process"][1].values["services"][1][0].values)
def Config.TestModuleCommand.testTypedParameterizable (   self)

Definition at line 1355 of file Config.py.

1356  def testTypedParameterizable(self):
1357  p = _TypedParameterizable("blah", b=int32(1))
1358  #see if copy works deeply
1359  other = p.copy()
1360  other.b = 2
1361  self.assertNotEqual(p.b,other.b)
def Config.TestModuleCommand.testUsing (   self)

Definition at line 1717 of file Config.py.

1718  def testUsing(self):
1719  p = Process('test')
1720  p.block = PSet(a = int32(1))
1721  p.modu = EDAnalyzer('Analyzer', p.block, b = int32(2))
1722  self.assertEqual(p.modu.a.value(),1)
1723  self.assertEqual(p.modu.b.value(),2)

Member Data Documentation

Config.TestModuleCommand.a

Definition at line 2029 of file Config.py.

tuple Config.TestModuleCommand.d = p.dumpPython()
static

Definition at line 1531 of file Config.py.

tuple Config.TestModuleCommand.p = Process("test")
static

Definition at line 1524 of file Config.py.

Config.TestModuleCommand.proc_mod_

Definition at line 2026 of file Config.py.

tuple Config.TestModuleCommand.s = Sequence(p.a)
static

Definition at line 1527 of file Config.py.