3 from __future__
import print_function
13 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.preexistingValidation \
46 from Alignment.OfflineValidation.TkAlAllInOneTool.plottingOptions \
47 import PlottingOptions
48 import Alignment.OfflineValidation.TkAlAllInOneTool.globalDictionaries \
50 from Alignment.OfflineValidation.TkAlAllInOneTool.overlapValidation \
51 import OverlapValidation
57 __metaclass__ = ABCMeta
59 def __init__( self, validation, config, options ):
61 if validation[1] ==
"":
63 valString = validation[0].
split(
"->" )[0]
66 if "->" in validation[0]:
67 msg = (
"Instead of using the intermediate syntax\n'" 68 +valString.strip()+
"-> "+alignments.strip()
69 +
":'\nyou have to use the now fully supported syntax \n'" 70 +valString.strip()+
": " 71 +alignments.strip()+
"'.")
72 raise AllInOneError(msg)
74 valString = validation[0]
76 valString = valString.split()
87 if self.
valType ==
"offlineParallel":
88 print (
"offlineParallel and offline are now the same. To run an offline parallel validation,\n" 89 "just set parallelJobs to something > 1. There is no reason to call it offlineParallel anymore.")
92 if not self.config.has_section( self.
valSection ):
93 raise AllInOneError(
"Validation '%s' of type '%s' is requested in" 94 " '[validation]' section, but is not defined." 95 "\nYou have to add a '[%s]' section." 116 class ValidationJob(ValidationBase):
123 def __init__( self, validation, config, options, *args, **kwargs ):
128 super(ValidationJob, self).
__init__( validation, config, options )
134 if valType ==
"compare":
135 alignmentsList = alignments.split(
"," )
136 firstAlignList = alignmentsList[0].
split()
137 firstAlignName = firstAlignList[0].
strip()
138 if firstAlignName ==
"IDEAL":
139 raise AllInOneError(
"'IDEAL' has to be the second (reference)" 140 " alignment in 'compare <val_name>: " 141 "<alignment> <reference>'.")
142 if len( firstAlignList ) > 1:
143 firstRun = firstAlignList[1]
144 elif config.has_section(
"IOV"):
145 firstRun = config.get(
"IOV",
"iov")
147 raise AllInOneError(
"Have to provide a run number for geometry comparison")
148 firstAlign =
Alignment( firstAlignName, config, firstRun )
149 firstAlignName = firstAlign.name
150 secondAlignList = alignmentsList[1].
split()
151 secondAlignName = secondAlignList[0].
strip()
152 if secondAlignName ==
"IDEAL":
153 secondAlign = secondAlignName
155 if len( secondAlignList ) > 1:
156 secondRun = secondAlignList[1]
157 elif config.has_section(
"IOV"):
158 secondRun = config.get(
"IOV",
"iov")
160 raise AllInOneError(
"Have to provide a run number for geometry comparison")
161 secondAlign =
Alignment( secondAlignName, config,
163 secondAlignName = secondAlign.name
165 validation = GeometryComparison( name, firstAlign, secondAlign,
167 self.commandLineOptions.getImages)
168 elif valType ==
"offline":
169 validation = OfflineValidation( name,
170 Alignment( alignments.strip(), config ), config )
171 elif valType ==
"preexistingoffline":
172 validation = PreexistingOfflineValidation(name, config)
173 elif valType ==
"offlineDQM":
174 validation = OfflineValidationDQM( name,
175 Alignment( alignments.strip(), config ), config )
176 elif valType ==
"mcValidate":
177 validation = MonteCarloValidation( name,
178 Alignment( alignments.strip(), config ), config )
179 elif valType ==
"preexistingmcValidate":
180 validation = PreexistingMonteCarloValidation(name, config)
181 elif valType ==
"split":
182 validation = TrackSplittingValidation( name,
183 Alignment( alignments.strip(), config ), config )
184 elif valType ==
"preexistingsplit":
185 validation = PreexistingTrackSplittingValidation(name, config)
186 elif valType ==
"zmumu":
187 validation = ZMuMuValidation( name,
188 Alignment( alignments.strip(), config ), config )
189 elif valType ==
"primaryvertex":
191 Alignment( alignments.strip(), config ), config )
192 elif valType ==
"preexistingprimaryvertex":
193 validation = PreexistingPrimaryVertexValidation(name, self.__config)
194 elif valType ==
"overlap":
196 Alignment( alignments.strip(), self.__config ), self.__config )
198 raise AllInOneError(
"Unknown validation mode '%s'"%valType)
203 """This private method creates the needed files for the validation job. 205 self.validation.createConfiguration( outpath )
208 self.
scripts = sum([
addIndex(script, self.validation.NJobs)
for script
in self.validation.createScript( outpath )], [])
212 """This is the method called to create the job files.""" 214 os.path.abspath( self.commandLineOptions.Name) )
217 general = self.config.getGeneral()
221 if self.validation.config.has_section(
"IOV"):
222 iov = self.validation.config.get(
"IOV",
"iov")
225 preexistingValType = self.
valType 226 originalValType = preexistingValType.replace(
'preexisting',
'')
227 key = (originalValType, self.validation.originalValName, iov)
228 if key
in ValidationJob.condorConf:
229 ValidationJob.condorConf[key].
append((
"preexisting",
"", general[
"logdir"]))
231 ValidationJob.condorConf[key] = [(
"preexisting",
"", general[
"logdir"])]
232 log =
"> " + self.validation.name +
" is already validated." 236 name = os.path.splitext( os.path.basename( script) )[0]
237 ValidationJob.jobCount += 1
238 if self.commandLineOptions.dryRun:
239 print(
"%s would run: %s"%( name, os.path.basename( script) ))
241 log =
"> Validating "+name
242 print(
"> Validating "+name)
243 if self.validation.jobmode ==
"interactive":
245 ValidationJob.interactCount += 1
246 elif self.validation.jobmode.split(
"," )[0] ==
"condor":
247 if self.validation.config.has_section(
"IOV"):
248 iov = self.validation.config.get(
"IOV",
"iov")
251 scriptPaths = script.split(
"/")
252 scriptName = scriptPaths[-1]
253 scriptName = scriptName.split(
".")
254 jobName =
"%s"%scriptName[0] +
"_%s"%scriptName[1]+
"_%s"%scriptName[2]
256 if key
in ValidationJob.condorConf:
257 ValidationJob.condorConf[key].
append((jobName, script, general[
"logdir"]))
259 ValidationJob.condorConf[key] = [(jobName, script, general[
"logdir"])]
261 raise AllInOneError(
"Unknown 'jobmode'!\n" 262 "Please change this parameter either in " 263 "the [general] or in the [" 265 +
"] section to one of the following " 267 "\tinteractive\n\tcondor, -q <queue>\n")
275 return self.validation.needsproxy
and not self.
preexisting and not self.commandLineOptions.dryRun
290 def __init__( self, validation, config, options, outPath, *args, **kwargs):
293 super(ValidationJobMultiIOV, self).
__init__( validation, config, options )
307 alignmentsList = alignments.split(
"," )
308 firstAlignList = alignmentsList[0].
split()
309 firstAlignName = firstAlignList[0].
strip()
310 secondAlignList = alignmentsList[1].
split()
311 secondAlignName = secondAlignList[0].
strip()
312 compareAlignments =
"%s"%firstAlignName +
"_vs_%s"%secondAlignName
313 sectionMultiIOV =
"multiIOV:compare" 314 if not self.config.has_section(sectionMultiIOV):
315 raise AllInOneError(
"section'[%s]' not found. Please define the dataset"%sectionMultiIOV)
316 iovList = self.config.get( sectionMultiIOV,
"iovs" )
317 iovList = re.sub(
r"\s+",
"", iovList, flags=re.UNICODE).
split(
"," )
319 tmpConfig = BetterConfigParser()
320 tmpConfig.read( options.config )
321 general = tmpConfig.getGeneral()
322 tmpConfig.add_section(
"IOV")
323 tmpConfig.set(
"IOV",
"iov", iov)
324 tmpConfig.set(
"internals",
"workdir",os.path.join(general[
"workdir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
325 tmpConfig.set(
"internals",
"scriptsdir",os.path.join(outPath, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
326 tmpConfig.set(
"general",
"datadir",os.path.join(general[
"datadir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
327 tmpConfig.set(
"general",
"logdir",os.path.join(general[
"logdir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
328 tmpConfig.set(
"general",
"eosdir",os.path.join(
"AlignmentValidation", general[
"eosdir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
329 tmpOptions = copy.deepcopy(options)
330 tmpOptions.Name = os.path.join(options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov)
331 tmpOptions.config = tmpConfig
332 newOutPath = os.path.abspath( tmpOptions.Name )
333 if not os.path.exists( newOutPath ):
334 os.makedirs( newOutPath )
335 elif not os.path.isdir( newOutPath ):
336 raise AllInOneError(
"the file %s is in the way rename the Job or move it away"%newOutPath)
337 job =
ValidationJob( validation, tmpConfig, tmpOptions, len(iovList) )
338 validations.append(job)
342 if "preexisting" in self.
valType:
343 preexistingValType = self.
valType 345 preexistingEosdir = self.config.get( self.
valSection,
"eosdirName" )
346 originalValType = preexistingValType.replace(
'preexisting',
'')
347 originalValName = self.config.get( self.
valSection,
"originalValName" )
349 originalAlignment = self.
valName 351 datasetList = self.config.get( self.
valSection,
"dataset" )
352 datasetList = re.sub(
r"\s+",
"", datasetList, flags=re.UNICODE).
split(
"," )
353 for dataset
in datasetList:
354 sectionMultiIOV =
"multiIOV:%s"%dataset
355 if not self.config.has_section(sectionMultiIOV):
356 raise AllInOneError(
"section'[%s]' not found. Please define the dataset"%sectionMultiIOV)
358 datasetBaseName = self.config.get( sectionMultiIOV,
"dataset" )
359 iovList = self.config.get( sectionMultiIOV,
"iovs" )
360 iovList = re.sub(
r"\s+",
"", iovList, flags=re.UNICODE).
split(
"," )
362 datasetName = datasetBaseName+
"_since%s"%iov
363 tmpConfig = BetterConfigParser()
364 tmpConfig.read( options.config )
365 general = tmpConfig.getGeneral()
366 if "preexisting" in self.
valType:
367 valType = originalValType
368 valName = originalValName
372 tmpConfig.add_section(
"IOV")
373 tmpConfig.set(
"IOV",
"iov", iov)
374 tmpConfig.set( self.
valSection,
"dataset", datasetName )
375 tmpConfig.set(
"internals",
"workdir",os.path.join(general[
"workdir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
376 tmpConfig.set(
"internals",
"scriptsdir",os.path.join(outPath, valType +
"_" + valName +
"_%s"%iov) )
377 tmpConfig.set(
"general",
"datadir",os.path.join(general[
"datadir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
378 tmpConfig.set(
"general",
"logdir",os.path.join(general[
"logdir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
379 tmpConfig.set(
"general",
"eosdir",os.path.join(
"AlignmentValidation", general[
"eosdir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
380 if "preexisting" in self.
valType:
381 if self.
valType ==
"preexistingoffline":
382 validationClassName =
"AlignmentValidation" 390 raise AllInOneError(
"Unknown validation mode for preexisting option:'%s'"%self.
valType)
391 preexistingEosdirPath = os.path.join(
"AlignmentValidation", preexistingEosdir, valType +
"_" + valName +
"_%s"%iov)
392 file =
"/eos/cms/store/group/alca_trackeralign/AlignmentValidation/" +
"%s"%preexistingEosdirPath +
"/%s"%validationClassName +
"_%s"%originalValName +
"_%s"%originalAlignment +
".root" 393 tmpConfig.set(preexistingValSection,
"file", file)
394 tmpOptions = copy.deepcopy(options)
395 tmpOptions.Name = os.path.join(options.Name, valType +
"_" + valName +
"_%s"%iov)
396 tmpOptions.config = tmpConfig
397 newOutPath = os.path.abspath( tmpOptions.Name )
398 if not os.path.exists( newOutPath ):
399 os.makedirs( newOutPath )
400 elif not os.path.isdir( newOutPath ):
401 raise AllInOneError(
"the file %s is in the way rename the Job or move it away"%newOutPath)
402 job =
ValidationJob( validation, tmpConfig, tmpOptions, len(iovList) )
403 validations.append(job)
408 map(
lambda validation: validation.createJob(), self.
validations )
411 return [validation.runJob()
for validation
in self.
validations]
415 dagmanLog =
"{}/daglogs".
format(outdir)
416 os.system(
"mkdir -p {}".
format(dagmanLog))
419 with open(
"{}/validation.condor".
format(outdir),
"w")
as condor:
420 condor.write(
"universe = vanilla" +
"\n")
421 condor.write(
"executable = $(scriptName).sh" +
"\n")
422 condor.write(
"log = $(scriptName).log" +
"\n")
423 condor.write(
"error = $(scriptName).stderr" +
"\n")
424 condor.write(
"output = $(scriptName).stdout" +
"\n")
425 condor.write(
'requirements = (OpSysAndVer =?= "CentOS7")' +
'\n')
426 condor.write(
'+JobFlavour = "tomorrow"' +
"\n")
427 condor.write(
'+RequestMemory = {}'.
format(1540) +
"\n")
428 condor.write(
'+FileTransferDownloadBytes = {}'.
format(1540) +
"\n")
429 condor.write(
'+AccountingGroup = "group_u_CMS.CAF.ALCA"' +
'\n')
430 condor.write(
"queue")
432 with open(
"{}/validation.dagman".
format(outdir),
"w")
as dagman:
434 for (valType, valName, iov), alignments
in six.iteritems(ValidationJob.condorConf):
436 parents[(valType, valName, iov)] = []
437 for jobInfo
in alignments:
438 if not "preexisting" in jobInfo[0]:
439 dagman.write(
"JOB {}_{} {}/validation.condor".
format(jobInfo[0], iov, outdir) +
"\n")
440 dagman.write(
'VARS {}_{} '.
format(jobInfo[0], iov) +
'scriptName="{}"'.
format(
'.'.
join(jobInfo[1].
split(
'.')[:-1])) +
"\n")
441 parents[(valType, valName, iov)].
append(
'{}_{}'.
format(jobInfo[0], iov))
444 path = os.path.join(jobInfo[2],
"TkAlMerge.sh")
445 if os.path.exists( path ):
446 dagman.write(
"JOB Merge_{}_{}_{} {}/validation.condor".
format(valType, valName, iov, outdir) +
"\n")
447 dagman.write(
"VARS Merge_{}_{}_{} ".
format(valType, valName, iov) +
'scriptName="{}"'.
format(os.path.join(jobInfo[2],
"TkAlMerge")) +
"\n")
450 raise AllInOneError(
"Merge script '[%s]' not found!"%path)
452 for (valType, valName, iov), alignments
in six.iteritems(ValidationJob.condorConf):
453 if len(parents[(valType, valName, iov)]) != 0:
454 dagman.write(
'PARENT {} '.
format(
" ".
join([parent
for parent
in parents[(valType, valName, iov)]])) +
'CHILD Merge_{}_{}_{}'.
format(valType, valName, iov) +
"\n")
456 submitCommands = [
"condor_submit_dag -no_submit -outfile_dir {} {}/validation.dagman".
format(dagmanLog, outdir),
"condor_submit {}/validation.dagman.condor.sub".
format(outdir)]
458 for command
in submitCommands:
459 subprocess.call(command.split(
" "))
462 return [validation.getValidation()
for validation
in self.
validations]
465 return [validation.needsproxy()
for validation
in self.
validations].
join(
"and")
and not self.
preexisting and not self.commandLineOptions.dryRun
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)
592 if config.has_section(
"alternateTemplates"):
593 for templateName
in config.options(
"alternateTemplates"):
594 if templateName ==
"AutoAlternates":
596 newTemplateName = config.get(
"alternateTemplates", templateName )
604 if type(item) == list:
605 flattenList.extend(
flatten(item))
608 flattenList.append(item)
617 optParser = optparse.OptionParser()
618 optParser.description =
"""All-in-one Alignment Validation. 619 This will run various validation procedures either on batch queues or interactively. 620 If no name is given (-N parameter) a name containing time and date is created automatically. 621 To merge the outcome of all validation procedures run TkAlMerge.sh in your validation's directory. 623 optParser.add_option(
"-n",
"--dryRun", dest=
"dryRun", action=
"store_true", default=
False,
624 help=
"create all scripts and cfg File but do not start jobs (default=False)")
625 optParser.add_option(
"--getImages", dest=
"getImages", action=
"store_true", default=
True,
626 help=
"get all Images created during the process (default= True)")
627 defaultConfig =
"TkAlConfig.ini" 628 optParser.add_option(
"-c",
"--config", dest=
"config", default = defaultConfig,
629 help=
"configuration to use (default TkAlConfig.ini) this can be a comma-seperated list of all .ini file you want to merge", metavar=
"CONFIG")
630 optParser.add_option(
"-N",
"--Name", dest=
"Name",
631 help=
"Name of this validation (default: alignmentValidation_DATE_TIME)", metavar=
"NAME")
632 optParser.add_option(
"-r",
"--restrictTo", dest=
"restrictTo",
633 help=
"restrict validations to given modes (comma seperated) (default: no restriction)", metavar=
"RESTRICTTO")
634 optParser.add_option(
"-d",
"--debug", dest=
"debugMode", action=
"store_true",
636 help=
"run the tool to get full traceback of errors",
640 (options, args) = optParser.parse_args(argv)
643 if not options.restrictTo ==
None:
644 options.restrictTo = options.restrictTo.split(
",")
646 options.config = [ os.path.abspath( iniFile )
for iniFile
in \
647 options.config.split(
"," )]
649 config = BetterConfigParser()
650 outputIniFileSet = set( config.read( options.config ) )
651 failedIniFiles = [ iniFile
for iniFile
in options.config
if iniFile
not in outputIniFileSet ]
654 if options.config == [ os.path.abspath( defaultConfig ) ]:
655 if (
not os.path.exists( defaultConfig ) ):
656 raise AllInOneError(
"Default 'ini' file '%s' not found!\n" 657 "You can specify another name with the " 658 "command line option '-c'/'--config'." 661 for iniFile
in failedIniFiles:
662 if not os.path.exists( iniFile ):
663 raise AllInOneError(
"'%s' does not exist. Please check for " 664 "typos in the filename passed to the " 665 "'-c'/'--config' option!" 668 raise AllInOneError((
"'%s' does exist, but parsing of the " 669 "content failed!" ) % iniFile)
672 if options.Name ==
None:
673 existingValDirs = fnmatch.filter( os.walk(
'.' ).
next()[1],
674 "alignmentValidation_*" )
675 if len( existingValDirs ) > 0:
676 options.Name = existingValDirs[-1]
678 print(
"Cannot guess last working directory!")
679 print (
"Please use the parameter '-N' or '--Name' to specify " 680 "the task for which you want a status report." )
684 outPath = os.path.abspath( options.Name )
686 general = config.getGeneral()
687 config.set(
"internals",
"workdir",os.path.join(general[
"workdir"],options.Name) )
688 config.set(
"internals",
"scriptsdir",outPath)
689 config.set(
"general",
"datadir",os.path.join(general[
"datadir"],options.Name) )
690 config.set(
"general",
"logdir",os.path.join(general[
"logdir"],options.Name) )
691 config.set(
"general",
"eosdir",os.path.join(
"AlignmentValidation", general[
"eosdir"], options.Name) )
693 if not os.path.exists( outPath ):
694 os.makedirs( outPath )
695 elif not os.path.isdir( outPath ):
696 raise AllInOneError(
"the file %s is in the way rename the Job or move it away"%outPath)
702 backupConfigFile = open( os.path.join( outPath,
"usedConfiguration.ini" ) ,
"w" )
703 config.write( backupConfigFile )
712 shutil.copyfile(
getCommandOutput2(
"voms-proxy-info --path").
strip(), os.path.join(outPath,
".user_proxy"))
716 for validation
in config.items(
"validation"):
717 alignmentList = [validation[1]]
718 validationsToAdd = [(validation[0],alignment) \
719 for alignment
in alignmentList]
720 validations.extend(validationsToAdd)
723 for validation
in validations:
725 if (job.optionMultiIOV ==
True):
731 if job.needsproxy
and not proxyexists:
732 raise AllInOneError(
"At least one job needs a grid proxy, please init one.")
734 map(
lambda job: job.createJob(), jobs )
736 validations = [ job.getValidation()
for job
in jobs ]
737 validations =
flatten(validations)
742 map(
lambda job: job.runJob(), jobs )
747 ValidationJobMultiIOV.runCondorJobs(outPath)
750 if __name__ ==
"__main__":
752 if "-d" in sys.argv[1:]
or "--debug" in sys.argv[1:]:
757 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)
S & print(S &os, JobReport::InputFile const &f)
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)
def __getValidation(self, valType, name, alignments, config, options)
— Classes —############################
def replaceByMap(target, the_map)
— Helpers —############################
def __createJob(self, jobMode, outpath)
static std::string join(char **cmd)
def alternateTemplate(templateName, alternateTemplateName)
Alternate Templates ###