3 from __future__
import print_function
4 from future.utils
import lmap
14 from abc
import ABCMeta, abstractmethod
21 import Alignment.OfflineValidation.TkAlAllInOneTool.configTemplates \
23 from Alignment.OfflineValidation.TkAlAllInOneTool.TkAlExceptions \
25 from Alignment.OfflineValidation.TkAlAllInOneTool.helperFunctions \
26 import replaceByMap, getCommandOutput2, addIndex
27 from Alignment.OfflineValidation.TkAlAllInOneTool.betterConfigParser \
28 import BetterConfigParser
29 from Alignment.OfflineValidation.TkAlAllInOneTool.alignment
import Alignment
32 import GenericValidation, ParallelValidation, ValidationWithComparison, ValidationWithPlots
33 from Alignment.OfflineValidation.TkAlAllInOneTool.geometryComparison \
34 import GeometryComparison
36 import OfflineValidation, OfflineValidationDQM
37 from Alignment.OfflineValidation.TkAlAllInOneTool.monteCarloValidation \
38 import MonteCarloValidation
40 import TrackSplittingValidation
42 import ZMuMuValidation
44 import PrimaryVertexValidation
45 from Alignment.OfflineValidation.TkAlAllInOneTool.primaryVertexResolution \
46 import PrimaryVertexResolution
47 from Alignment.OfflineValidation.TkAlAllInOneTool.preexistingValidation \
49 from Alignment.OfflineValidation.TkAlAllInOneTool.plottingOptions \
50 import PlottingOptions
51 import Alignment.OfflineValidation.TkAlAllInOneTool.globalDictionaries \
53 from Alignment.OfflineValidation.TkAlAllInOneTool.overlapValidation \
54 import OverlapValidation
60 __metaclass__ = ABCMeta
62 def __init__( self, validation, config, options ):
64 if validation[1] ==
"":
66 valString = validation[0].
split(
"->" )[0]
69 if "->" in validation[0]:
70 msg = (
"Instead of using the intermediate syntax\n'"
71 +valString.strip()+
"-> "+alignments.strip()
72 +
":'\nyou have to use the now fully supported syntax \n'"
73 +valString.strip()+
": "
74 +alignments.strip()+
"'.")
75 raise AllInOneError(msg)
77 valString = validation[0]
79 valString = valString.split()
90 if self.
valType ==
"offlineParallel":
91 print (
"offlineParallel and offline are now the same. To run an offline parallel validation,\n"
92 "just set parallelJobs to something > 1. There is no reason to call it offlineParallel anymore.")
96 raise AllInOneError(
"Validation '%s' of type '%s' is requested in"
97 " '[validation]' section, but is not defined."
98 "\nYou have to add a '[%s]' section."
119 class ValidationJob(ValidationBase):
126 def __init__( self, validation, config, options, *args, **kwargs ):
131 super(ValidationJob, self).
__init__( validation, config, options )
137 if valType ==
"compare":
138 alignmentsList = alignments.split(
"," )
139 firstAlignList = alignmentsList[0].
split()
140 firstAlignName = firstAlignList[0].
strip()
141 if firstAlignName ==
"IDEAL":
142 raise AllInOneError(
"'IDEAL' has to be the second (reference)"
143 " alignment in 'compare <val_name>: "
144 "<alignment> <reference>'.")
145 if len( firstAlignList ) > 1:
146 firstRun = firstAlignList[1]
147 elif config.has_section(
"IOV"):
148 firstRun = config.get(
"IOV",
"iov")
150 raise AllInOneError(
"Have to provide a run number for geometry comparison")
151 firstAlign =
Alignment( firstAlignName, config, firstRun )
152 firstAlignName = firstAlign.name
153 secondAlignList = alignmentsList[1].
split()
154 secondAlignName = secondAlignList[0].
strip()
155 if secondAlignName ==
"IDEAL":
156 secondAlign = secondAlignName
158 if len( secondAlignList ) > 1:
159 secondRun = secondAlignList[1]
160 elif config.has_section(
"IOV"):
161 secondRun = config.get(
"IOV",
"iov")
163 raise AllInOneError(
"Have to provide a run number for geometry comparison")
164 secondAlign =
Alignment( secondAlignName, config,
166 secondAlignName = secondAlign.name
168 validation = GeometryComparison( name, firstAlign, secondAlign,
171 elif valType ==
"offline":
172 validation = OfflineValidation( name,
173 Alignment( alignments.strip(), config ), config )
174 elif valType ==
"preexistingoffline":
175 validation = PreexistingOfflineValidation(name, config)
176 elif valType ==
"offlineDQM":
177 validation = OfflineValidationDQM( name,
178 Alignment( alignments.strip(), config ), config )
179 elif valType ==
"mcValidate":
180 validation = MonteCarloValidation( name,
181 Alignment( alignments.strip(), config ), config )
182 elif valType ==
"preexistingmcValidate":
183 validation = PreexistingMonteCarloValidation(name, config)
184 elif valType ==
"split":
185 validation = TrackSplittingValidation( name,
186 Alignment( alignments.strip(), config ), config )
187 elif valType ==
"preexistingsplit":
188 validation = PreexistingTrackSplittingValidation(name, config)
189 elif valType ==
"zmumu":
190 validation = ZMuMuValidation( name,
191 Alignment( alignments.strip(), config ), config )
192 elif valType ==
"primaryvertex":
194 Alignment( alignments.strip(), config ), config )
195 elif valType ==
"pvresolution":
197 Alignment( alignments.strip(), config ), config )
198 elif valType ==
"preexistingprimaryvertex":
199 validation = PreexistingPrimaryVertexValidation(name, self.__config)
200 elif valType ==
"overlap":
202 Alignment( alignments.strip(), self.__config ), self.__config )
204 raise AllInOneError(
"Unknown validation mode '%s'"%valType)
209 """This private method creates the needed files for the validation job.
211 self.
validation.createConfiguration( outpath )
218 """This is the method called to create the job files."""
224 general = self.
config.getGeneral()
229 iov = self.
validation.config.get(
"IOV",
"iov")
232 preexistingValType = self.
valType
233 originalValType = preexistingValType.replace(
'preexisting',
'')
234 key = (originalValType, self.
validation.originalValName, iov)
235 if key
in ValidationJob.condorConf:
236 ValidationJob.condorConf[key].
append((
"preexisting",
"", general[
"logdir"]))
238 ValidationJob.condorConf[key] = [(
"preexisting",
"", general[
"logdir"])]
239 log =
"> " + self.
validation.name +
" is already validated."
243 name = os.path.splitext( os.path.basename( script) )[0]
244 ValidationJob.jobCount += 1
246 print(
"%s would run: %s"%( name, os.path.basename( script) ))
248 log =
"> Validating "+name
249 print(
"> Validating "+name)
252 ValidationJob.interactCount += 1
253 elif self.
validation.jobmode.split(
"," )[0] ==
"condor":
255 iov = self.
validation.config.get(
"IOV",
"iov")
258 scriptPaths = script.split(
"/")
259 scriptName = scriptPaths[-1]
260 scriptName = scriptName.split(
".")
261 jobName =
"%s"%scriptName[0] +
"_%s"%scriptName[1]+
"_%s"%scriptName[2]
263 if key
in ValidationJob.condorConf:
264 ValidationJob.condorConf[key].
append((jobName, script, general[
"logdir"]))
266 ValidationJob.condorConf[key] = [(jobName, script, general[
"logdir"])]
268 raise AllInOneError(
"Unknown 'jobmode'!\n"
269 "Please change this parameter either in "
270 "the [general] or in the ["
272 +
"] section to one of the following "
274 "\tinteractive\n\tcondor, -q <queue>\n")
297 def __init__( self, validation, config, options, outPath, *args, **kwargs):
300 super(ValidationJobMultiIOV, self).
__init__( validation, config, options )
314 alignmentsList = alignments.split(
"," )
315 firstAlignList = alignmentsList[0].
split()
316 firstAlignName = firstAlignList[0].
strip()
317 secondAlignList = alignmentsList[1].
split()
318 secondAlignName = secondAlignList[0].
strip()
319 compareAlignments =
"%s"%firstAlignName +
"_vs_%s"%secondAlignName
320 sectionMultiIOV =
"multiIOV:compare"
321 if not self.
config.has_section(sectionMultiIOV):
322 raise AllInOneError(
"section'[%s]' not found. Please define the dataset"%sectionMultiIOV)
323 iovList = self.
config.get( sectionMultiIOV,
"iovs" )
324 iovList = re.sub(
r"\s+",
"", iovList, flags=re.UNICODE).
split(
"," )
326 tmpConfig = BetterConfigParser()
327 tmpConfig.read( options.config )
328 general = tmpConfig.getGeneral()
329 tmpConfig.add_section(
"IOV")
330 tmpConfig.set(
"IOV",
"iov", iov)
331 tmpConfig.set(
"internals",
"workdir",os.path.join(general[
"workdir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
332 tmpConfig.set(
"internals",
"scriptsdir",os.path.join(outPath, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
333 tmpConfig.set(
"general",
"datadir",os.path.join(general[
"datadir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
334 tmpConfig.set(
"general",
"logdir",os.path.join(general[
"logdir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
335 tmpConfig.set(
"general",
"eosdir",os.path.join(
"AlignmentValidation", general[
"eosdir"], options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov) )
336 tmpOptions = copy.deepcopy(options)
337 tmpOptions.Name = os.path.join(options.Name, self.
valType +
"_%s"%compareAlignments +
"_%s"%iov)
338 tmpOptions.config = tmpConfig
339 newOutPath = os.path.abspath( tmpOptions.Name )
340 if not os.path.exists( newOutPath ):
341 os.makedirs( newOutPath )
342 elif not os.path.isdir( newOutPath ):
343 raise AllInOneError(
"the file %s is in the way rename the Job or move it away"%newOutPath)
344 job =
ValidationJob( validation, tmpConfig, tmpOptions, len(iovList) )
345 validations.append(job)
349 if "preexisting" in self.
valType:
350 preexistingValType = self.
valType
353 originalValType = preexistingValType.replace(
'preexisting',
'')
356 originalAlignment = self.
valName
359 datasetList = re.sub(
r"\s+",
"", datasetList, flags=re.UNICODE).
split(
"," )
360 for dataset
in datasetList:
361 sectionMultiIOV =
"multiIOV:%s"%dataset
362 if not self.
config.has_section(sectionMultiIOV):
363 raise AllInOneError(
"section'[%s]' not found. Please define the dataset"%sectionMultiIOV)
365 datasetBaseName = self.
config.get( sectionMultiIOV,
"dataset" )
366 iovList = self.
config.get( sectionMultiIOV,
"iovs" )
367 iovList = re.sub(
r"\s+",
"", iovList, flags=re.UNICODE).
split(
"," )
369 datasetName = datasetBaseName+
"_since%s"%iov
370 tmpConfig = BetterConfigParser()
371 tmpConfig.read( options.config )
372 general = tmpConfig.getGeneral()
373 if "preexisting" in self.
valType:
374 valType = originalValType
375 valName = originalValName
379 tmpConfig.add_section(
"IOV")
380 tmpConfig.set(
"IOV",
"iov", iov)
381 tmpConfig.set( self.
valSection,
"dataset", datasetName )
382 tmpConfig.set(
"internals",
"workdir",os.path.join(general[
"workdir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
383 tmpConfig.set(
"internals",
"scriptsdir",os.path.join(outPath, valType +
"_" + valName +
"_%s"%iov) )
384 tmpConfig.set(
"general",
"datadir",os.path.join(general[
"datadir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
385 tmpConfig.set(
"general",
"logdir",os.path.join(general[
"logdir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
386 tmpConfig.set(
"general",
"eosdir",os.path.join(
"AlignmentValidation", general[
"eosdir"], options.Name, valType +
"_" + valName +
"_%s"%iov) )
387 if "preexisting" in self.
valType:
388 if self.
valType ==
"preexistingoffline":
389 validationClassName =
"AlignmentValidation"
397 raise AllInOneError(
"Unknown validation mode for preexisting option:'%s'"%self.
valType)
398 preexistingEosdirPath = os.path.join(
"AlignmentValidation", preexistingEosdir, valType +
"_" + valName +
"_%s"%iov)
399 file =
"/eos/cms/store/group/alca_trackeralign/AlignmentValidation/" +
"%s"%preexistingEosdirPath +
"/%s"%validationClassName +
"_%s"%originalValName +
"_%s"%originalAlignment +
".root"
400 tmpConfig.set(preexistingValSection,
"file", file)
401 tmpOptions = copy.deepcopy(options)
402 tmpOptions.Name = os.path.join(options.Name, valType +
"_" + valName +
"_%s"%iov)
403 tmpOptions.config = tmpConfig
404 newOutPath = os.path.abspath( tmpOptions.Name )
405 if not os.path.exists( newOutPath ):
406 os.makedirs( newOutPath )
407 elif not os.path.isdir( newOutPath ):
408 raise AllInOneError(
"the file %s is in the way rename the Job or move it away"%newOutPath)
409 job =
ValidationJob( validation, tmpConfig, tmpOptions, len(iovList) )
410 validations.append(job)
415 lmap(
lambda validation: validation.createJob(), self.
validations )
418 return [validation.runJob()
for validation
in self.
validations]
422 dagmanLog =
"{}/daglogs".
format(outdir)
423 os.system(
"mkdir -p {}".
format(dagmanLog))
426 with open(
"{}/validation.condor".
format(outdir),
"w")
as condor:
427 condor.write(
"universe = vanilla" +
"\n")
428 condor.write(
"executable = $(scriptName).sh" +
"\n")
429 condor.write(
"log = $(scriptName).log" +
"\n")
430 condor.write(
"error = $(scriptName).stderr" +
"\n")
431 condor.write(
"output = $(scriptName).stdout" +
"\n")
432 condor.write(
'requirements = (OpSysAndVer =?= "CentOS7")' +
'\n')
433 condor.write(
'+JobFlavour = "tomorrow"' +
"\n")
434 condor.write(
'+RequestMemory = {}'.
format(1540) +
"\n")
435 condor.write(
'+FileTransferDownloadBytes = {}'.
format(1540) +
"\n")
436 condor.write(
'+AccountingGroup = "group_u_CMS.CAF.ALCA"' +
'\n')
437 condor.write(
"queue")
439 with open(
"{}/validation.dagman".
format(outdir),
"w")
as dagman:
441 for (valType, valName, iov), alignments
in six.iteritems(ValidationJob.condorConf):
443 parents[(valType, valName, iov)] = []
444 for jobInfo
in alignments:
445 if not "preexisting" in jobInfo[0]:
446 dagman.write(
"JOB {}_{} {}/validation.condor".
format(jobInfo[0], iov, outdir) +
"\n")
447 dagman.write(
'VARS {}_{} '.
format(jobInfo[0], iov) +
'scriptName="{}"'.
format(
'.'.
join(jobInfo[1].
split(
'.')[:-1])) +
"\n")
448 parents[(valType, valName, iov)].
append(
'{}_{}'.
format(jobInfo[0], iov))
451 path = os.path.join(jobInfo[2],
"TkAlMerge.sh")
452 if os.path.exists( path ):
453 dagman.write(
"JOB Merge_{}_{}_{} {}/validation.condor".
format(valType, valName, iov, outdir) +
"\n")
454 dagman.write(
"VARS Merge_{}_{}_{} ".
format(valType, valName, iov) +
'scriptName="{}"'.
format(os.path.join(jobInfo[2],
"TkAlMerge")) +
"\n")
457 raise AllInOneError(
"Merge script '[%s]' not found!"%path)
459 for (valType, valName, iov), alignments
in six.iteritems(ValidationJob.condorConf):
460 if len(parents[(valType, valName, iov)]) != 0:
461 dagman.write(
'PARENT {} '.
format(
" ".
join([parent
for parent
in parents[(valType, valName, iov)]])) +
'CHILD Merge_{}_{}_{}'.
format(valType, valName, iov) +
"\n")
463 submitCommands = [
"condor_submit_dag -no_submit -outfile_dir {} {}/validation.dagman".
format(dagmanLog, outdir),
"condor_submit {}/validation.dagman.condor.sub".
format(outdir)]
465 for command
in submitCommands:
466 subprocess.call(command.split(
" "))
469 return [validation.getValidation()
for validation
in self.
validations]
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)
599 if config.has_section(
"alternateTemplates"):
600 for templateName
in config.options(
"alternateTemplates"):
601 if templateName ==
"AutoAlternates":
603 newTemplateName = config.get(
"alternateTemplates", templateName )
611 if type(item) == list:
612 flattenList.extend(
flatten(item))
615 flattenList.append(item)
624 optParser = optparse.OptionParser()
625 optParser.description =
"""All-in-one Alignment Validation.
626 This will run various validation procedures either on batch queues or interactively.
627 If no name is given (-N parameter) a name containing time and date is created automatically.
628 To merge the outcome of all validation procedures run TkAlMerge.sh in your validation's directory.
630 optParser.add_option(
"-n",
"--dryRun", dest=
"dryRun", action=
"store_true", default=
False,
631 help=
"create all scripts and cfg File but do not start jobs (default=False)")
632 optParser.add_option(
"--getImages", dest=
"getImages", action=
"store_true", default=
True,
633 help=
"get all Images created during the process (default= True)")
634 defaultConfig =
"TkAlConfig.ini"
635 optParser.add_option(
"-c",
"--config", dest=
"config", default = defaultConfig,
636 help=
"configuration to use (default TkAlConfig.ini) this can be a comma-seperated list of all .ini file you want to merge", metavar=
"CONFIG")
637 optParser.add_option(
"-N",
"--Name", dest=
"Name",
638 help=
"Name of this validation (default: alignmentValidation_DATE_TIME)", metavar=
"NAME")
639 optParser.add_option(
"-r",
"--restrictTo", dest=
"restrictTo",
640 help=
"restrict validations to given modes (comma seperated) (default: no restriction)", metavar=
"RESTRICTTO")
641 optParser.add_option(
"-d",
"--debug", dest=
"debugMode", action=
"store_true",
643 help=
"run the tool to get full traceback of errors",
647 (options, args) = optParser.parse_args(argv)
649 if not options.dryRun:
650 schedinfo = subprocess.check_output([
"myschedd",
"show"])
651 if not 'tzero' in schedinfo:
652 print(
"\nAll-In-One Tool: you need to call `module load lxbatch/tzero` before trying to submit jobs. Please do so and try again")
656 if not options.restrictTo ==
None:
657 options.restrictTo = options.restrictTo.split(
",")
659 options.config = [ os.path.abspath( iniFile )
for iniFile
in \
660 options.config.split(
"," )]
662 config = BetterConfigParser()
663 outputIniFileSet = set( config.read( options.config ) )
664 failedIniFiles = [ iniFile
for iniFile
in options.config
if iniFile
not in outputIniFileSet ]
667 if options.config == [ os.path.abspath( defaultConfig ) ]:
668 if (
not os.path.exists( defaultConfig ) ):
669 raise AllInOneError(
"Default 'ini' file '%s' not found!\n"
670 "You can specify another name with the "
671 "command line option '-c'/'--config'."
674 for iniFile
in failedIniFiles:
675 if not os.path.exists( iniFile ):
676 raise AllInOneError(
"'%s' does not exist. Please check for "
677 "typos in the filename passed to the "
678 "'-c'/'--config' option!"
681 raise AllInOneError((
"'%s' does exist, but parsing of the "
682 "content failed!" ) % iniFile)
685 if options.Name ==
None:
686 existingValDirs = fnmatch.filter( os.walk(
'.' ).
next()[1],
687 "alignmentValidation_*" )
688 if len( existingValDirs ) > 0:
689 options.Name = existingValDirs[-1]
691 print(
"Cannot guess last working directory!")
692 print (
"Please use the parameter '-N' or '--Name' to specify "
693 "the task for which you want a status report." )
697 outPath = os.path.abspath( options.Name )
699 general = config.getGeneral()
700 config.set(
"internals",
"workdir",os.path.join(general[
"workdir"],options.Name) )
701 config.set(
"internals",
"scriptsdir",outPath)
702 config.set(
"general",
"datadir",os.path.join(general[
"datadir"],options.Name) )
703 config.set(
"general",
"logdir",os.path.join(general[
"logdir"],options.Name) )
704 config.set(
"general",
"eosdir",os.path.join(
"AlignmentValidation", general[
"eosdir"], options.Name) )
706 if not os.path.exists( outPath ):
707 os.makedirs( outPath )
708 elif not os.path.isdir( outPath ):
709 raise AllInOneError(
"the file %s is in the way rename the Job or move it away"%outPath)
715 backupConfigFile = open( os.path.join( outPath,
"usedConfiguration.ini" ) ,
"w" )
716 config.write( backupConfigFile )
725 shutil.copyfile(
getCommandOutput2(
"voms-proxy-info --path").
strip(), os.path.join(outPath,
".user_proxy"))
729 for validation
in config.items(
"validation"):
730 validation = validation[0].
split(
"-")
731 alignmentList = [validation[1]]
732 validationsToAdd = [(validation[0],alignment) \
733 for alignment
in alignmentList]
734 validations.extend(validationsToAdd)
736 for validation
in validations:
739 if (job.optionMultiIOV ==
True):
745 if job.needsproxy
and not proxyexists:
746 raise AllInOneError(
"At least one job needs a grid proxy, please init one.")
748 lmap(
lambda job: job.createJob(), jobs )
750 validations = [ job.getValidation()
for job
in jobs ]
751 validations =
flatten(validations)
755 lmap(
lambda job: job.runJob(), jobs )
760 ValidationJobMultiIOV.runCondorJobs(outPath)
763 if __name__ ==
"__main__":
765 if "-d" in sys.argv[1:]
or "--debug" in sys.argv[1:]:
770 except AllInOneError
as e: