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__':
113 'jetmc': [5.1, 13, 15, 25, 38, 39],
114 'metmc' : [5.1, 15, 25, 37, 38, 39],
115 'muonmc' : [5.1, 124.4, 124.5, 20, 21, 22, 23, 25, 30],
120 usage =
'usage: runTheMatrix.py --show -s ' 122 parser = argparse.ArgumentParser(usage,formatter_class=argparse.ArgumentDefaultsHelpFormatter)
124 parser.add_argument(
'-b',
'--batchName',
125 help=
'relval batch: suffix to be appended to Campaign name',
129 parser.add_argument(
'-m',
'--memoryOffset',
130 help=
'memory of the wf for single core',
135 parser.add_argument(
'--addMemPerCore',
136 help=
'increase of memory per each n > 1 core: memory(n_core) = memoryOffset + (n_core-1) * memPerCore',
141 parser.add_argument(
'-j',
'--nproc',
142 help=
'number of processes. 0 Will use 4 processes, not execute anything but create the wfs',
147 parser.add_argument(
'-t',
'--nThreads',
148 help=
'number of threads per process to use in cmsRun.',
153 parser.add_argument(
'--nStreams',
154 help=
'number of streams to use in cmsRun.',
159 parser.add_argument(
'--numberEventsInLuminosityBlock',
160 help=
'number of events in a luminosity block',
161 dest=
'numberEventsInLuminosityBlock',
165 parser.add_argument(
'-n',
'--showMatrix',
166 help=
'Only show the worflows. Use --ext to show more',
171 parser.add_argument(
'-e',
'--extended',
172 help=
'Show details of workflows, used with --show',
177 parser.add_argument(
'-s',
'--selected',
178 help=
'Run a pre-defined selected matrix of wf. Deprecated, please use -l limited',
183 parser.add_argument(
'-l',
'--list',
184 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',
188 parser.add_argument(
'-r',
'--raw',
189 help=
'Temporary dump the .txt needed for prodAgent interface. To be discontinued soon. Argument must be the name of the set (standard, pileup,...)',
192 parser.add_argument(
'-i',
'--useInput',
193 help=
'Use recyling where available. Either all, or a comma separated list of wf number.',
195 type=
lambda x: x.split(
','),
198 parser.add_argument(
'-w',
'--what',
199 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 )',
203 parser.add_argument(
'--step1',
204 help=
'Used with --raw. Limit the production to step1',
208 parser.add_argument(
'--maxSteps',
209 help=
'Only run maximum on maxSteps. Used when we are only interested in first n steps.',
214 parser.add_argument(
'--fromScratch',
215 help=
'Comma separated list of wf to be run without recycling. all is not supported as default.',
217 type=
lambda x: x.split(
','),
220 parser.add_argument(
'--refRelease',
221 help=
'Allow to modify the recycling dataset version',
225 parser.add_argument(
'--wmcontrol',
226 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',
227 choices=[
'init',
'test',
'submit',
'force'],
231 parser.add_argument(
'--revertDqmio',
232 help=
'When submitting workflows to wmcontrol, force DQM outout to use pool and not DQMIO',
233 choices=[
'yes',
'no'],
237 parser.add_argument(
'--optionswm',
238 help=
'Specify a few things for wm injection',
242 parser.add_argument(
'--keep',
243 help=
'allow to specify for which comma separated steps the output is needed',
246 parser.add_argument(
'--label',
247 help=
'allow to give a special label to the output dataset name',
250 parser.add_argument(
'--command',
251 help=
'provide a way to add additional command to all of the cmsDriver commands in the matrix',
256 parser.add_argument(
'--apply',
257 help=
'allow to use the --command only for 1 comma separeated',
261 parser.add_argument(
'--workflow',
262 help=
'define a workflow to be created or altered from the matrix',
267 parser.add_argument(
'--dryRun',
268 help=
'do not run the wf at all',
273 parser.add_argument(
'--testbed',
274 help=
'workflow injection to cmswebtest (you need dedicated rqmgr account)',
279 parser.add_argument(
'--noCafVeto',
280 help=
'Run from any source, ignoring the CAF label',
283 action=
'store_false')
285 parser.add_argument(
'--overWrite',
286 help=
'Change the content of a step for another. List of pairs.',
290 parser.add_argument(
'--noRun',
291 help=
'Remove all run list selection from wfs',
296 parser.add_argument(
'--das-options',
297 help=
'Options to be passed to dasgoclient.',
302 parser.add_argument(
'--job-reports',
303 help=
'Dump framework job reports',
308 parser.add_argument(
'--ibeos',
309 help=
'Use IB EOS site configuration',
314 parser.add_argument(
'--sites',
315 help=
'Run DAS query to get data from a specific site. Set it to empty string to search all sites.',
317 default=
'T2_CH_CERN',
320 parser.add_argument(
'--interactive',
321 help=
"Open the Matrix interactive shell",
325 parser.add_argument(
'--dbs-url',
326 help=
'Overwrite DbsUrl value in JSON submitted to ReqMgr2',
331 gpugroup = parser.add_argument_group(
'GPU-related options',
'These options are only meaningful when --gpu is used, and is not set to forbidden.')
333 gpugroup.add_argument(
'--gpu',
'--requires-gpu',
334 help=
'Enable GPU workflows. Possible options are "forbidden" (default), "required" (implied if no argument is given), or "optional".',
336 choices=[
'forbidden',
'optional',
'required'],
342 gpugroup.add_argument(
'--gpu-memory',
343 help=
'Specify the minimum amount of GPU memory required by the job, in MB.',
348 gpugroup.add_argument(
'--cuda-capabilities',
349 help=
'Specify a comma-separated list of CUDA "compute capabilities", or GPU hardware architectures, that the job can use.',
350 dest=
'CUDACapabilities',
351 type=
lambda x: x.split(
','),
352 default=
'6.0,6.1,6.2,7.0,7.2,7.5,8.0,8.6')
355 cudart_version =
None 356 libcudart = os.path.realpath(os.path.expandvars(
'$CMSSW_RELEASE_BASE/external/$SCRAM_ARCH/lib/libcudart.so'))
357 if os.path.isfile(libcudart):
358 cudart_basename = os.path.basename(libcudart)
359 cudart_version =
'.'.
join(cudart_basename.split(
'.')[2:4])
360 gpugroup.add_argument(
'--cuda-runtime',
361 help=
'Specify major and minor version of the CUDA runtime used to build the application.',
363 default=cudart_version)
365 gpugroup.add_argument(
'--force-gpu-name',
366 help=
'Request a specific GPU model, e.g. "Tesla T4" or "NVIDIA GeForce RTX 2080". The default behaviour is to accept any supported GPU.',
370 gpugroup.add_argument(
'--force-cuda-driver-version',
371 help=
'Request a specific CUDA driver version, e.g. 470.57.02. The default behaviour is to accept any supported CUDA driver version.',
372 dest=
'CUDADriverVersion',
375 gpugroup.add_argument(
'--force-cuda-runtime-version',
376 help=
'Request a specific CUDA runtime version, e.g. 11.4. The default behaviour is to accept any supported CUDA runtime version.',
377 dest=
'CUDARuntimeVersion',
380 opt = parser.parse_args()
381 if opt.command: opt.command =
' '.
join(opt.command)
382 os.environ[
"CMSSW_DAS_QUERY_SITES"]=opt.dasSites
384 from subprocess
import getstatusoutput
as run_cmd
386 ibeos_cache = os.path.join(os.getenv(
"LOCALRT"),
"ibeos_cache.txt")
387 if not os.path.exists(ibeos_cache):
388 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)
390 run_cmd(
"rm -f %s" % ibeos_cache)
391 print(
"Error: Unable to download ibeos cache information")
395 for cmssw_env
in [
"CMSSW_BASE",
"CMSSW_RELEASE_BASE" ]:
396 cmssw_base = os.getenv(cmssw_env,
None)
397 if not cmssw_base:
continue 398 cmssw_base = os.path.join(cmssw_base,
"src/Utilities/General/ibeos")
399 if os.path.exists(cmssw_base):
400 os.environ[
"PATH"]=cmssw_base+
":"+os.getenv(
"PATH")
401 os.environ[
"CMS_PATH"]=
"/cvmfs/cms-ib.cern.ch" 402 os.environ[
"CMSSW_USE_IBEOS"]=
"true" 403 print(
">> WARNING: You are using SITECONF from /cvmfs/cms-ib.cern.ch")
406 print(
'Deprecated, please use -l limited')
407 if opt.testList: opt.testList+=
',limited' 408 else: opt.testList=
'limited' 416 opt.apply=
map(stepOrIndex,opt.apply.split(
','))
418 opt.keep=
map(stepOrIndex,opt.keep.split(
','))
422 for entry
in opt.testList.split(
','):
423 if not entry:
continue 425 for k
in predefinedSet:
426 if k.lower().startswith(entry.lower())
or k.lower().endswith(entry.lower()):
427 testList.extend(predefinedSet[k])
432 testList.append(
float(entry))
434 print(entry,
'is not a possible selected entry')
436 opt.testList = list(set(testList))
441 opt.overWrite=eval(opt.overWrite)
446 intro =
"Welcome to the Matrix (? for help)" 450 cmd.Cmd.__init__(self)
454 for what
in tmp.files:
455 what = what.replace(
'relval_',
'')
456 self.
opt_.what = what
459 self.
opt_.fromScratch)
463 """Clear the screen, put prompt at the top""" 467 print(
"Leaving the Matrix")
471 if inp ==
'x' or inp ==
'q':
475 print(
"\n".
join([
"predefined [predef1 [...]]\n",
476 "Run w/o argument, it will print the list of known predefined workflows.",
477 "Run with space-separated predefined workflows, it will print the workflow-ids registered to them"]))
480 if text
and len(text) > 0:
481 return [t
for t
in predefinedSet.keys()
if t.startswith(text)]
483 return predefinedSet.keys()
486 """Print the list of predefined workflows""" 487 print(
"List of predefined workflows")
489 for w
in arg.split():
490 if w
in predefinedSet.keys():
491 print(
"Predefined Set: %s" % w)
492 print(predefinedSet[w])
494 print(
"Unknown Set: %s" % w)
496 print(predefinedSet.keys())
499 print(
"\n".
join([
"showWorkflow [workflow1 [...]]\n",
500 "Run w/o arguments, it will print the list of registered macro-workflows.",
501 "Run with space-separated workflows, it will print the full list of workflow-ids registered to them"]))
504 if text
and len(text) > 0:
505 return [t
for t
in self.
matrices_.
keys()
if t.startswith(text)]
511 print(
"Available workflows:")
515 selected = arg.split()
518 print(
"Unknown workflow %s: skipping" % k)
521 wfName, stepNames = wfl.nameId.split(
'+',1)
522 print(
"%s %s %s" % (wfl.numId, wfName, stepNames))
523 print(
"%s contains %d workflows" % (k, len(self.
matrices_[k].workFlows)))
526 print(
"\n".
join([
"searchInWorkflow wfl_name search_regexp\n",
527 "This command will search for a match within all workflows registered to wfl_name.",
528 "The search is done on both the workflow name and the names of steps registered to it."]))
531 if text
and len(text) > 0:
532 return [t
for t
in self.
matrices_.
keys()
if t.startswith(text)]
539 print(
"searchInWorkflow name regexp")
542 print(
"Unknown workflow")
547 pattern = re.compile(args[1])
549 print(
"Failed to compile regexp %s" % args[1])
552 for wfl
in self.
matrices_[args[0]].workFlows:
553 wfName, stepNames = wfl.nameId.split(
'+',1)
554 if re.match(pattern, wfName)
or re.match(pattern, stepNames):
555 print(
"%s %s %s" % (wfl.numId, wfName, stepNames))
557 print(
"Found %d compatible workflows inside %s" % (counter, args[0]))
560 print(
"\n".
join([
"search search_regexp\n",
561 "This command will search for a match within all workflows registered.",
562 "The search is done on both the workflow name and the names of steps registered to it."]))
567 print(
"search regexp")
573 print(
"\n".
join([
"dumpWorkflowId [wfl-id1 [...]]\n",
574 "Dumps the details (cmsDriver commands for all steps) of the space-separated workflow-ids in input."]))
579 print(
"dumpWorkflowId [wfl-id1 [...]]")
587 for wfl
in mrd.workFlows:
588 if wfl.numId ==
float(wflid):
589 wfName, stepNames = wfl.nameId.split(
'+',1)
592 print(wfl.numId, stepNames)
593 for i,s
in enumerate(wfl.cmds):
595 print(
"\nWorkflow found in %s." % key)
597 print(
"Workflow also found in %s." % key)
604 if opt.raw
and opt.show:
def performInjectionOptionTest(opt)
def do_predefined(self, arg)
def do_showWorkflow(self, arg)
def complete_showWorkflow(self, text, line, start_idx, end_idx)
def help_showWorkflow(self)
def help_dumpWorkflowId(self)
def complete_predefined(self, text, line, start_idx, end_idx)
def help_searchInWorkflow(self)
def do_dumpWorkflowId(self, arg)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def help_predefined(self)
static std::string join(char **cmd)
def complete_searchInWorkflow(self, text, line, start_idx, end_idx)
def do_searchInWorkflow(self, arg)