CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes
genericValidation.GenericValidation Class Reference
Inheritance diagram for genericValidation.GenericValidation:
genericValidation.GenericValidationData genericValidation.ParallelValidation genericValidation.ValidationWithComparison genericValidation.ValidationWithPlots geometryComparison.GeometryComparison preexistingValidation.PreexistingValidation genericValidation.GenericValidationData_CTSR monteCarloValidation.MonteCarloValidation zMuMuValidation.ZMuMuValidation offlineValidation.OfflineValidation trackSplittingValidation.TrackSplittingValidation offlineValidation.OfflineValidation genericValidation.ValidationForPresentation genericValidation.ValidationWithPlotsSummaryBase primaryVertexValidation.PrimaryVertexValidation zMuMuValidation.ZMuMuValidation preexistingValidation.PreexistingGeometryComparison preexistingValidation.PreexistingMonteCarloValidation preexistingValidation.PreexistingOfflineValidation preexistingValidation.PreexistingTrackSplittingValidation preexistingValidation.PreexistingZMuMuValidation

Public Member Functions

def __init__ (self, valName, alignment, config)
 
def createConfiguration (self, fileContents, path, schedule=None, repMap=None, repMaps=None)
 
def createCrabCfg (self, fileContents, path)
 
def createFiles (self, fileContents, path, repMap=None, repMaps=None)
 
def createScript (self, fileContents, path, downloadFiles=[], repMap=None, repMaps=None)
 
def filesToCompare (self)
 
def getCompareStrings (self, requestId=None, plain=False)
 
def getRepMap (self, alignment=None)
 

Public Attributes

 alignmentToValidate
 
 AutoAlternates
 
 cmssw
 
 cmsswreleasebase
 
 config
 
 configFiles
 
 crabConfigFiles
 
 general
 
 jobid
 
 jobmode
 
 name
 
 needsproxy
 
 NJobs
 
 packages
 
 randomWorkdirPart
 
 scramarch
 
 scriptFiles
 

Static Public Attributes

string defaultReferenceName = "DEFAULT"
 
dictionary defaults
 
 mandatories = set()
 
dictionary needpackages = {"Alignment/OfflineValidation"}
 
dictionary optionals = {"jobmode"}
 

Static Private Attributes

 __metaclass__ = ValidationMetaClass
 

Detailed Description

Definition at line 38 of file genericValidation.py.

Constructor & Destructor Documentation

def genericValidation.GenericValidation.__init__ (   self,
  valName,
  alignment,
  config 
)

Definition at line 51 of file genericValidation.py.

