480 if(len(validations) == 0):
481 raise AllInOneError(
"Cowardly refusing to merge nothing!")
486 for validation
in validations:
487 if validation.config.has_section(
"IOV"):
488 iov = validation.config.get(
"IOV",
"iov")
489 validation.defaultReferenceName = iov
490 for referenceName
in validation.filesToCompare:
491 validationtype = type(validation)
492 validationName = validation.name
493 if validation.config.has_section(
"IOV")
and (referenceName ==
"Tracker_defaultRange" or referenceName ==
"Tracker_autoRange"):
495 if issubclass(validationtype, PreexistingValidation):
496 validationName = validation.originalValName
498 for parentclass
in validationtype.mro():
499 if not issubclass(parentclass, PreexistingValidation):
500 validationtype = parentclass
502 key = (validationtype, validationName, referenceName)
505 if key
in comparisonLists:
506 comparisonLists[key].
append(validation)
508 comparisonLists[key] = [validation]
509 repMap[key] = validation.config.getGeneral()
512 "CompareAlignments":
"",
513 "RunValidationPlots":
"",
514 "CMSSW_BASE": os.environ[
"CMSSW_BASE"],
515 "SCRAM_ARCH": os.environ[
"SCRAM_ARCH"],
516 "CMSSW_RELEASE_BASE": os.environ[
"CMSSW_RELEASE_BASE"],
521 repMap[key][
"doMerge"] =
"mergeRetCode=0\n" 522 repMap[key][
"rmUnmerged"] = (
"if [[ mergeRetCode -eq 0 ]]; then\n" 523 " echo -e \\n\"Merging succeeded, removing original files.\"\n")
524 repMap[key][
"beforeMerge"] =
"" 525 repMap[key][
"mergeParallelFilePrefixes"] =
"" 526 repMap[key][
"createResultsDirectory"]=
"" 532 for (validationtype, validationName, referenceName), validations
in comparisonLists.iteritems():
535 globalDictionaries.plottingOptions = {}
536 map(
lambda validation: validation.getRepMap(), validations )
541 for validation
in validations:
542 validation.getRepMap()
546 if not (isinstance(validation, PreexistingValidation)
or validation.NJobs == 1
or not isinstance(validation, ParallelValidation)):
547 if (validationtype, validationName, referenceName)
not in anythingToMerge:
548 anythingToMerge.append((validationtype, validationName, referenceName))
549 repMap[(validationtype, validationName, referenceName)][
"doMerge"] +=
'\n\n\n\necho -e "\n\nMerging results from %s jobs"\n\n' % validationtype.valType
550 repMap[(validationtype, validationName, referenceName)][
"beforeMerge"] += validationtype.doInitMerge()
551 repMap[(validationtype, validationName, referenceName)][
"doMerge"] += validation.doMerge()
552 for f
in validation.getRepMap()[
"outputFiles"]:
553 longName = os.path.join(
"/eos/cms/store/group/alca_trackeralign/AlignmentValidation/",
554 validation.getRepMap()[
"eosdir"], f)
555 repMap[(validationtype, validationName, referenceName)][
"rmUnmerged"] +=
" rm "+longName+
"\n" 557 repMap[(validationtype, validationName, referenceName)][
"rmUnmerged"] += (
"else\n" 558 " echo -e \\n\"WARNING: Merging failed, unmerged" 559 " files won't be deleted.\\n" 560 "(Ignore this warning if merging was done earlier)\"\n" 565 repMap[(validationtype, validationName, referenceName)][
"DownloadData"] +=
replaceByMap( configTemplates.mergeParallelResults, repMap[(validationtype, validationName, referenceName)] )
567 repMap[(validationtype, validationName, referenceName)][
"DownloadData"] =
"" 569 repMap[(validationtype, validationName, referenceName)][
"RunValidationPlots"] =
"" 570 repMap[(validationtype, validationName, referenceName)][
"plottingscriptpath"] =
"" 571 if issubclass(validationtype, ValidationWithPlots):
572 repMap[(validationtype, validationName, referenceName)][
"RunValidationPlots"] = validationtype.doRunPlots(validations)
574 repMap[(validationtype, validationName, referenceName)][
"CompareAlignments"] =
"#run comparisons" 575 if issubclass(validationtype, ValidationWithComparison):
576 repMap[(validationtype, validationName, referenceName)][
"CompareAlignments"] += validationtype.doComparison(validations)
579 if validations[0].config.has_section(
"IOV"):
580 repMap[(validationtype, validationName, referenceName)][
"createResultsDirectory"]=
replaceByMap(configTemplates.createResultsDirectoryTemplate, repMap[(validationtype, validationName, referenceName)])
581 filePath = os.path.join(repMap[(validationtype, validationName, referenceName)][
"scriptsdir"],
"TkAlMerge.sh")
583 repMap[(validationtype, validationName, referenceName)][
"createResultsDirectory"]=
replaceByMap(configTemplates.createResultsDirectoryTemplate, repMap[(validationtype, validationName, referenceName)])
584 filePath = os.path.join(path,
"TkAlMerge.sh")
586 theFile = open( filePath,
"w" )
587 theFile.write(
replaceByMap( configTemplates.mergeTemplate, repMap[(validationtype, validationName, referenceName)]) )
589 os.chmod(filePath,0o755)
def createMergeScript(path, validations, options)
def replaceByMap(target, the_map)
— Helpers —############################