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 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)
 

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

Constructor & Destructor Documentation

def Config.Modifier.__init__ (   self)

Definition at line 1340 of file Config.py.

1340  def __init__(self):
1342  self.__chosen = False
def __init__(self)
Definition: Config.py:1340

Member Function Documentation

def Config.Modifier.__and__ (   self,
  other 
)

Definition at line 1412 of file Config.py.

1412  def __and__(self, other):
1413  return _AndModifier(self,other)
def __and__(self, other)
Definition: Config.py:1412
def Config.Modifier.__invert__ (   self)

Definition at line 1414 of file Config.py.

1414  def __invert__(self):
1415  return _InvertModifier(self)
def __invert__(self)
Definition: Config.py:1414
def Config.Modifier.__or__ (   self,
  other 
)

Definition at line 1416 of file Config.py.

Referenced by LumiList.LumiList.__add__().

1416  def __or__(self, other):
1417  return _OrModifier(self,other)
def __or__(self, other)
Definition: Config.py:1416
def Config.Modifier._isOrContains (   self,
  other 
)
private

Definition at line 1418 of file Config.py.

Referenced by Config.ModifierChain.__copyIfExclude().

1418  def _isOrContains(self, other):
1419  return self == other
1420 
1421 
def _isOrContains(self, other)
Definition: Config.py:1418
def Config.Modifier._setChosen (   self)
private
Should only be called by cms.Process instances

Definition at line 1407 of file Config.py.

References Config.Modifier.__chosen.

1407  def _setChosen(self):
1408  """Should only be called by cms.Process instances"""
1409  self.__chosen = True
def _setChosen(self)
Definition: Config.py:1407
def Config.Modifier._toModify (   obj,
  func,
  kw 
)
staticprivate

Definition at line 1371 of file Config.py.

References patCandidates_cff.func, and groupFilesInBlocks.temp.

1371  def _toModify(obj,func,**kw):
1372  if func is not None:
1373  func(obj)
1374  else:
1375  temp =_ParameterModifier(kw)
1376  temp(obj)
def _toModify(obj, func, kw)
Definition: Config.py:1371
def Config.Modifier._toModifyCheck (   obj,
  func,
  kw 
)
staticprivate

Definition at line 1350 of file Config.py.

1350  def _toModifyCheck(obj,func,**kw):
1351  if func is not None and len(kw) != 0:
1352  raise TypeError("toModify takes either two arguments or one argument and key/value pairs")
def _toModifyCheck(obj, func, kw)
Definition: Config.py:1350
def Config.Modifier._toReplaceWith (   toObj,
  fromObj 
)
staticprivate

Definition at line 1389 of file Config.py.

References str.

1389  def _toReplaceWith(toObj,fromObj):
1390  if isinstance(fromObj,_ModuleSequenceType):
1391  toObj._seq = fromObj._seq
1392  toObj._tasks = fromObj._tasks
1393  elif isinstance(fromObj,Task):
1394  toObj._collection = fromObj._collection
1395  elif isinstance(fromObj,_Parameterizable):
1396  #clear old items just incase fromObj is not a complete superset of toObj
1397  for p in toObj.parameterNames_():
1398  delattr(toObj,p)
1399  for p in fromObj.parameterNames_():
1400  setattr(toObj,p,getattr(fromObj,p))
1401  if isinstance(fromObj,_TypedParameterizable):
1402  toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1403 
1404  else:
1405  raise TypeError("toReplaceWith does not work with type "+str(type(toObj)))
1406 
def _toReplaceWith(toObj, fromObj)
Definition: Config.py:1389
#define str(s)
def Config.Modifier._toReplaceWithCheck (   toObj,
  fromObj 
)
staticprivate

Definition at line 1378 of file Config.py.

1378  def _toReplaceWithCheck(toObj,fromObj):
1379  if not isinstance(fromObj, type(toObj)):
1380  raise TypeError("toReplaceWith requires both arguments to be the same class type")
def _toReplaceWithCheck(toObj, fromObj)
Definition: Config.py:1378
def Config.Modifier.isChosen (   self)
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 1343 of file Config.py.

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

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

1353  def toModify(self,obj, func=None,**kw):
1354  """This is used to register an action to be performed on the specific object. Two different forms are allowed
1355  Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
1356  that will be the object passed in as the first argument.
1357  Form 2: A list of parameter name, value pairs can be passed
1358  mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
1359  This form can also be used to remove a parameter by passing the value of None
1360  #remove the parameter foo.fred
1361  mod.toModify(foo, fred = None)
1362  Additionally, parameters embedded within PSets can also be modified using a dictionary
1363  #change foo.fred.pebbles to 3 and foo.fred.friend to "barney"
1364  mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) )
1365  """
1366  Modifier._toModifyCheck(obj,func,**kw)
1367  if not self.isChosen():
1368  return
1369  Modifier._toModify(obj,func,**kw)
def toModify(self, obj, func=None, kw)
Definition: Config.py:1353
def isChosen(self)
Definition: Config.py:1410
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 1381 of file Config.py.

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

1381  def toReplaceWith(self,toObj,fromObj):
1382  """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj
1383  """
1384  Modifier._toReplaceWithCheck(toObj,fromObj)
1385  if not self.isChosen():
1386  return
1387  Modifier._toReplaceWith(toObj,fromObj)
def toReplaceWith(self, toObj, fromObj)
Definition: Config.py:1381
def isChosen(self)
Definition: Config.py:1410

Member Data Documentation

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

Definition at line 1341 of file Config.py.