3 from __future__
import print_function
4 from future.utils
import lmap
14 from abc
import ABCMeta, abstractmethod
20 import Alignment.OfflineValidation.TkAlAllInOneTool.configTemplates \
22 from Alignment.OfflineValidation.TkAlAllInOneTool.TkAlExceptions \
24 from Alignment.OfflineValidation.TkAlAllInOneTool.helperFunctions \
25 import replaceByMap, getCommandOutput2, addIndex
26 from Alignment.OfflineValidation.TkAlAllInOneTool.betterConfigParser \
27 import BetterConfigParser
28 from Alignment.OfflineValidation.TkAlAllInOneTool.alignment
import Alignment
31 import GenericValidation, ParallelValidation, ValidationWithComparison, ValidationWithPlots
32 from Alignment.OfflineValidation.TkAlAllInOneTool.geometryComparison \
33 import GeometryComparison
35 import OfflineValidation, OfflineValidationDQM
36 from Alignment.OfflineValidation.TkAlAllInOneTool.monteCarloValidation \
37 import MonteCarloValidation
39 import TrackSplittingValidation
41 import ZMuMuValidation
43 import PrimaryVertexValidation
44 from Alignment.OfflineValidation.TkAlAllInOneTool.primaryVertexResolution \
45 import PrimaryVertexResolution
46 from Alignment.OfflineValidation.TkAlAllInOneTool.preexistingValidation \
48 from Alignment.OfflineValidation.TkAlAllInOneTool.plottingOptions \
49 import PlottingOptions
50 import Alignment.OfflineValidation.TkAlAllInOneTool.globalDictionaries \
52 from Alignment.OfflineValidation.TkAlAllInOneTool.overlapValidation \
53 import OverlapValidation
59 __metaclass__ = ABCMeta
61 def __init__( self, validation, config, options ):
63 if validation[1] ==
"":
65 valString = validation[0].
split(
"->" )[0]
68 if "->" in validation[0]:
69 msg = (
"Instead of using the intermediate syntax\n'" 70 +valString.strip()+
"-> "+alignments.strip()
71 +
":'\nyou have to use the now fully supported syntax \n'" 72 +valString.strip()+
": " 73 +alignments.strip()+
"'.")
74 raise AllInOneError(msg)
76 valString = validation[0]
78 valString = valString.split()
89 if self.
valType ==
"offlineParallel":
90 print (
"offlineParallel and offline are now the same. To run an offline parallel validation,\n" 91 "just set parallelJobs to something > 1. There is no reason to call it offlineParallel anymore.")
95 raise AllInOneError(
"Validation '%s' of type '%s' is requested in" 96 " '[validation]' section, but is not defined." 97 "\nYou have to add a '[%s]' section." 118 class ValidationJob(ValidationBase):
125 def __init__( self, validation, config, options, *args, **kwargs ):
130 super(ValidationJob, self).
__init__( validation, config, options )
136 if valType ==
"compare":
137 alignmentsList = alignments.split(
"," )
138 firstAlignList = alignmentsList[0].
split()
139 firstAlignName = firstAlignList[0].
strip()
140 if firstAlignName ==
"IDEAL":
141 raise AllInOneError(
"'IDEAL' has to be the second (reference)" 142 " alignment in 'compare <val_name>: " 143 "<alignment> <reference>'.")
144 if len( firstAlignList ) > 1:
145 firstRun = firstAlignList[1]
146 elif config.has_section(
"IOV"):
147 firstRun = config.get(
"IOV",
"iov")
149 raise AllInOneError(
"Have to provide a run number for geometry comparison")
150 firstAlign =
Alignment( firstAlignName, config, firstRun )
151 firstAlignName = firstAlign.name
152 secondAlignList = alignmentsList[1].
split()
153 secondAlignName = secondAlignList[0].
strip()
154 if secondAlignName ==
"IDEAL":
155 secondAlign = secondAlignName
157 if len( secondAlignList ) > 1:
158 secondRun = secondAlignList[1]
159 elif config.has_section(
"IOV"):
160 secondRun = config.get(
"IOV",
"iov")
162 raise AllInOneError(
"Have to provide a run number for geometry comparison")
163 secondAlign =
Alignment( secondAlignName, config,
165 secondAlignName = secondAlign.name
167 validation = GeometryComparison( name, firstAlign, secondAlign,
170 elif valType ==
"offline":
171 validation = OfflineValidation( name,
172 Alignment( alignments.strip(), config ), config )
173 elif valType ==
"preexistingoffline":
174 validation = PreexistingOfflineValidation(name, config)
175 elif valType ==
"offlineDQM":
176 validation = OfflineValidationDQM( name,
177 Alignment( alignments.strip(), config ), config )
178 elif valType ==
"mcValidate":
179 validation = MonteCarloValidation( name,
180 Alignment( alignments.strip(), config ), config )
181 elif valType ==
"preexistingmcValidate":
182 validation = PreexistingMonteCarloValidation(name, config)
183 elif valType ==
"split":
184 validation = TrackSplittingValidation( name,
185 Alignment( alignments.strip(), config ), config )
186 elif valType ==
"preexistingsplit":
187 validation = PreexistingTrackSplittingValidation(name, config)
188 elif valType ==
"zmumu":
189 validation = ZMuMuValidation( name,
190 Alignment( alignments.strip(), config ), config )
191 elif valType ==
"primaryvertex":
193 Alignment( alignments.strip(), config ), config )
194 elif valType ==
"pvresolution":
196 Alignment( alignments.strip(), config ), config )
197 elif valType ==
"preexistingprimaryvertex":
198 validation = PreexistingPrimaryVertexValidation(name, self.__config)
199 elif valType ==
"overlap":
201 Alignment( alignments.strip(), self.__config ), self.__config )
203 raise AllInOneError(
"Unknown validation mode '%s'"%valType)
208 """This private method creates the needed files for the validation job. 210 self.
validation.createConfiguration( outpath )
217 """This is the method called to create the job files.""" 223 general = self.
config.getGeneral()
228 iov = self.
validation.config.get(
"IOV",
"iov")
231 preexistingValType = self.
valType 232 originalValType = preexistingValType.replace(
'preexisting',
'')
233 key = (originalValType, self.
validation.originalValName, iov)
234 if key
in ValidationJob.condorConf:
235 ValidationJob.condorConf[key].
append((
"preexisting",
"", general[
"logdir"]))
237 ValidationJob.condorConf[key] = [(
"preexisting",
"", general[
"logdir"])]
238 log =
"> " + self.
validation.name +
" is already validated." 242 name = os.path.splitext( os.path.basename( script) )[0]
243 ValidationJob.jobCount += 1
245 print(
"%s would run: %s"%( name, os.path.basename( script) ))
247 log =
"> Validating "+name
248 print(
"> Validating "+name)
251 ValidationJob.interactCount += 1
252 elif self.
validation.jobmode.split(
"," )[0] ==
"condor":
254 iov = self.
validation.config.get(
"IOV",
"iov")
257 scriptPaths = script.split(
"/")
258 scriptName = scriptPaths[-1]
259 scriptName = scriptName.split(
".")
260 jobName =
"%s"%scriptName[0] +
"_%s"%scriptName[1]+
"_%s"%scriptName[2]
262 if key
in ValidationJob.condorConf:
263 ValidationJob.condorConf[key].
append((jobName, script, general[
"logdir"]))
265 ValidationJob.condorConf[key] = [(jobName, script, general[
"logdir"])]
267 raise AllInOneError(
"Unknown 'jobmode'!\n" 268 "Please change this parameter either in " 269 "the [general] or in the [" 271 +
"] section to one of the following " 273 "\tinteractive\n\tcondor, -q <queue>\n")
296 def __init__( self, validation, config, options, outPath, *args, **kwargs):
299 super(ValidationJobMultiIOV, self).
__init__( validation, config, options )
313 alignmentsList = alignments.split(
"," )
314 firstAlignList = alignmentsList[0].
split()
315 firstAlignName = firstAlignList[0].
strip()
316 secondAlignList = alignmentsList[1].
split()
317 secondAlignName = secondAlignList[0].
strip()
318 compareAlignments =
"%s"%firstAlignName +
"_vs_%s"%secondAlignName
319 sectionMultiIOV =
"multiIOV:compare" 320 if not self.
config.has_section(sectionMultiIOV):
321 raise AllInOneError(
"section'[%s]' not found. Please define the dataset"%sectionMultiIOV)
322 iovList = self.
config.get( sectionMultiIOV,
"iovs" )
323 iovList = re.sub(
r"\s+",
"", iovList, flags=re.UNICODE).
split(
"," )
325 tmpConfig = BetterConfigParser()
326 tmpConfig.read( options.config )
327 general = tmpConfig.getGeneral()
328 tmpConfig.add_section(
"IOV")
329 tmpConfig.set(
"IOV",
"iov", iov)
330 tmpConfig.set(
"internals",
"workdir",os.path.join(general[
"workdir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
331 tmpConfig.set(
"internals",
"scriptsdir",os.path.join(outPath, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
332 tmpConfig.set(
"general",
"datadir",os.path.join(general[
"datadir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
333 tmpConfig.set(
"general",
"logdir",os.path.join(general[
"logdir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
334 tmpConfig.set(
"general",
"eosdir",os.path.join(
"AlignmentValidation", general[
"eosdir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
335 tmpOptions = copy.deepcopy(options)
336 tmpOptions.Name = os.path.join(options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov)
337 tmpOptions.config = tmpConfig
338 newOutPath = os.path.abspath( tmpOptions.Name )
339 if not os.path.exists( newOutPath ):
340 os.makedirs( newOutPath )
341 elif not os.path.isdir( newOutPath ):
342 raise AllInOneError(
"the file %s is in the way rename the Job or move it away"%newOutPath)
343 job =
ValidationJob( validation, tmpConfig, tmpOptions, len(iovList) )
344 validations.append(job)
348 if "preexisting" in self.
valType:
349 preexistingValType = self.
valType 352 originalValType = preexistingValType.replace(
'preexisting',
'')
355 originalAlignment = self.
valName 358 datasetList = re.sub(
r"\s+",
"", datasetList, flags=re.UNICODE).
split(
"," )
359 for dataset
in datasetList:
360 sectionMultiIOV =
"multiIOV:%s"%dataset
361 if not self.
config.has_section(sectionMultiIOV):
362 raise AllInOneError(
"section'[%s]' not found. Please define the dataset"%sectionMultiIOV)
364 datasetBaseName = self.
config.get( sectionMultiIOV,
"dataset" )
365 iovList = self.
config.get( sectionMultiIOV,
"iovs" )
366 iovList = re.sub(
r"\s+",
"", iovList, flags=re.UNICODE).
split(
"," )
368 datasetName = datasetBaseName+
"_since%s"%iov
369 tmpConfig = BetterConfigParser()
370 tmpConfig.read( options.config )
371 general = tmpConfig.getGeneral()
372 if "preexisting" in self.
valType:
373 valType = originalValType
374 valName = originalValName
378 tmpConfig.add_section(
"IOV")
379 tmpConfig.set(
"IOV",
"iov", iov)
380 tmpConfig.set( self.
valSection,
"dataset", datasetName )
381 tmpConfig.set(
"internals",
"workdir",os.path.join(general[
"workdir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
382 tmpConfig.set(
"internals",
"scriptsdir",os.path.join(outPath, valType +
"_" + valName +
"_%s"%iov) )
383 tmpConfig.set(
"general",
"datadir",os.path.join(general[
"datadir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
384 tmpConfig.set(
"general",
"logdir",os.path.join(general[
"logdir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
385 tmpConfig.set(
"general",
"eosdir",os.path.join(
"AlignmentValidation", general[
"eosdir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
386 if "preexisting" in self.
valType:
387 if self.
valType ==
"preexistingoffline":
388 validationClassName =
"AlignmentValidation" 396 raise AllInOneError(
"Unknown validation mode for preexisting option:'%s'"%self.
valType)
397 preexistingEosdirPath = os.path.join(
"AlignmentValidation", preexistingEosdir, valType +
"_" + valName +
"_%s"%iov)
398 file =
"/eos/cms/store/group/alca_trackeralign/AlignmentValidation/" +
"%s"%preexistingEosdirPath +
"/%s"%validationClassName +
"_%s"%originalValName +
"_%s"%originalAlignment +
".root" 399 tmpConfig.set(preexistingValSection,
"file", file)
400 tmpOptions = copy.deepcopy(options)
401 tmpOptions.Name = os.path.join(options.Name, valType +
"_" + valName +
"_%s"%iov)
402 tmpOptions.config = tmpConfig
403 newOutPath = os.path.abspath( tmpOptions.Name )
404 if not os.path.exists( newOutPath ):
405 os.makedirs( newOutPath )
406 elif not os.path.isdir( newOutPath ):
407 raise AllInOneError(
"the file %s is in the way rename the Job or move it away"%newOutPath)
408 job =
ValidationJob( validation, tmpConfig, tmpOptions, len(iovList) )
409 validations.append(job)
414 lmap(
lambda validation: validation.createJob(), self.
validations )
417 return [validation.runJob()
for validation
in self.
validations]
421 dagmanLog =
"{}/daglogs".
format(outdir)
422 os.system(
"mkdir -p {}".
format(dagmanLog))
425 with open(
"{}/validation.condor".
format(outdir),
"w")
as condor:
426 condor.write(
"universe = vanilla" +
"\n")
427 condor.write(
"executable = $(scriptName).sh" +
"\n")
428 condor.write(
"log = $(scriptName).log" +
"\n")
429 condor.write(
"error = $(scriptName).stderr" +
"\n")
430 condor.write(
"output = $(scriptName).stdout" +
"\n")
431 condor.write(
'requirements = (OpSysAndVer =?= "CentOS7")' +
'\n')
432 condor.write(
'+JobFlavour = "tomorrow"' +
"\n")
433 condor.write(
'+RequestMemory = {}'.
format(1540) +
"\n")
434 condor.write(
'+FileTransferDownloadBytes = {}'.
format(1540) +
"\n")
435 condor.write(
'+AccountingGroup = "group_u_CMS.CAF.ALCA"' +
'\n')
436 condor.write(
"queue")
438 with open(
"{}/validation.dagman".
format(outdir),
"w")
as dagman:
440 for (valType, valName, iov), alignments
in ValidationJob.condorConf.items():
442 parents[(valType, valName, iov)] = []
443 for jobInfo
in alignments:
444 if not "preexisting" in jobInfo[0]:
445 dagman.write(
"JOB {}_{} {}/validation.condor".
format(jobInfo[0], iov, outdir) +
"\n")
446 dagman.write(
'VARS {}_{} '.
format(jobInfo[0], iov) +
'scriptName="{}"'.
format(
'.'.
join(jobInfo[1].
split(
'.')[:-1])) +
"\n")
447 parents[(valType, valName, iov)].
append(
'{}_{}'.
format(jobInfo[0], iov))
450 path = os.path.join(jobInfo[2],
"TkAlMerge.sh")
451 if os.path.exists( path ):
452 dagman.write(
"JOB Merge_{}_{}_{} {}/validation.condor".
format(valType, valName, iov, outdir) +
"\n")
453 dagman.write(
"VARS Merge_{}_{}_{} ".
format(valType, valName, iov) +
'scriptName="{}"'.
format(os.path.join(jobInfo[2],
"TkAlMerge")) +
"\n")
456 raise AllInOneError(
"Merge script '[%s]' not found!"%path)
458 for (valType, valName, iov), alignments
in ValidationJob.condorConf.items():
459 if len(parents[(valType, valName, iov)]) != 0:
460 dagman.write(
'PARENT {} '.
format(
" ".
join([parent
for parent
in parents[(valType, valName, iov)]])) +
'CHILD Merge_{}_{}_{}'.
format(valType, valName, iov) +
"\n")
462 submitCommands = [
"condor_submit_dag -no_submit -outfile_dir {} {}/validation.dagman".
format(dagmanLog, outdir),
"condor_submit {}/validation.dagman.condor.sub".
format(outdir)]
464 for command
in submitCommands:
465 subprocess.call(command.split(
" "))
468 return [validation.getValidation()
for validation
in self.
validations]
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)
598 if config.has_section(
"alternateTemplates"):
599 for templateName
in config.options(
"alternateTemplates"):
600 if templateName ==
"AutoAlternates":
602 newTemplateName = config.get(
"alternateTemplates", templateName )
610 if type(item) == list:
611 flattenList.extend(
flatten(item))
614 flattenList.append(item)
623 optParser = optparse.OptionParser()
624 optParser.description =
"""All-in-one Alignment Validation. 625 This will run various validation procedures either on batch queues or interactively. 626 If no name is given (-N parameter) a name containing time and date is created automatically. 627 To merge the outcome of all validation procedures run TkAlMerge.sh in your validation's directory. 629 optParser.add_option(
"-n",
"--dryRun", dest=
"dryRun", action=
"store_true", default=
False,
630 help=
"create all scripts and cfg File but do not start jobs (default=False)")
631 optParser.add_option(
"--getImages", dest=
"getImages", action=
"store_true", default=
True,
632 help=
"get all Images created during the process (default= True)")
633 defaultConfig =
"TkAlConfig.ini" 634 optParser.add_option(
"-c",
"--config", dest=
"config", default = defaultConfig,
635 help=
"configuration to use (default TkAlConfig.ini) this can be a comma-seperated list of all .ini file you want to merge", metavar=
"CONFIG")
636 optParser.add_option(
"-N",
"--Name", dest=
"Name",
637 help=
"Name of this validation (default: alignmentValidation_DATE_TIME)", metavar=
"NAME")
638 optParser.add_option(
"-r",
"--restrictTo", dest=
"restrictTo",
639 help=
"restrict validations to given modes (comma seperated) (default: no restriction)", metavar=
"RESTRICTTO")
640 optParser.add_option(
"-d",
"--debug", dest=
"debugMode", action=
"store_true",
642 help=
"run the tool to get full traceback of errors",
646 (options, args) = optParser.parse_args(argv)
648 if not options.dryRun:
649 schedinfo = subprocess.check_output([
"myschedd",
"show"]).
decode()
650 if not 'tzero' in schedinfo:
651 print(
"\nAll-In-One Tool: you need to call `module load lxbatch/tzero` before trying to submit jobs. Please do so and try again")
655 if not options.restrictTo ==
None:
656 options.restrictTo = options.restrictTo.split(
",")
658 options.config = [ os.path.abspath( iniFile )
for iniFile
in \
659 options.config.split(
"," )]
661 config = BetterConfigParser()
662 outputIniFileSet = set( config.read( options.config ) )
663 failedIniFiles = [ iniFile
for iniFile
in options.config
if iniFile
not in outputIniFileSet ]
666 if options.config == [ os.path.abspath( defaultConfig ) ]:
667 if (
not os.path.exists( defaultConfig ) ):
668 raise AllInOneError(
"Default 'ini' file '%s' not found!\n" 669 "You can specify another name with the " 670 "command line option '-c'/'--config'." 673 for iniFile
in failedIniFiles:
674 if not os.path.exists( iniFile ):
675 raise AllInOneError(
"'%s' does not exist. Please check for " 676 "typos in the filename passed to the " 677 "'-c'/'--config' option!" 680 raise AllInOneError((
"'%s' does exist, but parsing of the " 681 "content failed!" ) % iniFile)
684 if options.Name ==
None:
685 existingValDirs = fnmatch.filter( os.walk(
'.' ).
next()[1],
686 "alignmentValidation_*" )
687 if len( existingValDirs ) > 0:
688 options.Name = existingValDirs[-1]
690 print(
"Cannot guess last working directory!")
691 print (
"Please use the parameter '-N' or '--Name' to specify " 692 "the task for which you want a status report." )
696 outPath = os.path.abspath( options.Name )
698 general = config.getGeneral()
699 config.set(
"internals",
"workdir",os.path.join(general[
"workdir"],options.Name) )
700 config.set(
"internals",
"scriptsdir",outPath)
701 config.set(
"general",
"datadir",os.path.join(general[
"datadir"],options.Name) )
702 config.set(
"general",
"logdir",os.path.join(general[
"logdir"],options.Name) )
703 config.set(
"general",
"eosdir",os.path.join(
"AlignmentValidation", general[
"eosdir"], options.Name) )
705 if not os.path.exists( outPath ):
706 os.makedirs( outPath )
707 elif not os.path.isdir( outPath ):
708 raise AllInOneError(
"the file %s is in the way rename the Job or move it away"%outPath)
714 backupConfigFile = open( os.path.join( outPath,
"usedConfiguration.ini" ) ,
"w" )
715 config.write( backupConfigFile )
724 shutil.copyfile(
getCommandOutput2(
"voms-proxy-info --path").
strip(), os.path.join(outPath,
".user_proxy"))
728 for validation
in config.items(
"validation"):
729 validation = validation[0].
split(
"-")
730 alignmentList = [validation[1]]
731 validationsToAdd = [(validation[0],alignment) \
732 for alignment
in alignmentList]
733 validations.extend(validationsToAdd)
735 for validation
in validations:
738 if (job.optionMultiIOV ==
True):
744 if job.needsproxy
and not proxyexists:
745 raise AllInOneError(
"At least one job needs a grid proxy, please init one.")
747 lmap(
lambda job: job.createJob(), jobs )
749 validations = [ job.getValidation()
for job
in jobs ]
750 validations =
flatten(validations)
754 lmap(
lambda job: job.runJob(), jobs )
759 ValidationJobMultiIOV.runCondorJobs(outPath)
762 if __name__ ==
"__main__":
764 if "-d" in sys.argv[1:]
or "--debug" in sys.argv[1:]:
769 except AllInOneError
as e:
def runCondorJobs(outdir)
def main(argv=None)
— Main —############################
def __init__(self, validation, config, options)
def __init__(self, validation, config, options, outPath, args, kwargs)
def loadTemplates(config)
def createMergeScript(path, validations, options)
def getCommandOutput2(command)
def __performMultiIOV(self, validation, alignments, config, options, outPath)
def addIndex(filename, njobs, index=None)
def __init__(self, validation, config, options, args, kwargs)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
bool decode(bool &, std::string const &)
def __getValidation(self, valType, name, alignments, config, options)
— Classes —############################
def replaceByMap(target, the_map)
— Helpers —############################
def split(sequence, size)
def __createJob(self, jobMode, outpath)
static std::string join(char **cmd)
def alternateTemplate(templateName, alternateTemplateName)
Alternate Templates ###