Classes | |
class | TestModuleCommand |
Functions | |
def | _build_options |
def | convertToUnscheduled |
def | getHltConfiguration |
def | loadHltConfiguration |
def | removeModulesNotOnAPathExcluding |
def Utilities::_build_options | ( | args | ) | [private] |
Definition at line 6 of file Utilities.py.
def Utilities::convertToUnscheduled | ( | proc | ) |
Definition at line 27 of file Utilities.py.
00028 : 00029 import FWCore.ParameterSet.Config as cms 00030 """Given a 'Process', convert from scheduled execution to unscheduled. This is done by 00031 1. Removing all modules not on Paths or EndPaths 00032 2. Pulling all EDProducers off of all Paths 00033 3. Dropping any paths which are now empty 00034 4. Fixing up the Schedule if needed 00035 """ 00036 proc.prune() 00037 if not hasattr(proc,'options'): 00038 proc.options = cms.untracked.PSet() 00039 proc.options.allowUnscheduled = cms.untracked.bool(True) 00040 l = proc.paths 00041 droppedPaths =[] 00042 #have to get them now since switching them after the 00043 # paths have been changed gives null labels 00044 if proc.schedule: 00045 pathNamesInScheduled = [p.label_() for p in proc.schedule] 00046 else: 00047 pathNamesInScheduled = False 00048 00049 for pName,p in l.iteritems(): 00050 nodes = [] 00051 v = cms.ModuleNodeVisitor(nodes) 00052 p.visit(v) 00053 names = [node.label_() for node in nodes] 00054 remaining =[] 00055 for n in names: 00056 if not isinstance(getattr(proc,n), cms.EDProducer): 00057 remaining.append(n) 00058 if remaining: 00059 p=getattr(proc,remaining[0]) 00060 for m in remaining[1:]: 00061 p+=getattr(proc,m) 00062 setattr(proc,pName,cms.Path(p)) 00063 else: 00064 delattr(proc,pName) 00065 droppedPaths.append(pName) 00066 if droppedPaths and proc.schedule: 00067 for p in droppedPaths: 00068 if p in pathNamesInScheduled: 00069 pathNamesInScheduled.remove(p) 00070 proc.schedule = cms.Schedule([getattr(proc,p) for p in pathNamesInScheduled]) 00071
def Utilities::getHltConfiguration | ( | menu, | |
args | |||
) |
Definition at line 13 of file Utilities.py.
def Utilities::loadHltConfiguration | ( | process, | |
menu, | |||
args | |||
) |
Definition at line 23 of file Utilities.py.
def Utilities::removeModulesNotOnAPathExcluding | ( | process, | |
keepList = () |
|||
) |
Given a 'process', find all modules (EDProducers,EDFilters,EDAnalyzers,OutputModules) and remove them if they do not appear on a Path or EndPath. One can optionally pass in a list of modules which even if they are not on a Path or EndPath you wish to have stay in the configuration [useful for unscheduled execution].
Definition at line 1 of file Utilities.py.
00002 : 00003 """Given a 'process', find all modules (EDProducers,EDFilters,EDAnalyzers,OutputModules) 00004 and remove them if they do not appear on a Path or EndPath. One can optionally pass in 00005 a list of modules which even if they are not on a Path or EndPath you wish to have stay 00006 in the configuration [useful for unscheduled execution]. 00007 """ 00008 allMods=set((x for x in process.producers_().iterkeys())) 00009 allMods.update((x for x in process.filters_().iterkeys())) 00010 allMods.update((x for x in process.analyzers_().iterkeys())) 00011 allMods.update((x for x in process.outputModules_().iterkeys())) 00012 00013 modulesOnPaths = set() 00014 for p in process.paths_(): 00015 modulesOnPaths.update( (x for x in getattr(process,p).moduleNames())) 00016 for p in process.endpaths_(): 00017 modulesOnPaths.update( (x for x in getattr(process,p).moduleNames())) 00018 00019 notOnPaths = allMods.difference(modulesOnPaths) 00020 00021 keepModuleNames = set( (x.label_() for x in keepList) ) 00022 00023 getRidOf = notOnPaths.difference(keepModuleNames) 00024 00025 for n in getRidOf: 00026 delattr(process,n)