51  def __init__(self, valName, alignment, config):
52  import random
53  self.name = valName
54  self.alignmentToValidate = alignment
55  self.general = config.getGeneral()
56  self.randomWorkdirPart = "%0i"%random.randint(1,10e9)
57  self.configFiles = []
58  self.config = config
59  self.jobid = ""
60 
61  theUpdate = config.getResultingSection(self.valType+":"+self.name,
62  defaultDict = self.defaults,
63  demandPars = self.mandatories)
64  self.general.update(theUpdate)
65  self.jobmode = self.general["jobmode"]
66  self.NJobs = int(self.general["parallelJobs"])
67  self.needsproxy = boolfromstring(self.general["needsproxy"], "needsproxy")
68 
69  # limit maximum number of parallel jobs to 40
70  # (each output file is approximately 20MB)
71  maximumNumberJobs = 40
72  if self.NJobs > maximumNumberJobs:
73  msg = ("Maximum allowed number of parallel jobs "
74  +str(maximumNumberJobs)+" exceeded!!!")
75  raise AllInOneError(msg)
76  if self.NJobs > 1 and not isinstance(self, ParallelValidation):
77  raise AllInOneError("Parallel jobs not implemented for {}!\n"
78  "Please set parallelJobs = 1.".format(type(self).__name__))
79 
80  self.jobid = self.general["jobid"]
81  if self.jobid:
82  try: #make sure it's actually a valid jobid
83  output = getCommandOutput2("bjobs %(jobid)s 2>&1"%self.general)
84  if "is not found" in output: raise RuntimeError
85  except RuntimeError:
86  raise AllInOneError("%s is not a valid jobid.\nMaybe it finished already?"%self.jobid)
87 
88  self.cmssw = self.general["cmssw"]
89  badcharacters = r"\'"
90  for character in badcharacters:
91  if character in self.cmssw:
92  raise AllInOneError("The bad characters " + badcharacters + " are not allowed in the cmssw\n"
93  "path name. If you really have it in such a ridiculously named location,\n"
94  "try making a symbolic link somewhere with a decent name.")
95  try:
96  os.listdir(self.cmssw)
97  except OSError:
98  raise AllInOneError("Your cmssw release " + self.cmssw + ' does not exist')
99 
100  if self.cmssw == os.environ["CMSSW_BASE"]:
101  self.scramarch = os.environ["SCRAM_ARCH"]
102  self.cmsswreleasebase = os.environ["CMSSW_RELEASE_BASE"]
103  else:
104  command = ("cd '" + self.cmssw + "' && eval `scramv1 ru -sh 2> /dev/null`"
105  ' && echo "$CMSSW_BASE\n$SCRAM_ARCH\n$CMSSW_RELEASE_BASE"')
106  commandoutput = getCommandOutput2(command).split('\n')
107  self.cmssw = commandoutput[0]
108  self.scramarch = commandoutput[1]
109  self.cmsswreleasebase = commandoutput[2]
110 
111  self.packages = {}
112  for package in self.needpackages:
113  for placetolook in self.cmssw, self.cmsswreleasebase:
114  pkgpath = os.path.join(placetolook, "src", package)
115  if os.path.exists(pkgpath):
116  self.packages[package] = pkgpath
117  break
118  else:
119  raise AllInOneError("Package {} does not exist in {} or {}!".format(package, self.cmssw, self.cmsswreleasebase))
120 
121  self.AutoAlternates = True
122  if config.has_option("alternateTemplates","AutoAlternates"):
123  try:
124  self.AutoAlternates = json.loads(config.get("alternateTemplates","AutoAlternates").lower())
125  except ValueError:
126  raise AllInOneError("AutoAlternates needs to be true or false, not %s" % config.get("alternateTemplates","AutoAlternates"))
127 
128  knownOpts = set(self.defaults.keys())|self.mandatories|self.optionals
129  ignoreOpts = []
130  config.checkInput(self.valType+":"+self.name,
131  knownSimpleOptions = knownOpts,
132  ignoreOptions = ignoreOpts)
133 
def __init__(self, valName, alignment, config)
def getCommandOutput2(command)
def boolfromstring(string, name)
double split
Definition: MVATrainer.cc:139

Member Function Documentation

def genericValidation.GenericValidation.createConfiguration (   self,
  fileContents,
  path,
  schedule = None,
  repMap = None,
  repMaps = None 
)

Definition at line 213 of file genericValidation.py.

References genericValidation.GenericValidation.configFiles, and genericValidation.GenericValidation.createFiles().

213  def createConfiguration(self, fileContents, path, schedule = None, repMap = None, repMaps = None):
214  self.configFiles = self.createFiles(fileContents,
215  path, repMap = repMap, repMaps = repMaps)
216  if not schedule == None:
217  schedule = [os.path.join( path, cfgName) for cfgName in schedule]
218  for cfgName in schedule:
219  if not cfgName in self.configFiles:
220  msg = ("scheduled %s missing in generated configfiles: %s"
221  %(cfgName, self.configFiles))
222  raise AllInOneError(msg)
223  for cfgName in self.configFiles:
224  if not cfgName in schedule:
225  msg = ("generated configuration %s not scheduled: %s"
226  %(cfgName, schedule))
227  raise AllInOneError(msg)
228  self.configFiles = schedule
229  return self.configFiles
230 
def createConfiguration(self, fileContents, path, schedule=None, repMap=None, repMaps=None)
def createFiles(self, fileContents, path, repMap=None, repMaps=None)
def genericValidation.GenericValidation.createCrabCfg (   self,
  fileContents,
  path 
)

Definition at line 239 of file genericValidation.py.

References genericValidation.GenericValidation.NJobs.

