CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
Config.Modifier Class Reference
Inheritance diagram for Config.Modifier:

Public Member Functions

def __and__ (self, other)
 
def __init__ (self)
 
def __invert__ (self)
 
def __or__ (self, other)
 
def makeProcessModifier (self, func)
 
def toModify (self, obj, func=None, **kw)
 
def toReplaceWith (self, toObj, fromObj)
 

Private Member Functions

def _isChosen (self)
 
def _isOrContains (self, other)
 
def _setChosen (self)
 

Static Private Member Functions

def _toModify (obj, func, **kw)
 
def _toModifyCheck (obj, func, **kw)
 
def _toReplaceWith (toObj, fromObj)
 
def _toReplaceWithCheck (toObj, fromObj)
 

Private Attributes

 __chosen
 
 __processModifiers
 

Detailed Description

This class is used to define standard modifications to a Process.
An instance of this class is declared to denote a specific modification,e.g. era2017 could
reconfigure items in a process to match our expectation of running in 2017. Once declared,
these Modifier instances are imported into a configuration and items that need to be modified
are then associated with the Modifier and with the action to do the modification.
The registered modifications will only occur if the Modifier was passed to 
the cms.Process' constructor.

Definition at line 1578 of file Config.py.

Constructor & Destructor Documentation

◆ __init__()

def Config.Modifier.__init__ (   self)

Definition at line 1587 of file Config.py.

1587  def __init__(self):
1588  self.__processModifiers = []
1589  self.__chosen = False

Member Function Documentation

◆ __and__()

def Config.Modifier.__and__ (   self,
  other 
)

Definition at line 1659 of file Config.py.

1659  def __and__(self, other):
1660  return _AndModifier(self,other)

◆ __invert__()

def Config.Modifier.__invert__ (   self)

Definition at line 1661 of file Config.py.

1661  def __invert__(self):
1662  return _InvertModifier(self)

◆ __or__()

def Config.Modifier.__or__ (   self,
  other 
)

Definition at line 1663 of file Config.py.

1663  def __or__(self, other):
1664  return _OrModifier(self,other)

Referenced by LumiList.LumiList.__add__().

◆ _isChosen()

def Config.Modifier._isChosen (   self)
private

Definition at line 1657 of file Config.py.

1657  def _isChosen(self):
1658  return self.__chosen

References Config.Modifier.__chosen.

Referenced by Config._BoolModifierBase.toModify(), Config.Modifier.toModify(), Config._BoolModifierBase.toReplaceWith(), and Config.Modifier.toReplaceWith().

◆ _isOrContains()

def Config.Modifier._isOrContains (   self,
  other 
)
private

Definition at line 1665 of file Config.py.

1665  def _isOrContains(self, other):
1666  return self == other
1667 
1668 

Referenced by Config.ModifierChain.__copyIfExclude().

◆ _setChosen()

def Config.Modifier._setChosen (   self)
private
Should only be called by cms.Process instances

Definition at line 1654 of file Config.py.

1654  def _setChosen(self):
1655  """Should only be called by cms.Process instances"""
1656  self.__chosen = True

References Config.Modifier.__chosen.

◆ _toModify()

def Config.Modifier._toModify (   obj,
  func,
**  kw 
)
staticprivate

Definition at line 1618 of file Config.py.

1618  def _toModify(obj,func,**kw):
1619  if func is not None:
1620  func(obj)
1621  else:
1622  temp =_ParameterModifier(kw)
1623  temp(obj)

References TrackCollections2monitor_cff.func, and groupFilesInBlocks.temp.

◆ _toModifyCheck()

def Config.Modifier._toModifyCheck (   obj,
  func,
**  kw 
)
staticprivate

Definition at line 1597 of file Config.py.

1597  def _toModifyCheck(obj,func,**kw):
1598  if func is not None and len(kw) != 0:
1599  raise TypeError("toModify takes either two arguments or one argument and key/value pairs")

◆ _toReplaceWith()

def Config.Modifier._toReplaceWith (   toObj,
  fromObj 
)
staticprivate

Definition at line 1636 of file Config.py.

