5 from __future__
import print_function
6 from builtins
import range
13 from multiprocessing
import Pool
14 from pprint
import pprint
17 if "-i" not in sys.argv:
21 ROOT.gROOT.SetBatch(
True)
25 from PhysicsTools.HeppyCore.framework.looper
import Looper
32 print(
'production done:',
str(result))
36 loop =
runLoop( comp, outDir, copy.copy(sys.modules[configName].config), options)
40 print(
"ERROR processing component %s" % comp.name)
42 print(
"STACK TRACE: ")
43 print(traceback.format_exc())
46 def runLoop( comp, outDir, config, options):
47 fullName =
'/'.
join( [outDir, comp.name ] )
49 config.components = [comp]
50 loop = Looper( fullName,
53 nPrint = options.nprint,
54 timeReport = options.timeReport,
55 quiet = options.quiet)
57 if options.iEvent
is None:
63 iEvent =
int(options.iEvent)
64 loop.process( iEvent )
69 '''Creates the output dir, dealing with the case where dir exists.''' 75 print(
'directory %s already exists' % dir)
77 dirlist = [path
for path
in os.listdir(dir)
if os.path.isdir(
'/'.
join([dir, path]) )]
79 print(
'component list: ')
80 print([comp.name
for comp
in components])
82 print(
'force mode, continue.')
85 while answer
not in [
'Y',
'y',
'yes',
'N',
'n',
'no']:
86 answer = raw_input(
'Continue? [y/n]')
87 if answer.lower().startswith(
'n'):
89 elif answer.lower().startswith(
'y'):
92 raise ValueError(
' '.
join([
'answer can not have this value!',
96 return [l[i:i+n]
for i
in range(0, len(l), n)]
102 if hasattr( comp,
'fineSplitFactor')
and comp.fineSplitFactor>1:
103 subchunks =
list(range(comp.fineSplitFactor))
104 for ichunk, chunk
in enumerate([(f,i)
for f
in comp.files
for i
in subchunks]):
105 newComp = copy.deepcopy(comp)
106 newComp.files = [chunk[0]]
107 newComp.fineSplit = ( chunk[1], comp.fineSplitFactor )
108 newComp.name =
'{name}_Chunk{index}'.
format(name=newComp.name,
110 splitComps.append( newComp )
111 elif hasattr( comp,
'splitFactor')
and comp.splitFactor>1:
112 chunkSize = len(comp.files) / comp.splitFactor
113 if len(comp.files) % comp.splitFactor:
116 for ichunk, chunk
in enumerate(
chunks( comp.files, chunkSize)):
117 newComp = copy.deepcopy(comp)
118 newComp.files = chunk
119 newComp.name =
'{name}_Chunk{index}'.
format(name=newComp.name,
121 splitComps.append( newComp )
123 splitComps.append( comp )
127 _heppyGlobalOptions = {}
130 global _heppyGlobalOptions
131 return _heppyGlobalOptions[name]
if name
in _heppyGlobalOptions
else default
133 global _heppyGlobalOptions
134 _heppyGlobalOptions[name] = value
136 def main( options, args, parser ):
140 print(
'ERROR: please provide the processing name and the component list')
144 if os.path.exists(outDir)
and not os.path.isdir( outDir ):
146 print(
'ERROR: when it exists, first argument must be a directory.')
148 cfgFileName = args[1]
149 if not os.path.isfile( cfgFileName ):
151 print(
'ERROR: second argument must be an existing file (your input cfg).')
156 logging.basicConfig(level=logging.INFO)
161 from PhysicsTools.HeppyCore.framework.heppy_loop
import _heppyGlobalOptions
162 for opt
in options.extraOptions:
164 (key,val) = opt.split(
"=",1)
165 _heppyGlobalOptions[key] = val
167 _heppyGlobalOptions[opt] =
True 169 file = open( cfgFileName,
'r' ) 170 cfg = imp.load_source( 'PhysicsTools.HeppyCore.__cfg_to_run__', cfgFileName, file)
172 selComps = [comp
for comp
in cfg.config.components
if len(comp.files)>0]
173 selComps =
split(selComps)
176 if len(selComps)>options.ntasks:
177 print(
"WARNING: too many threads {tnum}, will just use a maximum of {jnum}.".
format(tnum=len(selComps),jnum=options.ntasks))
182 shutil.copy( cfgFileName, outDir )
183 pool = Pool(processes=
min(len(selComps),options.ntasks))
185 import PhysicsTools.HeppyCore.framework.heppy_loop
as ML
186 for comp
in selComps:
187 print(
'submitting', comp.name)
188 pool.apply_async( ML.runLoopAsync, [comp, outDir,
'PhysicsTools.HeppyCore.__cfg_to_run__', options],
189 callback=ML.callBack)
196 loop =
runLoop( comp, outDir, cfg.config, options )
def runLoopAsync(comp, outDir, configName, options)
S & print(S &os, JobReport::InputFile const &f)
def setHeppyOption(name, value=True)
def runLoop(comp, outDir, config, options)
def main(options, args, parser)
static std::string join(char **cmd)
def createOutputDir(dir, components, force)
def getHeppyOption(name, default=None)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run