239  def createCrabCfg(self, fileContents, path ):
240  if self.NJobs > 1:
241  msg = ("jobmode 'crab' not supported for parallel validation."
242  " Please set parallelJobs = 1.")
243  raise AllInOneError(msg)
244  self.crabConfigFiles = self.createFiles(fileContents, path)
245  return self.crabConfigFiles
246 
247 
def createFiles(self, fileContents, path, repMap=None, repMaps=None)
def createCrabCfg(self, fileContents, path)
def genericValidation.GenericValidation.createFiles (   self,
  fileContents,
  path,
  repMap = None,
  repMaps = None 
)
repMap: single map for all files
   repMaps: a dict, with the filenames as the keys

Definition at line 190 of file genericValidation.py.

References helperFunctions.addIndex(), genericValidation.GenericValidation.NJobs, helperFunctions.replaceByMap(), and harvestTrackValidationPlots.str.

Referenced by genericValidation.GenericValidation.createConfiguration(), and geometryComparison.GeometryComparison.createScript().

190  def createFiles(self, fileContents, path, repMap = None, repMaps = None):
191  """repMap: single map for all files
192  repMaps: a dict, with the filenames as the keys"""
193  if repMap is not None and repMaps is not None:
194  raise AllInOneError("createFiles can only take repMap or repMaps (or neither), not both")
195  result = []
196  for fileName in fileContents:
197  filePath = os.path.join(path, fileName)
198  result.append(filePath)
199 
200  for (i, filePathi) in enumerate(addIndex(filePath, self.NJobs)):
201  theFile = open( filePathi, "w" )
202  fileContentsi = fileContents[ fileName ]
203  if repMaps is not None:
204  repMap = repMaps[fileName]
205  if repMap is not None:
206  repMap.update({"nIndex": str(i)})
207  fileContentsi = replaceByMap(fileContentsi, repMap)
208  theFile.write( fileContentsi )
209  theFile.close()
210 
211  return result
212 
def addIndex(filename, njobs, index=None)
def replaceByMap(target, the_map)
— Helpers —############################
def createFiles(self, fileContents, path, repMap=None, repMaps=None)
def genericValidation.GenericValidation.createScript (   self,
  fileContents,
  path,
  downloadFiles = [],
  repMap = None,
  repMaps = None 
)

Definition at line 231 of file genericValidation.py.

231  def createScript(self, fileContents, path, downloadFiles=[], repMap = None, repMaps = None):
232  self.scriptFiles = self.createFiles(fileContents,
233  path, repMap = repMap, repMaps = repMaps)
234  for script in self.scriptFiles:
235  for scriptwithindex in addIndex(script, self.NJobs):
236  os.chmod(scriptwithindex,0o755)
237  return self.scriptFiles
238 
def createScript(self, fileContents, path, downloadFiles=[], repMap=None, repMaps=None)
def addIndex(filename, njobs, index=None)
def createFiles(self, fileContents, path, repMap=None, repMaps=None)
def genericValidation.GenericValidation.filesToCompare (   self)

Definition at line 163 of file genericValidation.py.

163  def filesToCompare(self):
164  pass
165 
def genericValidation.GenericValidation.getCompareStrings (   self,
  requestId = None,
  plain = False 
)

Definition at line 166 of file genericValidation.py.

Referenced by trackSplittingValidation.TrackSplittingValidation.appendToPlots().

166  def getCompareStrings( self, requestId = None, plain = False ):
167  result = {}
168  repMap = self.getRepMap().copy()
169  for validationId in self.filesToCompare:
170  repMap["file"] = self.filesToCompare[ validationId ]
171  if repMap["file"].startswith( "/castor/" ):
172  repMap["file"] = "rfio:%(file)s"%repMap
173  elif repMap["file"].startswith( "/store/" ):
174  repMap["file"] = "root://eoscms.cern.ch//eos/cms%(file)s"%repMap
175  if plain:
176  result[validationId]=repMap["file"]
177  else:
178  result[validationId]= "%(file)s=%(title)s|%(color)s|%(style)s"%repMap
179  if requestId == None:
180  return result
181  else:
182  if not "." in requestId:
183  requestId += ".%s"%self.defaultReferenceName
184  if not requestId.split(".")[-1] in result:
185  msg = ("could not find %s in reference Objects!"
186  %requestId.split(".")[-1])
187  raise AllInOneError(msg)
188  return result[ requestId.split(".")[-1] ]
189 
def getRepMap(self, alignment=None)
def getCompareStrings(self, requestId=None, plain=False)
def genericValidation.GenericValidation.getRepMap (   self,
  alignment = None 
)

