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

Constructor & Destructor Documentation

def Config.Modifier.__init__ (   self)

Definition at line 1341 of file Config.py.

1341  def __init__(self):
1343  self.__chosen = False
def __init__(self)
Definition: Config.py:1341

Member Function Documentation

def Config.Modifier.__and__ (   self,
  other 
)

Definition at line 1413 of file Config.py.

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

Definition at line 1415 of file Config.py.

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

Definition at line 1417 of file Config.py.

Referenced by LumiList.LumiList.__add__().

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

Definition at line 1419 of file Config.py.

Referenced by Config.ModifierChain.__copyIfExclude().

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

Definition at line 1408 of file Config.py.

References Config.Modifier.__chosen.

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

Definition at line 1372 of file Config.py.

References patCandidates_cff.func, and groupFilesInBlocks.temp.

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

Definition at line 1351 of file Config.py.

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

Definition at line 1390 of file Config.py.

References str.

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

Definition at line 1379 of file Config.py.

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

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

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

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

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

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

Member Data Documentation

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

Definition at line 1342 of file Config.py.