1636  def _toReplaceWith(toObj,fromObj):
1637  if isinstance(fromObj,_ModuleSequenceType):
1638  toObj._seq = fromObj._seq
1639  toObj._tasks = fromObj._tasks
1640  elif isinstance(fromObj,Task):
1641  toObj._collection = fromObj._collection
1642  elif isinstance(fromObj,_Parameterizable):
1643  #clear old items just incase fromObj is not a complete superset of toObj
1644  for p in toObj.parameterNames_():
1645  delattr(toObj,p)
1646  for p in fromObj.parameterNames_():
1647  setattr(toObj,p,getattr(fromObj,p))
1648  if isinstance(fromObj,_TypedParameterizable):
1649  toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1650 
1651  else:
1652  raise TypeError("toReplaceWith does not work with type "+str(type(toObj)))
1653 

References str.

◆ _toReplaceWithCheck()

def Config.Modifier._toReplaceWithCheck (   toObj,
  fromObj 
)
staticprivate

Definition at line 1625 of file Config.py.

1625  def _toReplaceWithCheck(toObj,fromObj):
1626  if not isinstance(fromObj, type(toObj)):
1627  raise TypeError("toReplaceWith requires both arguments to be the same class type")

◆ makeProcessModifier()

def Config.Modifier.makeProcessModifier (   self,
  func 
)
This is used to create a ProcessModifer that can perform actions on the process as a whole.
   This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process.
   In order to work, the value returned from this function must be assigned to a uniquely named variable.

Definition at line 1590 of file Config.py.

1590  def makeProcessModifier(self,func):
1591  """This is used to create a ProcessModifer that can perform actions on the process as a whole.
1592  This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process.
1593  In order to work, the value returned from this function must be assigned to a uniquely named variable.
1594  """
1595  return ProcessModifier(self,func)

◆ toModify()

def Config.Modifier.toModify (   self,
  obj,
  func = None,
**  kw 
)
This is used to register an action to be performed on the specific object. Two different forms are allowed
Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
that will be the object passed in as the first argument.
Form 2: A list of parameter name, value pairs can be passed
   mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
This form can also be used to remove a parameter by passing the value of None
    #remove the parameter foo.fred       
    mod.toModify(foo, fred = None)
Additionally, parameters embedded within PSets can also be modified using a dictionary
    #change foo.fred.pebbles to 3 and foo.fred.friend to "barney"
    mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) )

Definition at line 1600 of file Config.py.

1600  def toModify(self,obj, func=None,**kw):
1601  """This is used to register an action to be performed on the specific object. Two different forms are allowed
1602  Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
1603  that will be the object passed in as the first argument.
1604  Form 2: A list of parameter name, value pairs can be passed
1605  mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
1606  This form can also be used to remove a parameter by passing the value of None
1607  #remove the parameter foo.fred
1608  mod.toModify(foo, fred = None)
1609  Additionally, parameters embedded within PSets can also be modified using a dictionary
1610  #change foo.fred.pebbles to 3 and foo.fred.friend to "barney"
1611  mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) )
1612  """
1613  Modifier._toModifyCheck(obj,func,**kw)
1614  if not self._isChosen():
1615  return
1616  Modifier._toModify(obj,func,**kw)

References Config._AndModifier._isChosen(), Config._InvertModifier._isChosen(), Config._OrModifier._isChosen(), and Config.Modifier._isChosen().

◆ toReplaceWith()

def Config.Modifier.toReplaceWith (   self,
  toObj,
  fromObj 
)
If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj

Definition at line 1628 of file Config.py.

1628  def toReplaceWith(self,toObj,fromObj):
1629  """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj
1630  """
1631  Modifier._toReplaceWithCheck(toObj,fromObj)
1632  if not self._isChosen():
1633  return
1634  Modifier._toReplaceWith(toObj,fromObj)

References Config._AndModifier._isChosen(), Config._InvertModifier._isChosen(), Config._OrModifier._isChosen(), and Config.Modifier._isChosen().

Member Data Documentation

◆ __chosen

Config.Modifier.__chosen
private

◆ __processModifiers

Config.Modifier.__processModifiers
private

Definition at line 1588 of file Config.py.

groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
str
#define str(s)
Definition: TestProcessor.cc:51
TrackCollections2monitor_cff.func
func
Definition: TrackCollections2monitor_cff.py:359