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__':
111 'jetmc': [5.1, 13, 15, 25, 38, 39],
112 'metmc' : [5.1, 15, 25, 37, 38, 39],
113 'muonmc' : [5.1, 124.4, 124.5, 20, 21, 22, 23, 25, 30],
118 usage =
'usage: runTheMatrix.py --show -s '
120 parser = argparse.ArgumentParser(usage,formatter_class=argparse.ArgumentDefaultsHelpFormatter)
122 parser.add_argument(
'-b',
'--batchName',
123 help=
'relval batch: suffix to be appended to Campaign name',
127 parser.add_argument(
'-m',
'--memoryOffset',
128 help=
'memory of the wf for single core',
133 parser.add_argument(
'--addMemPerCore',
134 help=
'increase of memory per each n > 1 core: memory(n_core) = memoryOffset + (n_core-1) * memPerCore',
139 parser.add_argument(
'-j',
'--nproc',
140 help=
'number of processes. 0 Will use 4 processes, not execute anything but create the wfs',
145 parser.add_argument(
'-t',
'--nThreads',
146 help=
'number of threads per process to use in cmsRun.',
151 parser.add_argument(
'--nStreams',
152 help=
'number of streams to use in cmsRun.',
157 parser.add_argument(
'--numberEventsInLuminosityBlock',
158 help=
'number of events in a luminosity block',
159 dest=
'numberEventsInLuminosityBlock',
163 parser.add_argument(
'-n',
'--showMatrix',
164 help=
'Only show the worflows. Use --ext to show more',
169 parser.add_argument(
'-e',
'--extended',
170 help=
'Show details of workflows, used with --show',
175 parser.add_argument(
'-s',
'--selected',
176 help=
'Run a pre-defined selected matrix of wf. Deprecated, please use -l limited',
181 parser.add_argument(
'-l',
'--list',
182 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',
186 parser.add_argument(
'-r',
'--raw',
187 help=
'Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)',
190 parser.add_argument(
'-i',
'--useInput',
191 help=
'Use recyling where available. Either all, or a comma separated list of wf number.',
193 type=
lambda x: x.split(
','),
196 parser.add_argument(
'-w',
'--what',
197 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 )',
201 parser.add_argument(
'--step1',
202 help=
'Used with --raw. Limit the production to step1',
206 parser.add_argument(
'--maxSteps',
207 help=
'Only run maximum on maxSteps. Used when we are only interested in first n steps.',
212 parser.add_argument(
'--fromScratch',
213 help=
'Comma separated list of wf to be run without recycling. all is not supported as default.',
215 type=
lambda x: x.split(
','),
218 parser.add_argument(
'--refRelease',
219 help=
'Allow to modify the recycling dataset version',
223 parser.add_argument(
'--wmcontrol',
224 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',
225 choices=[
'init',
'test',
'submit',
'force'],
229 parser.add_argument(
'--revertDqmio',
230 help=
'When submitting workflows to wmcontrol, force DQM outout to use pool and not DQMIO',
231 choices=[
'yes',
'no'],
235 parser.add_argument(
'--optionswm',
236 help=
'Specify a few things for wm injection',
240 parser.add_argument(
'--keep',
241 help=
'allow to specify for which comma separated steps the output is needed',
244 parser.add_argument(
'--label',
245 help=
'allow to give a special label to the output dataset name',
248 parser.add_argument(
'--command',
249 help=
'provide a way to add additional command to all of the cmsDriver commands in the matrix',
254 parser.add_argument(
'--apply',
255 help=
'allow to use the --command only for 1 comma separeated',
259 parser.add_argument(
'--workflow',
260 help=
'define a workflow to be created or altered from the matrix',
265 parser.add_argument(
'--dryRun',
266 help=
'do not run the wf at all',
271 parser.add_argument(
'--testbed',
272 help=
'workflow injection to cmswebtest (you need dedicated rqmgr account)',
277 parser.add_argument(
'--noCafVeto',
278 help=
'Run from any source, ignoring the CAF label',
281 action=
'store_false')
283 parser.add_argument(
'--overWrite',
284 help=
'Change the content of a step for another. List of pairs.',
288 parser.add_argument(
'--noRun',
289 help=
'Remove all run list selection from wfs',
294 parser.add_argument(
'--das-options',
295 help=
'Options to be passed to dasgoclient.',
300 parser.add_argument(
'--job-reports',
301 help=
'Dump framework job reports',
306 parser.add_argument(
'--ibeos',
307 help=
'Use IB EOS site configuration',
312 parser.add_argument(
'--sites',
313 help=
'Run DAS query to get data from a specific site. Set it to empty string to search all sites.',
315 default=
'T2_CH_CERN',
318 parser.add_argument(
'--interactive',
319 help=
"Open the Matrix interactive shell",
323 parser.add_argument(
'--dbs-url',
324 help=
'Overwrite DbsUrl value in JSON submitted to ReqMgr2',
329 gpugroup = parser.add_argument_group(
'GPU-related options',
'These options are only meaningful when --gpu is used, and is not set to forbidden.')
331 gpugroup.add_argument(
'--gpu',
'--requires-gpu',
332 help=
'Enable GPU workflows. Possible options are "forbidden" (default), "required" (implied if no argument is given), or "optional".',
334 choices=[
'forbidden',
'optional',
'required'],
340 gpugroup.add_argument(
'--gpu-memory',
341 help=
'Specify the minimum amount of GPU memory required by the job, in MB.',
346 gpugroup.add_argument(
'--cuda-capabilities',
347 help=
'Specify a comma-separated list of CUDA "compute capabilities", or GPU hardware architectures, that the job can use.',
348 dest=
'CUDACapabilities',
349 type=
lambda x: x.split(
','),
350 default=
'6.0,6.1,6.2,7.0,7.2,7.5,8.0,8.6')
353 cudart_version =
None
354 libcudart = os.path.realpath(os.path.expandvars(
'$CMSSW_RELEASE_BASE/external/$SCRAM_ARCH/lib/libcudart.so'))
355 if os.path.isfile(libcudart):
356 cudart_basename = os.path.basename(libcudart)
357 cudart_version =
'.'.
join(cudart_basename.split(
'.')[2:4])
358 gpugroup.add_argument(
'--cuda-runtime',
359 help=
'Specify major and minor version of the CUDA runtime used to build the application.',
361 default=cudart_version)
363 gpugroup.add_argument(
'--force-gpu-name',
364 help=
'Request a specific GPU model, e.g. "Tesla T4" or "NVIDIA GeForce RTX 2080". The default behaviour is to accept any supported GPU.',
368 gpugroup.add_argument(
'--force-cuda-driver-version',
369 help=
'Request a specific CUDA driver version, e.g. 470.57.02. The default behaviour is to accept any supported CUDA driver version.',
370 dest=
'CUDADriverVersion',
373 gpugroup.add_argument(
'--force-cuda-runtime-version',
374 help=
'Request a specific CUDA runtime version, e.g. 11.4. The default behaviour is to accept any supported CUDA runtime version.',
375 dest=
'CUDARuntimeVersion',
378 opt = parser.parse_args()
379 if opt.command: opt.command =
' '.
join(opt.command)
380 os.environ[
"CMSSW_DAS_QUERY_SITES"]=opt.dasSites
382 from subprocess
import getstatusoutput
as run_cmd
384 ibeos_cache = os.path.join(os.getenv(
"LOCALRT"),
"ibeos_cache.txt")
385 if not os.path.exists(ibeos_cache):
386 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)
388 run_cmd(
"rm -f %s" % ibeos_cache)
389 print(
"Error: Unable to download ibeos cache information")
393 for cmssw_env
in [
"CMSSW_BASE",
"CMSSW_RELEASE_BASE" ]:
394 cmssw_base = os.getenv(cmssw_env,
None)
395 if not cmssw_base:
continue
396 cmssw_base = os.path.join(cmssw_base,
"src/Utilities/General/ibeos")
397 if os.path.exists(cmssw_base):
398 os.environ[
"PATH"]=cmssw_base+
":"+os.getenv(
"PATH")
399 os.environ[
"CMS_PATH"]=
"/cvmfs/cms-ib.cern.ch"
400 os.environ[
"CMSSW_USE_IBEOS"]=
"true"
401 print(
">> WARNING: You are using SITECONF from /cvmfs/cms-ib.cern.ch")
404 print(
'Deprecated, please use -l limited')
405 if opt.testList: opt.testList+=
',limited'
406 else: opt.testList=
'limited'
414 opt.apply=map(stepOrIndex,opt.apply.split(
','))
416 opt.keep=map(stepOrIndex,opt.keep.split(
','))
420 for entry
in opt.testList.split(
','):
421 if not entry:
continue
423 for k
in predefinedSet:
424 if k.lower().startswith(entry.lower())
or k.lower().endswith(entry.lower()):
425 testList.extend(predefinedSet[k])
430 testList.append(float(entry))
432 print(entry,
'is not a possible selected entry')
434 opt.testList = list(set(testList))
439 opt.overWrite=eval(opt.overWrite)
444 intro =
"Welcome to the Matrix (? for help)"
448 cmd.Cmd.__init__(self)
452 for what
in tmp.files:
453 what = what.replace(
'relval_',
'')
454 self.opt_.what = what
456 self.
matrices_[what].prepare(self.opt_.useInput, self.opt_.refRel,
457 self.opt_.fromScratch)
461 """Clear the screen, put prompt at the top"""
465 print(
"Leaving the Matrix")
469 if inp ==
'x' or inp ==
'q':
473 print(
"\n".
join([
"predefined [predef1 [...]]\n",
474 "Run w/o argument, it will print the list of known predefined workflows.",
475 "Run with space-separated predefined workflows, it will print the workflow-ids registered to them"]))
478 if text
and len(text) > 0:
479 return [t
for t
in predefinedSet.keys()
if t.startswith(text)]
481 return predefinedSet.keys()
484 """Print the list of predefined workflows"""
485 print(
"List of predefined workflows")
487 for w
in arg.split():
488 if w
in predefinedSet.keys():
489 print(
"Predefined Set: %s" % w)
490 print(predefinedSet[w])
492 print(
"Unknown Set: %s" % w)
494 print(predefinedSet.keys())
497 print(
"\n".
join([
"showWorkflow [workflow1 [...]]\n",
498 "Run w/o arguments, it will print the list of registered macro-workflows.",
499 "Run with space-separated workflows, it will print the full list of workflow-ids registered to them"]))
502 if text
and len(text) > 0:
503 return [t
for t
in self.matrices_.keys()
if t.startswith(text)]
505 return self.matrices_.keys()
509 print(
"Available workflows:")
510 for k
in self.matrices_.keys():
513 selected = arg.split()
515 if k
not in self.matrices_.keys():
516 print(
"Unknown workflow %s: skipping" % k)
519 wfName, stepNames = wfl.nameId.split(
'+',1)
520 print(
"%s %s %s" % (wfl.numId, wfName, stepNames))
521 print(
"%s contains %d workflows" % (k, len(self.
matrices_[k].workFlows)))
524 print(
"\n".
join([
"searchInWorkflow wfl_name search_regexp\n",
525 "This command will search for a match within all workflows registered to wfl_name.",
526 "The search is done on both the workflow name and the names of steps registered to it."]))
529 if text
and len(text) > 0:
530 return [t
for t
in self.matrices_.keys()
if t.startswith(text)]
532 return self.matrices_.keys()
537 print(
"searchInWorkflow name regexp")
539 if args[0]
not in self.matrices_.keys():
540 print(
"Unknown workflow")
545 pattern = re.compile(args[1])
547 print(
"Failed to compile regexp %s" % args[1])
550 for wfl
in self.
matrices_[args[0]].workFlows:
551 wfName, stepNames = wfl.nameId.split(
'+',1)
552 if re.match(pattern, wfName)
or re.match(pattern, stepNames):
553 print(
"%s %s %s" % (wfl.numId, wfName, stepNames))
555 print(
"Found %d compatible workflows inside %s" % (counter, args[0]))
558 print(
"\n".
join([
"search search_regexp\n",
559 "This command will search for a match within all workflows registered.",
560 "The search is done on both the workflow name and the names of steps registered to it."]))
565 print(
"search regexp")
567 for wfl
in self.matrices_.keys():
571 print(
"\n".
join([
"dumpWorkflowId [wfl-id1 [...]]\n",
572 "Dumps the details (cmsDriver commands for all steps) of the space-separated workflow-ids in input."]))
577 print(
"dumpWorkflowId [wfl-id1 [...]]")
584 for key, mrd
in self.matrices_.items():
585 for wfl
in mrd.workFlows:
586 if wfl.numId == float(wflid):
587 wfName, stepNames = wfl.nameId.split(
'+',1)
590 print(wfl.numId, stepNames)
591 for i,s
in enumerate(wfl.cmds):
593 print(
"\nWorkflow found in %s." % key)
595 print(
"Workflow also found in %s." % key)
602 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