Definition at line 134 of file genericValidation.py.

References genericValidation.GenericValidation.alignmentToValidate, genericValidation.GenericValidation.cmssw, genericValidation.GenericValidation.cmsswreleasebase, geometry.Alignables.config, genericValidation.GenericValidation.config, genericValidation.GenericValidation.general, genericValidation.GenericValidation.packages, plottingOptions.PlottingOptions(), genericValidation.GenericValidation.randomWorkdirPart, genericValidation.GenericValidation.scramarch, trackSplittingValidation.TrackSplittingValidation.valType, monteCarloValidation.MonteCarloValidation.valType, primaryVertexValidation.PrimaryVertexValidation.valType, zMuMuValidation.ZMuMuValidation.valType, offlineValidation.OfflineValidation.valType, and geometryComparison.GeometryComparison.valType.

Referenced by trackSplittingValidation.TrackSplittingValidation.appendToMerge(), primaryVertexValidation.PrimaryVertexValidation.appendToMerge(), offlineValidation.OfflineValidation.appendToMerge(), trackSplittingValidation.TrackSplittingValidation.appendToPlots(), primaryVertexValidation.PrimaryVertexValidation.appendToPlots(), zMuMuValidation.ZMuMuValidation.appendToPlots(), geometryComparison.GeometryComparison.createConfiguration(), genericValidation.GenericValidationData.createConfiguration(), genericValidation.GenericValidationData.createCrabCfg(), geometryComparison.GeometryComparison.createScript(), genericValidation.GenericValidationData.createScript(), genericValidation.ParallelValidation.doMerge(), zMuMuValidation.ZMuMuValidation.filesToCompare(), genericValidation.GenericValidationData.filesToCompare(), genericValidation.GenericValidation.getCompareStrings(), and plottingOptions.PlottingOptionsTrackSplitting.validsubdets().

134  def getRepMap(self, alignment = None):
135  from plottingOptions import PlottingOptions
136  if alignment == None:
137  alignment = self.alignmentToValidate
138  try:
139  result = PlottingOptions(self.config, self.valType)
140  except KeyError:
141  result = {}
142  result.update(alignment.getRepMap())
143  result.update(self.general)
144  result.update({
145  "workdir": os.path.join(self.general["workdir"],
146  self.randomWorkdirPart),
147  "datadir": self.general["datadir"],
148  "logdir": self.general["logdir"],
149  "CommandLineTemplate": ("#run configfile and post-proccess it\n"
150  "cmsRun %(cfgFile)s\n"
151  "%(postProcess)s "),
152  "CMSSW_BASE": self.cmssw,
153  "SCRAM_ARCH": self.scramarch,
154  "CMSSW_RELEASE_BASE": self.cmsswreleasebase,
155  "alignmentName": alignment.name,
156  "condLoad": alignment.getConditions(),
157  "LoadGlobalTagTemplate": configTemplates.loadGlobalTagTemplate,
158  })
159  result.update(self.packages)
160  return result
161 
def PlottingOptions(config, valType)
def getRepMap(self, alignment=None)

Member Data Documentation

genericValidation.GenericValidation.__metaclass__ = ValidationMetaClass
staticprivate

Definition at line 39 of file genericValidation.py.

genericValidation.GenericValidation.alignmentToValidate
genericValidation.GenericValidation.AutoAlternates

Definition at line 121 of file genericValidation.py.

genericValidation.GenericValidation.cmssw
genericValidation.GenericValidation.cmsswreleasebase
genericValidation.GenericValidation.config
genericValidation.GenericValidation.configFiles
genericValidation.GenericValidation.crabConfigFiles

Definition at line 244 of file genericValidation.py.

string genericValidation.GenericValidation.defaultReferenceName = "DEFAULT"
static
dictionary genericValidation.GenericValidation.defaults
static
Initial value:
1 = {
2  "cmssw": os.environ['CMSSW_BASE'],
3  "parallelJobs": "1",
4  "jobid": "",
5  "needsproxy": "false",
6  }

Definition at line 42 of file genericValidation.py.

Referenced by tree.Tree.reset(), and tree.Tree.var().

genericValidation.GenericValidation.general
genericValidation.GenericValidation.jobid

Definition at line 59 of file genericValidation.py.

genericValidation.GenericValidation.jobmode

