CMS 3D CMS Logo

Classes | Functions | Variables
Utilities Namespace Reference

Classes

class  TestModuleCommand
 

Functions

def _build_options (**args)
 
def convertToSingleModuleEndPaths (process)
 
def convertToUnscheduled (proc)
 
def createTaskWithAllProducersAndFilters (process)
 
def getHltConfiguration (menu, **args)
 
def ignoreAllFiltersOnPath (path)
 
def loadHltConfiguration (process, menu, **args)
 
def moduleLabelsInSequences (*sequences)
 
def modulesInSequences (*sequences)
 

Variables

 __lastCallUnary
 
 _levelInTasks
 
 loadHltConfiguration
 
 onTask
 
 operator
 

Function Documentation

◆ _build_options()

def Utilities._build_options ( **  args)
private

Definition at line 6 of file Utilities.py.

6 def _build_options(**args):
7  options = _options.HLTProcessOptions()
8  for key, val in args.items():
9  setattr(options, key, val)
10  return options
11 
12 

Referenced by getHltConfiguration(), and loadHltConfiguration().

◆ convertToSingleModuleEndPaths()

def Utilities.convertToSingleModuleEndPaths (   process)
Remove the EndPaths in the Process with more than one module
and replace with new EndPaths each with only one module.

Definition at line 69 of file Utilities.py.

70  """Remove the EndPaths in the Process with more than one module
71  and replace with new EndPaths each with only one module.
72  """
73  import FWCore.ParameterSet.Config as cms
74  toRemove =[]
75  added = []
76  for n,ep in process.endpaths_().items():
77  tsks = []
78  ep.visit(cms.TaskVisitor(tsks))
79 
80  names = ep.moduleNames()
81  if 1 == len(names):
82  continue
83  toRemove.append(n)
84  for m in names:
85  epName = m+"_endpath"
86  setattr(process,epName,cms.EndPath(getattr(process,m),*tsks))
87  added.append(epName)
88 
89  s = process.schedule_()
90  if s:
91  pathNames = [p.label_() for p in s]
92  for rName in toRemove:
93  pathNames.remove(rName)
94  for n in added:
95  pathNames.append(n)
96  newS = cms.Schedule(*[getattr(process,n) for n in pathNames])
97  if s._tasks:
98  newS.associate(*s._tasks)
99  process.setSchedule_(newS)
100 
101  for r in toRemove:
102  delattr(process,r)
103 
104 

References mps_monitormerge.items.

Referenced by Utilities.TestModuleCommand.testConvertToSingleModuleEndPaths().

◆ convertToUnscheduled()

def Utilities.convertToUnscheduled (   proc)

Definition at line 46 of file Utilities.py.

46 def convertToUnscheduled(proc):
47  print("covertToUnscheduled is deprecated and no longer needed, and will be removed soon. Please update your configuration.")
48  return proc
49 
50 

References print().

◆ createTaskWithAllProducersAndFilters()

def Utilities.createTaskWithAllProducersAndFilters (   process)

Definition at line 62 of file Utilities.py.

63  from FWCore.ParameterSet.Config import Task
64 
65  l = [ p for p in process.producers.values()]
66  l.extend( (f for f in process.filters.values()) )
67  return Task(*l)
68 

Referenced by Utilities.TestModuleCommand.testCreateTaskWithAllProducersAndFilters().

◆ getHltConfiguration()

def Utilities.getHltConfiguration (   menu,
**  args 
)

Definition at line 13 of file Utilities.py.

13 def getHltConfiguration(menu, **args):
14  args['menu'] = menu
15  args['fragment'] = False
16  options = _build_options(**args)
17 
18  hlt = _imp.new_module('hlt')
19  exec(_confdb.HLTProcess(options).dump(), globals(), hlt.__dict__)
20  return hlt.process
21 
22 

References _build_options(), and submitPVValidationJobs.dump.

◆ ignoreAllFiltersOnPath()

def Utilities.ignoreAllFiltersOnPath (   path)
Given a 'Path', find all EDFilters and wrap them in 'cms.ignore'

Definition at line 2 of file Utilities.py.

