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 definedWf = [dwf.numId
for dwf
in mrd.workFlows]
28 definedSet = set(definedWf)
29 testSet = set(opt.testList)
30 undefSet = testSet - definedSet
31 if len(undefSet)>0:
raise ValueError(
'Undefined workflows: '+
', '.
join(map(str,list(undefSet))))
32 duplicates = [wf
for wf
in testSet
if definedWf.count(wf)>1 ]
33 if len(duplicates)>0:
raise ValueError(
'Duplicated workflows: '+
', '.
join(map(str,list(duplicates))))
37 mrd.show(opt.testList, opt.extended, opt.cafVeto)
38 if opt.testList :
print(
'testListected items:', opt.testList)
40 mRunnerHi =
MatrixRunner(mrd.workFlows, opt.nProcs, opt.nThreads)
41 ret = mRunnerHi.runTests(opt)
45 print(
'Cannot go on with wmagent injection with failing workflows')
47 wfInjector =
MatrixInjector(opt,mode=opt.wmcontrol,options=opt.wmoptions)
48 ret= wfInjector.prepare(mrd,
57 if __name__ ==
'__main__':
104 'jetmc': [5.1, 13, 15, 25, 38, 39],
105 'metmc' : [5.1, 15, 25, 37, 38, 39],
106 'muonmc' : [5.1, 124.4, 124.5, 20, 21, 22, 23, 25, 30],
111 usage =
'usage: runTheMatrix.py --show -s '
113 parser = argparse.ArgumentParser(usage,formatter_class=argparse.ArgumentDefaultsHelpFormatter)
115 parser.add_argument(
'-b',
'--batchName',
116 help=
'relval batch: suffix to be appended to Campaign name',
120 parser.add_argument(
'-m',
'--memoryOffset',
121 help=
'memory of the wf for single core',
126 parser.add_argument(
'--addMemPerCore',
127 help=
'increase of memory per each n > 1 core: memory(n_core) = memoryOffset + (n_core-1) * memPerCore',
132 parser.add_argument(
'-j',
'--nproc',
133 help=
'number of processes. 0 Will use 4 processes, not execute anything but create the wfs',
138 parser.add_argument(
'-t',
'--nThreads',
139 help=
'number of threads per process to use in cmsRun.',
144 parser.add_argument(
'--nStreams',
145 help=
'number of streams to use in cmsRun.',
150 parser.add_argument(
'--numberEventsInLuminosityBlock',
151 help=
'number of events in a luminosity block',
152 dest=
'numberEventsInLuminosityBlock',
156 parser.add_argument(
'-n',
'--showMatrix',
157 help=
'Only show the worflows. Use --ext to show more',
162 parser.add_argument(
'-e',
'--extended',
163 help=
'Show details of workflows, used with --show',
168 parser.add_argument(
'-s',
'--selected',
169 help=
'Run a pre-defined selected matrix of wf. Deprecated, please use -l limited',
174 parser.add_argument(
'-l',
'--list',
175 help=
'Comma separated list of workflow to be shown or ran. Possible keys are also '+
str(predefinedSet.keys())+
'. and wild card like muon, or mc',
179 parser.add_argument(
'-r',
'--raw',
180 help=
'Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)',
183 parser.add_argument(
'-i',
'--useInput',
184 help=
'Use recyling where available. Either all, or a comma separated list of wf number.',
186 type=
lambda x: x.split(
','),
189 parser.add_argument(
'-w',
'--what',
190 help=
'Specify the set to be used. Argument must be the name of a set (standard, pileup,...) or multiple sets separated by commas (--what standard,pileup )',
194 parser.add_argument(
'--step1',
195 help=
'Used with --raw. Limit the production to step1',
199 parser.add_argument(
'--maxSteps',
200 help=
'Only run maximum on maxSteps. Used when we are only interested in first n steps.',
205 parser.add_argument(
'--fromScratch',
206 help=
'Comma separated list of wf to be run without recycling. all is not supported as default.',
208 type=
lambda x: x.split(
','),
211 parser.add_argument(
'--refRelease',
212 help=
'Allow to modify the recycling dataset version',
216 parser.add_argument(
'--wmcontrol',
217 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',
218 choices=[
'init',
'test',
'submit',
'force'],
222 parser.add_argument(
'--revertDqmio',
223 help=
'When submitting workflows to wmcontrol, force DQM outout to use pool and not DQMIO',
224 choices=[
'yes',
'no'],
228 parser.add_argument(
'--optionswm',
229 help=
'Specify a few things for wm injection',
233 parser.add_argument(
'--keep',
234 help=
'allow to specify for which comma separated steps the output is needed',
237 parser.add_argument(
'--label',
238 help=
'allow to give a special label to the output dataset name',
241 parser.add_argument(
'--command',
242 help=
'provide a way to add additional command to all of the cmsDriver commands in the matrix',
247 parser.add_argument(
'--apply',
248 help=
'allow to use the --command only for 1 comma separeated',
252 parser.add_argument(
'--workflow',
253 help=
'define a workflow to be created or altered from the matrix',
258 parser.add_argument(
'--dryRun',
259 help=
'do not run the wf at all',
264 parser.add_argument(
'--testbed',
265 help=
'workflow injection to cmswebtest (you need dedicated rqmgr account)',
270 parser.add_argument(
'--noCafVeto',
271 help=
'Run from any source, ignoring the CAF label',
274 action=
'store_false')
276 parser.add_argument(
'--overWrite',
277 help=
'Change the content of a step for another. List of pairs.',
281 parser.add_argument(
'--noRun',
282 help=
'Remove all run list selection from wfs',
287 parser.add_argument(
'--das-options',
288 help=
'Options to be passed to dasgoclient.',
293 parser.add_argument(
'--job-reports',
294 help=
'Dump framework job reports',
299 parser.add_argument(
'--ibeos',
300 help=
'Use IB EOS site configuration',
305 parser.add_argument(
'--sites',
306 help=
'Run DAS query to get data from a specific site. Set it to empty string to search all sites.',
308 default=
'T2_CH_CERN',
311 parser.add_argument(
'--interactive',
312 help=
"Open the Matrix interactive shell",
316 parser.add_argument(
'--dbs-url',
317 help=
'Overwrite DbsUrl value in JSON submitted to ReqMgr2',
322 gpugroup = parser.add_argument_group(
'GPU-related options',
'These options are only meaningful when --gpu is used, and is not set to forbidden.')
324 gpugroup.add_argument(
'--gpu',
'--requires-gpu',
325 help=
'Enable GPU workflows. Possible options are "forbidden" (default), "required" (implied if no argument is given), or "optional".',
327 choices=[
'forbidden',
'optional',
'required'],
333 gpugroup.add_argument(
'--gpu-memory',
334 help=
'Specify the minimum amount of GPU memory required by the job, in MB.',
339 gpugroup.add_argument(
'--cuda-capabilities',
340 help=
'Specify a comma-separated list of CUDA "compute capabilities", or GPU hardware architectures, that the job can use.',
341 dest=
'CUDACapabilities',
342 type=
lambda x: x.split(
','),
343 default=
'6.0,6.1,6.2,7.0,7.2,7.5,8.0,8.6')
346 cudart_version =
None
347 libcudart = os.path.realpath(os.path.expandvars(
'$CMSSW_RELEASE_BASE/external/$SCRAM_ARCH/lib/libcudart.so'))
348 if os.path.isfile(libcudart):
349 cudart_basename = os.path.basename(libcudart)
350 cudart_version =
'.'.
join(cudart_basename.split(
'.')[2:4])
351 gpugroup.add_argument(
'--cuda-runtime',
352 help=
'Specify major and minor version of the CUDA runtime used to build the application.',
354 default=cudart_version)
356 gpugroup.add_argument(
'--force-gpu-name',
357 help=
'Request a specific GPU model, e.g. "Tesla T4" or "NVIDIA GeForce RTX 2080". The default behaviour is to accept any supported GPU.',
361 gpugroup.add_argument(
'--force-cuda-driver-version',
362 help=
'Request a specific CUDA driver version, e.g. 470.57.02. The default behaviour is to accept any supported CUDA driver version.',
363 dest=
'CUDADriverVersion',
366 gpugroup.add_argument(
'--force-cuda-runtime-version',
367 help=
'Request a specific CUDA runtime version, e.g. 11.4. The default behaviour is to accept any supported CUDA runtime version.',
368 dest=
'CUDARuntimeVersion',
371 opt = parser.parse_args()
372 if opt.command: opt.command =
' '.
join(opt.command)
373 os.environ[
"CMSSW_DAS_QUERY_SITES"]=opt.dasSites
375 from subprocess
import getstatusoutput
as run_cmd
377 ibeos_cache = os.path.join(os.getenv(
"LOCALRT"),
"ibeos_cache.txt")
378 if not os.path.exists(ibeos_cache):
379 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)
381 run_cmd(
"rm -f %s" % ibeos_cache)
382 print(
"Error: Unable to download ibeos cache information")
386 for cmssw_env
in [
"CMSSW_BASE",
"CMSSW_RELEASE_BASE" ]:
387 cmssw_base = os.getenv(cmssw_env,
None)
388 if not cmssw_base:
continue
389 cmssw_base = os.path.join(cmssw_base,
"src/Utilities/General/ibeos")
390 if os.path.exists(cmssw_base):
391 os.environ[
"PATH"]=cmssw_base+
":"+os.getenv(
"PATH")
392 os.environ[
"CMS_PATH"]=
"/cvmfs/cms-ib.cern.ch"
393 os.environ[
"CMSSW_USE_IBEOS"]=
"true"
394 print(
">> WARNING: You are using SITECONF from /cvmfs/cms-ib.cern.ch")
397 print(
'Deprecated, please use -l limited')
398 if opt.testList: opt.testList+=
',limited'
399 else: opt.testList=
'limited'
407 opt.apply=map(stepOrIndex,opt.apply.split(
','))
409 opt.keep=map(stepOrIndex,opt.keep.split(
','))
413 for entry
in opt.testList.split(
','):
414 if not entry:
continue
416 for k
in predefinedSet:
417 if k.lower().startswith(entry.lower())
or k.lower().endswith(entry.lower()):
418 testList.extend(predefinedSet[k])
423 testList.append(float(entry))
425 print(entry,
'is not a possible selected entry')
427 opt.testList = list(set(testList))
432 opt.overWrite=eval(opt.overWrite)
437 intro =
"Welcome to the Matrix (? for help)"
441 cmd.Cmd.__init__(self)
445 for what
in tmp.files:
446 what = what.replace(
'relval_',
'')
447 self.opt_.what = what
449 self.
matrices_[what].prepare(self.opt_.useInput, self.opt_.refRel,
450 self.opt_.fromScratch)
454 """Clear the screen, put prompt at the top"""
458 print(
"Leaving the Matrix")
462 if inp ==
'x' or inp ==
'q':
466 print(
"\n".
join([
"predefined [predef1 [...]]\n",
467 "Run w/o argument, it will print the list of known predefined workflows.",
468 "Run with space-separated predefined workflows, it will print the workflow-ids registered to them"]))
471 if text
and len(text) > 0:
472 return [t
for t
in predefinedSet.keys()
if t.startswith(text)]
474 return predefinedSet.keys()
477 """Print the list of predefined workflows"""
478 print(
"List of predefined workflows")
480 for w
in arg.split():
481 if w
in predefinedSet.keys():
482 print(
"Predefined Set: %s" % w)
483 print(predefinedSet[w])
485 print(
"Unknown Set: %s" % w)
487 print(predefinedSet.keys())
490 print(
"\n".
join([
"showWorkflow [workflow1 [...]]\n",
491 "Run w/o arguments, it will print the list of registered macro-workflows.",
492 "Run with space-separated workflows, it will print the full list of workflow-ids registered to them"]))
495 if text
and len(text) > 0:
496 return [t
for t
in self.matrices_.keys()
if t.startswith(text)]
498 return self.matrices_.keys()
502 print(
"Available workflows:")
503 for k
in self.matrices_.keys():
506 selected = arg.split()
508 if k
not in self.matrices_.keys():
509 print(
"Unknown workflow %s: skipping" % k)
512 wfName, stepNames = wfl.nameId.split(
'+',1)
513 print(
"%s %s %s" % (wfl.numId, wfName, stepNames))
514 print(
"%s contains %d workflows" % (k, len(self.
matrices_[k].workFlows)))
517 print(
"\n".
join([
"searchInWorkflow wfl_name search_regexp\n",
518 "This command will search for a match within all workflows registered to wfl_name.",
519 "The search is done on both the workflow name and the names of steps registered to it."]))
522 if text
and len(text) > 0:
523 return [t
for t
in self.matrices_.keys()
if t.startswith(text)]
525 return self.matrices_.keys()
530 print(
"searchInWorkflow name regexp")
532 if args[0]
not in self.matrices_.keys():
533 print(
"Unknown workflow")
538 pattern = re.compile(args[1])
540 print(
"Failed to compile regexp %s" % args[1])
543 for wfl
in self.
matrices_[args[0]].workFlows:
544 wfName, stepNames = wfl.nameId.split(
'+',1)
545 if re.match(pattern, wfName)
or re.match(pattern, stepNames):
546 print(
"%s %s %s" % (wfl.numId, wfName, stepNames))
548 print(
"Found %d compatible workflows inside %s" % (counter, args[0]))
551 print(
"\n".
join([
"search search_regexp\n",
552 "This command will search for a match within all workflows registered.",
553 "The search is done on both the workflow name and the names of steps registered to it."]))
558 print(
"search regexp")
560 for wfl
in self.matrices_.keys():
564 print(
"\n".
join([
"dumpWorkflowId [wfl-id1 [...]]\n",
565 "Dumps the details (cmsDriver commands for all steps) of the space-separated workflow-ids in input."]))
570 print(
"dumpWorkflowId [wfl-id1 [...]]")
577 for key, mrd
in self.matrices_.items():
578 for wfl
in mrd.workFlows:
579 if wfl.numId == float(wflid):
580 wfName, stepNames = wfl.nameId.split(
'+',1)
583 print(wfl.numId, stepNames)
584 for i,s
in enumerate(wfl.cmds):
586 print(
"\nWorkflow found in %s." % key)
588 print(
"Workflow also found in %s." % key)
595 if opt.raw
and opt.show:
def help_searchInWorkflow
def complete_searchInWorkflow
def complete_showWorkflow
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)
def performInjectionOptionTest