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 primaryVertexValidation.PrimaryVertexValidation trackSplittingValidation.TrackSplittingValidation offlineValidation.OfflineValidation genericValidation.ValidationForPresentation genericValidation.ValidationWithPlotsSummaryBase primaryVertexValidation.PrimaryVertexValidation zMuMuValidation.ZMuMuValidation preexistingValidation.PreexistingGeometryComparison preexistingValidation.PreexistingMonteCarloValidation preexistingValidation.PreexistingOfflineValidation preexistingValidation.PreexistingPrimaryVertexValidation 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 39 of file genericValidation.py.

Constructor & Destructor Documentation

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

Definition at line 52 of file genericValidation.py.

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

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

214  def createConfiguration(self, fileContents, path, schedule = None, repMap = None, repMaps = None):
215  self.configFiles = self.createFiles(fileContents,
216  path, repMap = repMap, repMaps = repMaps)
217  if not schedule == None:
218  schedule = [os.path.join( path, cfgName) for cfgName in schedule]
219  for cfgName in schedule:
220  if not cfgName in self.configFiles:
221  msg = ("scheduled %s missing in generated configfiles: %s"
222  %(cfgName, self.configFiles))
223  raise AllInOneError(msg)
224  for cfgName in self.configFiles:
225  if not cfgName in schedule:
226  msg = ("generated configuration %s not scheduled: %s"
227  %(cfgName, schedule))
228  raise AllInOneError(msg)
229  self.configFiles = schedule
230  return self.configFiles
231 
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 240 of file genericValidation.py.

References genericValidation.GenericValidation.NJobs.

240  def createCrabCfg(self, fileContents, path ):
241  if self.NJobs > 1:
242  msg = ("jobmode 'crab' not supported for parallel validation."
243  " Please set parallelJobs = 1.")
244  raise AllInOneError(msg)
245  self.crabConfigFiles = self.createFiles(fileContents, path)
246  return self.crabConfigFiles
247 
248 
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 191 of file genericValidation.py.

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

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

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

Definition at line 232 of file genericValidation.py.

232  def createScript(self, fileContents, path, downloadFiles=[], repMap = None, repMaps = None):
233  self.scriptFiles = self.createFiles(fileContents,
234  path, repMap = repMap, repMaps = repMaps)
235  for script in self.scriptFiles:
236  for scriptwithindex in addIndex(script, self.NJobs):
237  os.chmod(scriptwithindex,0o755)
238  return self.scriptFiles
239 
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 164 of file genericValidation.py.

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

Definition at line 167 of file genericValidation.py.

Referenced by trackSplittingValidation.TrackSplittingValidation.appendToPlots().

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

Definition at line 135 of file genericValidation.py.

References genericValidation.GenericValidation.alignmentToValidate, genericValidation.GenericValidation.cmssw, genericValidation.GenericValidation.cmsswreleasebase, geometry.Alignables.config, genericValidation.GenericValidation.config, genericValidation.GenericValidation.general, betterConfigParser.BetterConfigParser.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().

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

Member Data Documentation

genericValidation.GenericValidation.__metaclass__ = ValidationMetaClass
staticprivate

Definition at line 40 of file genericValidation.py.

genericValidation.GenericValidation.alignmentToValidate
genericValidation.GenericValidation.AutoAlternates

Definition at line 122 of file genericValidation.py.

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

Definition at line 245 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 43 of file genericValidation.py.

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

genericValidation.GenericValidation.general
genericValidation.GenericValidation.jobid

Definition at line 60 of file genericValidation.py.

genericValidation.GenericValidation.jobmode

Definition at line 66 of file genericValidation.py.

genericValidation.GenericValidation.mandatories = set()
static

Definition at line 42 of file genericValidation.py.

genericValidation.GenericValidation.name

Definition at line 54 of file genericValidation.py.

Referenced by ElectronMVAID.ElectronMVAID.__call__(), FWLite.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__(), FWLite.WorkingPoints._reformat_cut_definitions(), core.autovars.NTupleObjectType.addSubObjects(), core.autovars.NTupleObjectType.addVariables(), core.autovars.NTupleObjectType.allVars(), dirstructure.Directory.calcStats(), genericValidation.GenericValidationData.cfgName(), crabFunctions.CrabTask.crabConfig(), crabFunctions.CrabTask.crabFolder(), 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(), crabFunctions.CrabTask.handleNoState(), 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(), crabFunctions.CrabTask.resubmit_failed(), production_tasks.MonitorJobs.run(), validateAlignments.ParallelMergeJob.runJob(), BeautifulSoup.SoupStrainer.searchTag(), python.rootplot.utilities.Hist.TGraph(), python.rootplot.utilities.Hist.TH1F(), crabFunctions.CrabTask.update(), crabFunctions.CrabTask.updateJobStats(), Vispa.Views.PropertyView.Property.valueChanged(), counter.Counter.write(), and average.Average.write().

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

Definition at line 49 of file genericValidation.py.

genericValidation.GenericValidation.needsproxy

Definition at line 68 of file genericValidation.py.

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

Definition at line 50 of file genericValidation.py.

genericValidation.GenericValidation.packages

Definition at line 112 of file genericValidation.py.

Referenced by genericValidation.GenericValidation.getRepMap().

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

Definition at line 233 of file genericValidation.py.