2 from __future__
import print_function
5 from Configuration.PyReleaseValidation.MatrixReader
import MatrixReader
6 from Configuration.PyReleaseValidation.MatrixRunner
import MatrixRunner
7 from Configuration.PyReleaseValidation.MatrixInjector
import MatrixInjector,performInjectionOptionTest
14 mrd.showRaw(opt.useInput, opt.refRel, opt.fromScratch, opt.raw, opt.step1Only, selected=opt.testList)
23 mrd.prepare(opt.useInput, opt.refRel, opt.fromScratch)
27 definedSet = set([dwf.numId
for dwf
in mrd.workFlows])
28 testSet = set(opt.testList)
29 undefSet = testSet - definedSet
30 if len(undefSet)>0:
raise ValueError(
'Undefined workflows: '+
', '.
join(
map(str,list(undefSet))))
34 mrd.show(opt.testList, opt.extended, opt.cafVeto)
35 if opt.testList :
print(
'testListected items:', opt.testList)
37 mRunnerHi =
MatrixRunner(mrd.workFlows, opt.nProcs, opt.nThreads)
38 ret = mRunnerHi.runTests(opt)
42 print(
'Cannot go on with wmagent injection with failing workflows')
44 wfInjector =
MatrixInjector(opt,mode=opt.wmcontrol,options=opt.wmoptions)
45 ret= wfInjector.prepare(mrd,
54 if __name__ ==
'__main__':
95 'jetmc': [5.1, 13, 15, 25, 38, 39],
96 'metmc' : [5.1, 15, 25, 37, 38, 39],
97 'muonmc' : [5.1, 124.4, 124.5, 20, 21, 22, 23, 25, 30],
102 usage =
'usage: runTheMatrix.py --show -s '
104 parser = optparse.OptionParser(usage)
106 parser.add_option(
'-b',
'--batchName',
107 help=
'relval batch: suffix to be appended to Campaign name',
112 parser.add_option(
'-m',
'--memoryOffset',
113 help=
'memory of the wf for single core',
117 parser.add_option(
'--addMemPerCore',
118 help=
'increase of memory per each n > 1 core: memory(n_core) = memoryOffset + (n_core-1) * memPerCore',
122 parser.add_option(
'-j',
'--nproc',
123 help=
'number of processes. 0 Will use 4 processes, not execute anything but create the wfs',
127 parser.add_option(
'-t',
'--nThreads',
128 help=
'number of threads per process to use in cmsRun.',
132 parser.add_option(
'--nStreams',
133 help=
'number of streams to use in cmsRun.',
137 parser.add_option(
'--numberEventsInLuminosityBlock',
138 help=
'number of events in a luminosity block',
139 dest=
'numberEventsInLuminosityBlock',
143 parser.add_option(
'-n',
'--showMatrix',
144 help=
'Only show the worflows. Use --ext to show more',
149 parser.add_option(
'-e',
'--extended',
150 help=
'Show details of workflows, used with --show',
155 parser.add_option(
'-s',
'--selected',
156 help=
'Run a pre-defined selected matrix of wf. Deprecated, please use -l limited',
161 parser.add_option(
'-l',
'--list',
162 help=
'Coma separated list of workflow to be shown or ran. Possible keys are also '+
str(predefinedSet.keys())+
'. and wild card like muon, or mc',
166 parser.add_option(
'-r',
'--raw',
167 help=
'Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)',
170 parser.add_option(
'-i',
'--useInput',
171 help=
'Use recyling where available. Either all, or a coma separated list of wf number.',
175 parser.add_option(
'-w',
'--what',
176 help=
'Specify the set to be used. Argument must be the name of the set (standard, pileup,...)',
180 parser.add_option(
'--step1',
181 help=
'Used with --raw. Limit the production to step1',
185 parser.add_option(
'--maxSteps',
186 help=
'Only run maximum on maxSteps. Used when we are only interested in first n steps.',
191 parser.add_option(
'--fromScratch',
192 help=
'Coma separated list of wf to be run without recycling. all is not supported as default.',
196 parser.add_option(
'--refRelease',
197 help=
'Allow to modify the recycling dataset version',
201 parser.add_option(
'--wmcontrol',
202 help=
'Create the workflows for injection to WMAgent. In the WORKING. -wmcontrol init will create the the workflows, -wmcontrol test will dryRun a test, -wmcontrol submit will submit to wmagent',
203 choices=[
'init',
'test',
'submit',
'force'],
207 parser.add_option(
'--revertDqmio',
208 help=
'When submitting workflows to wmcontrol, force DQM outout to use pool and not DQMIO',
209 choices=[
'yes',
'no'],
213 parser.add_option(
'--optionswm',
214 help=
'Specify a few things for wm injection',
217 parser.add_option(
'--keep',
218 help=
'allow to specify for which coma separated steps the output is needed',
220 parser.add_option(
'--label',
221 help=
'allow to give a special label to the output dataset name',
223 parser.add_option(
'--command',
224 help=
'provide a way to add additional command to all of the cmsDriver commands in the matrix',
228 parser.add_option(
'--apply',
229 help=
'allow to use the --command only for 1 coma separeated',
232 parser.add_option(
'--workflow',
233 help=
'define a workflow to be created or altered from the matrix',
238 parser.add_option(
'--dryRun',
239 help=
'do not run the wf at all',
244 parser.add_option(
'--testbed',
245 help=
'workflow injection to cmswebtest (you need dedicated rqmgr account)',
250 parser.add_option(
'--noCafVeto',
251 help=
'Run from any source, ignoring the CAF label',
256 parser.add_option(
'--overWrite',
257 help=
'Change the content of a step for another. List of pairs.',
261 parser.add_option(
'--noRun',
262 help=
'Remove all run list selection from wfs',
267 parser.add_option(
'--das-options',
268 help=
'Options to be passed to dasgoclient.',
273 parser.add_option(
'--job-reports',
274 help=
'Dump framework job reports',
279 parser.add_option(
'--ibeos',
280 help=
'Use IB EOS site configuration',
285 parser.add_option(
'--sites',
286 help=
'Run DAS query to get data from a specific site (default is T2_CH_CERN). Set it to empty string to search all sites.',
288 default=
'T2_CH_CERN',
291 parser.add_option(
'--dbs-url',
292 help=
'Overwrite DbsUrl value in JSON submitted to ReqMgr2',
297 opt,args = parser.parse_args()
298 os.environ[
"CMSSW_DAS_QUERY_SITES"]=opt.dasSites
300 try:
from commands
import getstatusoutput
as run_cmd
301 except:
from subprocess
import getstatusoutput
as run_cmd
303 ibeos_cache = os.path.join(os.getenv(
"LOCALRT"),
"ibeos_cache.txt")
304 if not os.path.exists(ibeos_cache):
305 err, out = run_cmd(
"curl -L -s -o %s https://raw.githubusercontent.com/cms-sw/cms-sw.github.io/master/das_queries/ibeos.txt" % ibeos_cache)
307 run_cmd(
"rm -f %s" % ibeos_cache)
308 print(
"Error: Unable to download ibeos cache information")
312 for cmssw_env
in [
"CMSSW_BASE",
"CMSSW_RELEASE_BASE" ]:
313 cmssw_base = os.getenv(cmssw_env,
None)
314 if not cmssw_base:
continue
315 cmssw_base = os.path.join(cmssw_base,
"src/Utilities/General/ibeos")
316 if os.path.exists(cmssw_base):
317 os.environ[
"PATH"]=cmssw_base+
":"+os.getenv(
"PATH")
318 os.environ[
"CMS_PATH"]=
"/cvmfs/cms-ib.cern.ch"
319 os.environ[
"CMSSW_USE_IBEOS"]=
"true"
320 print(
">> WARNING: You are using SITECONF from /cvmfs/cms-ib.cern.ch")
323 print(
'Deprecated, please use -l limited')
324 if opt.testList: opt.testList+=
',limited'
325 else: opt.testList=
'limited'
333 opt.apply=
map(stepOrIndex,opt.apply.split(
','))
335 opt.keep=
map(stepOrIndex,opt.keep.split(
','))
341 for entry
in opt.testList.split(
','):
342 if not entry:
continue
344 for k
in predefinedSet:
345 if k.lower().startswith(entry.lower())
or k.lower().endswith(entry.lower()):
346 testList.extend(predefinedSet[k])
351 testList.append(
float(entry))
353 print(entry,
'is not a possible selected entry')
355 opt.testList = list(set(testList))
358 if opt.useInput: opt.useInput = opt.useInput.split(
',')
359 if opt.fromScratch: opt.fromScratch = opt.fromScratch.split(
',')
360 if opt.nProcs: opt.nProcs=
int(opt.nProcs)
361 if opt.nThreads: opt.nThreads=
int(opt.nThreads)
362 if opt.nStreams: opt.nStreams=
int(opt.nStreams)
363 if (opt.numberEventsInLuminosityBlock): opt.numberEventsInLuminosityBlock=
int(opt.numberEventsInLuminosityBlock)
364 if (opt.memoryOffset): opt.memoryOffset=
int(opt.memoryOffset)
365 if (opt.memPerCore): opt.memPerCore=
int(opt.memPerCore)
370 opt.overWrite=eval(opt.overWrite)
372 if opt.raw
and opt.show: