487 if(len(validations) == 0):
488 raise AllInOneError(
"Cowardly refusing to merge nothing!")
493 for validation
in validations:
494 if validation.config.has_section(
"IOV"):
495 iov = validation.config.get(
"IOV",
"iov")
496 validation.defaultReferenceName = iov
497 for referenceName
in validation.filesToCompare:
498 validationtype = type(validation)
499 validationName = validation.name
500 if validation.config.has_section(
"IOV")
and (referenceName ==
"Tracker_defaultRange" or referenceName ==
"Tracker_autoRange"):
502 if issubclass(validationtype, PreexistingValidation):
503 validationName = validation.originalValName
505 for parentclass
in validationtype.mro():
506 if not issubclass(parentclass, PreexistingValidation):
507 validationtype = parentclass
509 key = (validationtype, validationName, referenceName)
512 if key
in comparisonLists:
513 comparisonLists[key].
append(validation)
515 comparisonLists[key] = [validation]
516 repMap[key] = validation.config.getGeneral()
519 "CompareAlignments":
"",
520 "RunValidationPlots":
"",
521 "CMSSW_BASE": os.environ[
"CMSSW_BASE"],
522 "SCRAM_ARCH": os.environ[
"SCRAM_ARCH"],
523 "CMSSW_RELEASE_BASE": os.environ[
"CMSSW_RELEASE_BASE"],
528 repMap[key][
"doMerge"] =
"mergeRetCode=0\n"
529 repMap[key][
"rmUnmerged"] = (
"if [[ mergeRetCode -eq 0 ]]; then\n"
530 " echo -e \\n\"Merging succeeded, removing original files.\"\n")
531 repMap[key][
"beforeMerge"] =
""
532 repMap[key][
"mergeParallelFilePrefixes"] =
""
533 repMap[key][
"createResultsDirectory"]=
""
539 for (validationtype, validationName, referenceName), validations
in six.iteritems(comparisonLists):
542 globalDictionaries.plottingOptions = {}
543 lmap(
lambda validation: validation.getRepMap(), validations )
548 for validation
in validations:
549 validation.getRepMap()
553 if not (isinstance(validation, PreexistingValidation)
or validation.NJobs == 1
or not isinstance(validation, ParallelValidation)):
554 if (validationtype, validationName, referenceName)
not in anythingToMerge:
555 anythingToMerge.append((validationtype, validationName, referenceName))
556 repMap[(validationtype, validationName, referenceName)][
"doMerge"] +=
'\n\n\n\necho -e "\n\nMerging results from %s jobs"\n\n' % validationtype.valType
557 repMap[(validationtype, validationName, referenceName)][
"beforeMerge"] += validationtype.doInitMerge()
558 repMap[(validationtype, validationName, referenceName)][
"doMerge"] += validation.doMerge()
559 for f
in validation.getRepMap()[
"outputFiles"]:
560 longName = os.path.join(
"/eos/cms/store/group/alca_trackeralign/AlignmentValidation/",
561 validation.getRepMap()[
"eosdir"], f)
562 repMap[(validationtype, validationName, referenceName)][
"rmUnmerged"] +=
" rm "+longName+
"\n"
564 repMap[(validationtype, validationName, referenceName)][
"rmUnmerged"] += (
"else\n"
565 " echo -e \\n\"WARNING: Merging failed, unmerged"
566 " files won't be deleted.\\n"
567 "(Ignore this warning if merging was done earlier)\"\n"
572 repMap[(validationtype, validationName, referenceName)][
"DownloadData"] +=
replaceByMap( configTemplates.mergeParallelResults, repMap[(validationtype, validationName, referenceName)] )
574 repMap[(validationtype, validationName, referenceName)][
"DownloadData"] =
""
576 repMap[(validationtype, validationName, referenceName)][
"RunValidationPlots"] =
""
577 repMap[(validationtype, validationName, referenceName)][
"plottingscriptpath"] =
""
578 if issubclass(validationtype, ValidationWithPlots):
579 repMap[(validationtype, validationName, referenceName)][
"RunValidationPlots"] = validationtype.doRunPlots(validations)
581 repMap[(validationtype, validationName, referenceName)][
"CompareAlignments"] =
"#run comparisons"
582 if issubclass(validationtype, ValidationWithComparison):
583 repMap[(validationtype, validationName, referenceName)][
"CompareAlignments"] += validationtype.doComparison(validations)
586 if validations[0].config.has_section(
"IOV"):
587 repMap[(validationtype, validationName, referenceName)][
"createResultsDirectory"]=
replaceByMap(configTemplates.createResultsDirectoryTemplate, repMap[(validationtype, validationName, referenceName)])
588 filePath = os.path.join(repMap[(validationtype, validationName, referenceName)][
"scriptsdir"],
"TkAlMerge.sh")
590 repMap[(validationtype, validationName, referenceName)][
"createResultsDirectory"]=
replaceByMap(configTemplates.createResultsDirectoryTemplate, repMap[(validationtype, validationName, referenceName)])
591 filePath = os.path.join(path,
"TkAlMerge.sh")
593 theFile = open( filePath,
"w" )
594 theFile.write(
replaceByMap( configTemplates.mergeTemplate, repMap[(validationtype, validationName, referenceName)]) )
596 os.chmod(filePath,0o755)