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