CMS 3D CMS Logo

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

Public Member Functions

def __and__
 
def __init__
 
def isChosen
 
def makeProcessModifier
 
def toModify
 
def toReplaceWith
 

Private Member Functions

def _setChosen
 

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 1147 of file Config.py.

Constructor & Destructor Documentation

def Config.Modifier.__init__ (   self)

Definition at line 1156 of file Config.py.

1157  def __init__(self):
self.__chosen = False

Member Function Documentation

def Config.Modifier.__and__ (   self,
  other 
)

Definition at line 1213 of file Config.py.

1214  def __and__(self, other):
1215  return _AndModifier(self,other)
1216 
def Config.Modifier._setChosen (   self)
private
Should only be called by cms.Process instances

Definition at line 1208 of file Config.py.

References Config.Modifier.__chosen.

1209  def _setChosen(self):
1210  """Should only be called by cms.Process instances"""
self.__chosen = True
def Config.Modifier.isChosen (   self)

Definition at line 1211 of file Config.py.

References Config.Modifier.__chosen.

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

1212  def isChosen(self):
return self.__chosen
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 1159 of file Config.py.

1160  def makeProcessModifier(self,func):
1161  """This is used to create a ProcessModifer that can perform actions on the process as a whole.
1162  This takes as argument a callable object (e.g. function) that takes as its sole argument an instance of Process.
1163  In order to work, the value returned from this function must be assigned to a uniquely named variable.
1164  """
return ProcessModifier(self,func)
def makeProcessModifier
Definition: Config.py:1159
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 1165 of file Config.py.

References RecoJets_EventContent_cff.func, Config._AndModifier.isChosen(), Config.Modifier.isChosen(), and groupFilesInBlocks.temp.

1166  def toModify(self,obj, func=None,**kw):
1167  """This is used to register an action to be performed on the specific object. Two different forms are allowed
1168  Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
1169  that will be the object passed in as the first argument.
1170  Form 2: A list of parameter name, value pairs can be passed
1171  mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
1172  This form can also be used to remove a parameter by passing the value of None
1173  #remove the parameter foo.fred
1174  mod.toModify(foo, fred = None)
1175  Additionally, parameters embedded within PSets can also be modified using a dictionary
1176  #change foo.fred.pebbles to 3 and foo.fred.friend to "barney"
1177  mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) )
1178  """
1179  if func is not None and len(kw) != 0:
1180  raise TypeError("toModify takes either two arguments or one argument and key/value pairs")
1181  if not self.isChosen():
1182  return
1183  if func is not None:
1184  func(obj)
1185  else:
1186  temp =_ParameterModifier(kw)
temp(obj)
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 1187 of file Config.py.

References Config._AndModifier.isChosen(), and Config.Modifier.isChosen().

1188  def toReplaceWith(self,toObj,fromObj):
1189  """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj
1190  """
1191  if type(fromObj) != type(toObj):
1192  raise TypeError("toReplaceWith requires both arguments to be the same class type")
1193  if not self.isChosen():
1194  return
1195  if isinstance(fromObj,_ModuleSequenceType):
1196  toObj._seq = fromObj._seq
1197  elif isinstance(fromObj,_Parameterizable):
1198  #clear old items just incase fromObj is not a complete superset of toObj
1199  for p in toObj.parameterNames_():
1200  delattr(toObj,p)
1201  for p in fromObj.parameterNames_():
1202  setattr(toObj,p,getattr(fromObj,p))
1203  if isinstance(fromObj,_TypedParameterizable):
1204  toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1205 
1206  else:
1207  raise TypeError("toReplaceWith does not work with type "+str(type(toObj)))
def toReplaceWith
Definition: Config.py:1187

Member Data Documentation

Config.Modifier.__chosen
private

Definition at line 1158 of file Config.py.

Referenced by Config.Modifier._setChosen(), Config.ModifierChain._setChosen(), Config.Modifier.isChosen(), and Config.ModifierChain.isChosen().

Config.Modifier.__processModifiers
private

Definition at line 1157 of file Config.py.