CMS 3D CMS Logo

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__ (self, other)
 
def __init__ (self)
 
def isChosen (self)
 
def makeProcessModifier (self, func)
 
def toModify (self, obj, func=None, kw)
 
def toReplaceWith (self, toObj, fromObj)
 

Private Member Functions

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

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

Constructor & Destructor Documentation

def Config.Modifier.__init__ (   self)

Definition at line 1311 of file Config.py.

1311  def __init__(self):
1313  self.__chosen = False
def __init__(self)
Definition: Config.py:1311

Member Function Documentation

def Config.Modifier.__and__ (   self,
  other 
)

Definition at line 1371 of file Config.py.

1371  def __and__(self, other):
1372  return _AndModifier(self,other)
def __and__(self, other)
Definition: Config.py:1371
def Config.Modifier._isOrContains (   self,
  other 
)
private

Definition at line 1373 of file Config.py.

Referenced by Config.ModifierChain.__copyIfExclude().

1373  def _isOrContains(self, other):
1374  return self == other
1375 
1376 
def _isOrContains(self, other)
Definition: Config.py:1373
def Config.Modifier._setChosen (   self)
private
Should only be called by cms.Process instances

Definition at line 1366 of file Config.py.

References Config.Modifier.__chosen.

1366  def _setChosen(self):
1367  """Should only be called by cms.Process instances"""
1368  self.__chosen = True
def _setChosen(self)
Definition: Config.py:1366
def Config.Modifier.isChosen (   self)

Definition at line 1369 of file Config.py.

References Config.Modifier.__chosen.

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

1369  def isChosen(self):
1370  return self.__chosen
def isChosen(self)
Definition: Config.py:1369
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 1314 of file Config.py.

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

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

1320  def toModify(self,obj, func=None,**kw):
1321  """This is used to register an action to be performed on the specific object. Two different forms are allowed
1322  Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
1323  that will be the object passed in as the first argument.
1324  Form 2: A list of parameter name, value pairs can be passed
1325  mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
1326  This form can also be used to remove a parameter by passing the value of None
1327  #remove the parameter foo.fred
1328  mod.toModify(foo, fred = None)
1329  Additionally, parameters embedded within PSets can also be modified using a dictionary
1330  #change foo.fred.pebbles to 3 and foo.fred.friend to "barney"
1331  mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) )
1332  """
1333  if func is not None and len(kw) != 0:
1334  raise TypeError("toModify takes either two arguments or one argument and key/value pairs")
1335  if not self.isChosen():
1336  return
1337  if func is not None:
1338  func(obj)
1339  else:
1340  temp =_ParameterModifier(kw)
1341  temp(obj)
def toModify(self, obj, func=None, kw)
Definition: Config.py:1320
def isChosen(self)
Definition: Config.py:1369
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 1342 of file Config.py.

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

1342  def toReplaceWith(self,toObj,fromObj):
1343  """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj
1344  """
1345  if type(fromObj) != type(toObj):
1346  raise TypeError("toReplaceWith requires both arguments to be the same class type")
1347  if not self.isChosen():
1348  return
1349  if isinstance(fromObj,_ModuleSequenceType):
1350  toObj._seq = fromObj._seq
1351  toObj._tasks = fromObj._tasks
1352  elif isinstance(fromObj,Task):
1353  toObj._collection = fromObj._collection
1354  elif isinstance(fromObj,_Parameterizable):
1355  #clear old items just incase fromObj is not a complete superset of toObj
1356  for p in toObj.parameterNames_():
1357  delattr(toObj,p)
1358  for p in fromObj.parameterNames_():
1359  setattr(toObj,p,getattr(fromObj,p))
1360  if isinstance(fromObj,_TypedParameterizable):
1361  toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1362 
1363  else:
1364  raise TypeError("toReplaceWith does not work with type "+str(type(toObj)))
1365 
def toReplaceWith(self, toObj, fromObj)
Definition: Config.py:1342
def isChosen(self)
Definition: Config.py:1369

Member Data Documentation

Config.Modifier.__chosen
private
Config.Modifier.__processModifiers
private

Definition at line 1312 of file Config.py.