Definition at line 65 of file genericValidation.py.

genericValidation.GenericValidation.mandatories = set()
static

Definition at line 41 of file genericValidation.py.

genericValidation.GenericValidation.name

Definition at line 53 of file genericValidation.py.

Referenced by ElectronMVAID.ElectronMVAID.__call__(), dirstructure.Directory.__create_pie_image(), DisplayManager.DisplayManager.__del__(), dqm_interfaces.DirID.__eq__(), BeautifulSoup.Tag.__eq__(), dirstructure.Directory.__get_full_path(), dirstructure.Comparison.__get_img_name(), dataset.Dataset.__getDataType(), dataset.Dataset.__getFileInfoList(), dirstructure.Comparison.__make_image(), core.autovars.NTupleVariable.__repr__(), core.autovars.NTupleObjectType.__repr__(), core.autovars.NTupleObject.__repr__(), core.autovars.NTupleCollection.__repr__(), dirstructure.Directory.__repr__(), dqm_interfaces.DirID.__repr__(), dirstructure.Comparison.__repr__(), config.Service.__setattr__(), config.CFG.__str__(), counter.Counter.__str__(), average.Average.__str__(), BeautifulSoup.Tag.__str__(), BeautifulSoup.SoupStrainer.__str__(), core.autovars.NTupleObjectType.addSubObjects(), core.autovars.NTupleObjectType.addVariables(), core.autovars.NTupleObjectType.allVars(), dirstructure.Directory.calcStats(), genericValidation.GenericValidationData.cfgName(), genericValidation.GenericValidationData.createCrabCfg(), geometryComparison.GeometryComparison.createScript(), genericValidation.GenericValidationData.createScript(), validation.Sample.digest(), python.rootplot.utilities.Hist.divide(), python.rootplot.utilities.Hist.divide_wilson(), DisplayManager.DisplayManager.Draw(), TreeCrawler.Package.dump(), core.autovars.NTupleVariable.fillBranch(), core.autovars.NTupleObject.fillBranches(), core.autovars.NTupleCollection.fillBranchesScalar(), core.autovars.NTupleCollection.fillBranchesVector(), core.autovars.NTupleCollection.get_cpp_declaration(), core.autovars.NTupleCollection.get_cpp_wrapper_class(), core.autovars.NTupleCollection.get_py_wrapper_class(), utils.StatisticalTest.get_status(), production_tasks.Task.getname(), dataset.CMSDataset.getPrimaryDatasetEntries(), dataset.PrivateDataset.getPrimaryDatasetEntries(), primaryVertexValidation.PrimaryVertexValidation.getRepMap(), zMuMuValidation.ZMuMuValidation.getRepMap(), genericValidation.GenericValidationData.getRepMap(), VIDSelectorBase.VIDSelectorBase.initialize(), personalPlayback.Applet.log(), core.autovars.NTupleVariable.makeBranch(), core.autovars.NTupleObject.makeBranches(), core.autovars.NTupleCollection.makeBranchesScalar(), core.autovars.NTupleCollection.makeBranchesVector(), dirstructure.Directory.print_report(), dataset.BaseDataset.printInfo(), dataset.Dataset.printInfo(), production_tasks.MonitorJobs.run(), validateAlignments.ParallelMergeJob.runJob(), BeautifulSoup.SoupStrainer.searchTag(), python.rootplot.utilities.Hist.TGraph(), python.rootplot.utilities.Hist.TH1F(), Vispa.Views.PropertyView.Property.valueChanged(), counter.Counter.write(), and average.Average.write().

dictionary genericValidation.GenericValidation.needpackages = {"Alignment/OfflineValidation"}
static

Definition at line 48 of file genericValidation.py.

genericValidation.GenericValidation.needsproxy

Definition at line 67 of file genericValidation.py.

genericValidation.GenericValidation.NJobs
dictionary genericValidation.GenericValidation.optionals = {"jobmode"}
static

Definition at line 49 of file genericValidation.py.

genericValidation.GenericValidation.packages

Definition at line 111 of file genericValidation.py.

Referenced by genericValidation.GenericValidation.getRepMap().

genericValidation.GenericValidation.randomWorkdirPart
genericValidation.GenericValidation.scramarch
genericValidation.GenericValidation.scriptFiles

Definition at line 232 of file genericValidation.py.