2 def ignoreAllFiltersOnPath(path):
3  """Given a 'Path', find all EDFilters and wrap them in 'cms.ignore'
4  """
5  import FWCore.ParameterSet.Config as cms
6  from FWCore.ParameterSet.SequenceTypes import _MutatingSequenceVisitor, _UnarySequenceOperator
7 
8  class IgnoreFilters(object):
9  def __init__(self):
10  self.__lastCallUnary = False
11  self.onTask = False
12  def __call__(self, obj):
13  if self.onTask:
14  return obj
15  elif isinstance(obj,_UnarySequenceOperator):
16  self.__lastCallUnary = True
17  elif obj.isLeaf() and isinstance(obj, cms.EDFilter) and not self.__lastCallUnary:
18  return cms.ignore(obj)
19  else:
20  self.__lastCallUnary = False
21  return obj
22  class IgnoreFiltersVisitor(_MutatingSequenceVisitor):
23  def __init__(self):
24  self.operator = IgnoreFilters()
25  self._levelInTasks = 0
26  super(type(self),self).__init__(self.operator)
27  def enter(self,visitee):
28  if isinstance(visitee, cms.Task):
29  self._levelInTasks += 1
30  self.operator.onTask = (self._levelInTasks > 0)
31  super(IgnoreFiltersVisitor,self).enter(visitee)
32  def leave(self,visitee):
33  if self._levelInTasks > 0:
34  if isinstance(visitee, cms.Task):
35  self._levelInTasks -= 1
36  super(IgnoreFiltersVisitor,self).leave(visitee)
37 
38  mutator = IgnoreFiltersVisitor()
39  path.visit(mutator)
40  if mutator._didApply():
41  path._seq = mutator.result(path)[0]
42  path._tasks.clear()
43  path.associate(*mutator.result(path)[1])
44  return path
45 

References resolutioncreator_cfi.object.

◆ loadHltConfiguration()

def Utilities.loadHltConfiguration (   process,
  menu,
**  args 
)

Definition at line 23 of file Utilities.py.

23 def loadHltConfiguration(process, menu, **args):
24  args['menu'] = menu
25  args['fragment'] = True
26  options = _build_options(**args)
27 
28  hlt = types.ModuleType('hlt')
29  exec(_confdb.HLTProcess(options).dump(), globals(), hlt.__dict__)
30  process.extend( hlt )
31 
32 

References _build_options(), submitPVValidationJobs.dump, and loadHltConfiguration.

◆ moduleLabelsInSequences()

def Utilities.moduleLabelsInSequences ( sequences)

Definition at line 59 of file Utilities.py.

59 def moduleLabelsInSequences(* sequences):
60  return [module.label_() for module in modulesInSequences(* sequences)]
61 

References modulesInSequences().

◆ modulesInSequences()

def Utilities.modulesInSequences ( sequences)

Definition at line 51 of file Utilities.py.

51 def modulesInSequences(* sequences):
52  from FWCore.ParameterSet.SequenceTypes import ModuleNodeVisitor
53  modules = []
54  for sequence in sequences:
55  sequence.visit(ModuleNodeVisitor(modules))
56  return modules
57 
58 

Referenced by moduleLabelsInSequences().

Variable Documentation

◆ __lastCallUnary

Utilities.__lastCallUnary
private

Definition at line 10 of file Utilities.py.

◆ _levelInTasks

Utilities._levelInTasks
private

Definition at line 25 of file Utilities.py.

◆ loadHltConfiguration

Utilities.loadHltConfiguration

Definition at line 34 of file Utilities.py.

Referenced by loadHltConfiguration().

◆ onTask

Utilities.onTask

Definition at line 11 of file Utilities.py.

◆ operator

Utilities.operator
submitPVValidationJobs.dump
dump
Definition: submitPVValidationJobs.py:55
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
Utilities.convertToUnscheduled
def convertToUnscheduled(proc)
Definition: Utilities.py:46
Utilities.ignoreAllFiltersOnPath
def ignoreAllFiltersOnPath(path)
Definition: Utilities.py:2
Utilities._build_options
def _build_options(**args)
Definition: Utilities.py:6
Utilities.createTaskWithAllProducersAndFilters
def createTaskWithAllProducersAndFilters(process)
Definition: Utilities.py:62
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
Utilities.moduleLabelsInSequences
def moduleLabelsInSequences(*sequences)
Definition: Utilities.py:59
Utilities.modulesInSequences
def modulesInSequences(*sequences)
Definition: Utilities.py:51
Utilities.getHltConfiguration
def getHltConfiguration(menu, **args)
Definition: Utilities.py:13
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
Utilities.convertToSingleModuleEndPaths
def convertToSingleModuleEndPaths(process)
Definition: Utilities.py:69
Utilities.loadHltConfiguration
def loadHltConfiguration(process, menu, **args)
Definition: Utilities.py:23
SequenceTypes