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

Constructor & Destructor Documentation

def Config.Modifier.__init__ (   self)

Definition at line 1370 of file Config.py.

1370  def __init__(self):
1372  self.__chosen = False
def __init__(self)
Definition: Config.py:1370

Member Function Documentation

def Config.Modifier.__and__ (   self,
  other 
)

Definition at line 1442 of file Config.py.

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

Definition at line 1444 of file Config.py.

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

Definition at line 1446 of file Config.py.

Referenced by LumiList.LumiList.__add__().

1446  def __or__(self, other):
1447  return _OrModifier(self,other)
def __or__(self, other)
Definition: Config.py:1446
def Config.Modifier._isChosen (   self)
private
def Config.Modifier._isOrContains (   self,
  other 
)
private

Definition at line 1448 of file Config.py.

Referenced by Config.ModifierChain.__copyIfExclude().

1448  def _isOrContains(self, other):
1449  return self == other
1450 
1451 
def _isOrContains(self, other)
Definition: Config.py:1448
def Config.Modifier._setChosen (   self)
private
Should only be called by cms.Process instances

Definition at line 1437 of file Config.py.

References Config.Modifier.__chosen.

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

Definition at line 1401 of file Config.py.

References patCandidates_cff.func, and groupFilesInBlocks.temp.

1401  def _toModify(obj,func,**kw):
1402  if func is not None:
1403  func(obj)
1404  else:
1405  temp =_ParameterModifier(kw)
1406  temp(obj)
def _toModify(obj, func, kw)
Definition: Config.py:1401
def Config.Modifier._toModifyCheck (   obj,
  func,
  kw 
)
staticprivate

Definition at line 1380 of file Config.py.

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

Definition at line 1419 of file Config.py.

References str.

1419  def _toReplaceWith(toObj,fromObj):
1420  if isinstance(fromObj,_ModuleSequenceType):
1421  toObj._seq = fromObj._seq
1422  toObj._tasks = fromObj._tasks
1423  elif isinstance(fromObj,Task):
1424  toObj._collection = fromObj._collection
1425  elif isinstance(fromObj,_Parameterizable):
1426  #clear old items just incase fromObj is not a complete superset of toObj
1427  for p in toObj.parameterNames_():
1428  delattr(toObj,p)
1429  for p in fromObj.parameterNames_():
1430  setattr(toObj,p,getattr(fromObj,p))
1431  if isinstance(fromObj,_TypedParameterizable):
1432  toObj._TypedParameterizable__type = fromObj._TypedParameterizable__type
1433 
1434  else:
1435  raise TypeError("toReplaceWith does not work with type "+str(type(toObj)))
1436 
def _toReplaceWith(toObj, fromObj)
Definition: Config.py:1419
#define str(s)
def Config.Modifier._toReplaceWithCheck (   toObj,
  fromObj 
)
staticprivate

Definition at line 1408 of file Config.py.

1408  def _toReplaceWithCheck(toObj,fromObj):
1409  if not isinstance(fromObj, type(toObj)):
1410  raise TypeError("toReplaceWith requires both arguments to be the same class type")
def _toReplaceWithCheck(toObj, fromObj)
Definition: Config.py:1408
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 1373 of file Config.py.

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

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

1383  def toModify(self,obj, func=None,**kw):
1384  """This is used to register an action to be performed on the specific object. Two different forms are allowed
1385  Form 1: A callable object (e.g. function) can be passed as the second. This callable object is expected to take one argument
1386  that will be the object passed in as the first argument.
1387  Form 2: A list of parameter name, value pairs can be passed
1388  mod.toModify(foo, fred=cms.int32(7), barney = cms.double(3.14))
1389  This form can also be used to remove a parameter by passing the value of None
1390  #remove the parameter foo.fred
1391  mod.toModify(foo, fred = None)
1392  Additionally, parameters embedded within PSets can also be modified using a dictionary
1393  #change foo.fred.pebbles to 3 and foo.fred.friend to "barney"
1394  mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) )
1395  """
1396  Modifier._toModifyCheck(obj,func,**kw)
1397  if not self._isChosen():
1398  return
1399  Modifier._toModify(obj,func,**kw)
def toModify(self, obj, func=None, kw)
Definition: Config.py:1383
def _isChosen(self)
Definition: Config.py:1440
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 1411 of file Config.py.

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

1411  def toReplaceWith(self,toObj,fromObj):
1412  """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj
1413  """
1414  Modifier._toReplaceWithCheck(toObj,fromObj)
1415  if not self._isChosen():
1416  return
1417  Modifier._toReplaceWith(toObj,fromObj)
def _isChosen(self)
Definition: Config.py:1440
def toReplaceWith(self, toObj, fromObj)
Definition: Config.py:1411

Member Data Documentation

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

Definition at line 1371 of file Config.py.