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

Constructor & Destructor Documentation

def Config.Modifier.__init__ (   self)

Definition at line 1307 of file Config.py.

1307  def __init__(self):
1309  self.__chosen = False
def __init__(self)
Definition: Config.py:1307

Member Function Documentation

def Config.Modifier.__and__ (   self,
  other 
)

Definition at line 1367 of file Config.py.

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

Definition at line 1369 of file Config.py.

Referenced by Config.ModifierChain.__copyIfExclude().

1369  def _isOrContains(self, other):
1370  return self == other
1371 
1372 
def _isOrContains(self, other)
Definition: Config.py:1369
def Config.Modifier._setChosen (   self)
private
Should only be called by cms.Process instances

Definition at line 1362 of file Config.py.

References Config.Modifier.__chosen.

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

Definition at line 1365 of file Config.py.

References Config.Modifier.__chosen.

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

1365  def isChosen(self):
1366  return self.__chosen
def isChosen(self)
Definition: Config.py:1365
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 1310 of file Config.py.

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

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

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

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

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

Member Data Documentation

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

Definition at line 1308 of file Config.py.