CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes
validateAlignments.ValidationJob Class Reference

Public Member Functions

def __init__ (self, validation, config, options)
 
def createJob (self)
 
def getValidation (self)
 
def needsproxy (self)
 
def runJob (self)
 

Public Attributes

 JobId
 
 validation
 

Static Public Attributes

 batchCount
 
 batchJobIds
 
 crabCount
 
 interactCount
 
 jobCount
 

Private Member Functions

def __createJob (self, jobMode, outpath)
 
def __getValidation (self, valType, name, alignments, config, options)
 

Private Attributes

 __commandLineOptions
 
 __config
 
 __preexisting
 
 __scripts
 
 __valName
 
 __valType
 

Detailed Description

Definition at line 71 of file validateAlignments.py.

Constructor & Destructor Documentation

def validateAlignments.ValidationJob.__init__ (   self,
  validation,
  config,
  options 
)

Definition at line 80 of file validateAlignments.py.

80  def __init__( self, validation, config, options ):
81  self.JobId=[]
82  if validation[1] == "":
83  # intermediate syntax
84  valString = validation[0].split( "->" )[0]
85  alignments = validation[0].split( "->" )[1]
86  # force user to use the normal syntax
87  if "->" in validation[0]:
88  msg = ("Instead of using the intermediate syntax\n'"
89  +valString.strip()+"-> "+alignments.strip()
90  +":'\nyou have to use the now fully supported syntax \n'"
91  +valString.strip()+": "
92  +alignments.strip()+"'.")
93  raise AllInOneError(msg)
94  else:
95  valString = validation[0]
96  alignments = validation[1]
97  valString = valString.split()
98  self.__valType = valString[0]
99  self.__valName = valString[1]
100  self.__commandLineOptions = options
101  self.__config = config
102  self.__preexisting = ("preexisting" in self.__valType)
103  if self.__valType[0] == "*":
104  self.__valType = self.__valType[1:]
105  self.__preexisting = True
106 
107  # workaround for intermediate parallel version
108  if self.__valType == "offlineParallel":
109  print ("offlineParallel and offline are now the same. To run an offline parallel validation,\n"
110  "just set parallelJobs to something > 1. There is no reason to call it offlineParallel anymore.")
111  self.__valType = "offline"
112  section = self.__valType + ":" + self.__valName
113  if not self.__config.has_section( section ):
114  raise AllInOneError("Validation '%s' of type '%s' is requested in"
115  " '[validation]' section, but is not defined."
116  "\nYou have to add a '[%s]' section."
117  %( self.__valName, self.__valType, section ))
119  alignments, self.__config,
120  options )
121 
def __getValidation(self, valType, name, alignments, config, options)
def __init__(self, validation, config, options)
double split
Definition: MVATrainer.cc:139

Member Function Documentation

def validateAlignments.ValidationJob.__createJob (   self,
  jobMode,
  outpath 
)
private
This private method creates the needed files for the validation job.

Definition at line 182 of file validateAlignments.py.

References validateAlignments.ValidationJob.__preexisting.

Referenced by validateAlignments.ValidationJob.createJob().

182  def __createJob( self, jobMode, outpath ):
183  """This private method creates the needed files for the validation job.
184  """
185  self.validation.createConfiguration( outpath )
186  if self.__preexisting:
187  return
188  self.__scripts = sum([addIndex(script, self.validation.NJobs) for script in self.validation.createScript( outpath )], [])
189  if jobMode.split( ',' )[0] == "crab":
190  self.validation.createCrabCfg( outpath )
191  return None
192 
def addIndex(filename, njobs, index=None)
def __createJob(self, jobMode, outpath)
def validateAlignments.ValidationJob.__getValidation (   self,
  valType,
  name,
  alignments,
  config,
  options 
)
private

Definition at line 122 of file validateAlignments.py.

References validateAlignments.ValidationJob.__config, split, and digitizers_cfi.strip.

122  def __getValidation( self, valType, name, alignments, config, options ):
123  if valType == "compare":
124  alignmentsList = alignments.split( "," )
125  firstAlignList = alignmentsList[0].split()
126  firstAlignName = firstAlignList[0].strip()
127  if firstAlignName == "IDEAL":
128  raise AllInOneError("'IDEAL' has to be the second (reference)"
129  " alignment in 'compare <val_name>: "
130  "<alignment> <reference>'.")
131  if len( firstAlignList ) > 1:
132  firstRun = firstAlignList[1]
133  else:
134  firstRun = "1"
135  firstAlign = Alignment( firstAlignName, self.__config, firstRun )
136  firstAlignName = firstAlign.name
137  secondAlignList = alignmentsList[1].split()
138  secondAlignName = secondAlignList[0].strip()
139  if len( secondAlignList ) > 1:
140  secondRun = secondAlignList[1]
141  else:
142  secondRun = "1"
143  if secondAlignName == "IDEAL":
144  secondAlign = secondAlignName
145  else:
146  secondAlign = Alignment( secondAlignName, self.__config,
147  secondRun )
148  secondAlignName = secondAlign.name
149 
150  validation = GeometryComparison( name, firstAlign, secondAlign,
151  self.__config,
152  self.__commandLineOptions.getImages)
153  elif valType == "offline":
154  validation = OfflineValidation( name,
155  Alignment( alignments.strip(), self.__config ), self.__config )
156  elif valType == "preexistingoffline":
157  validation = PreexistingOfflineValidation(name, self.__config)
158  elif valType == "offlineDQM":
159  validation = OfflineValidationDQM( name,
160  Alignment( alignments.strip(), self.__config ), self.__config )
161  elif valType == "mcValidate":
162  validation = MonteCarloValidation( name,
163  Alignment( alignments.strip(), self.__config ), self.__config )
164  elif valType == "preexistingmcValidate":
165  validation = PreexistingMonteCarloValidation(name, self.__config)
166  elif valType == "split":
167  validation = TrackSplittingValidation( name,
168  Alignment( alignments.strip(), self.__config ), self.__config )
169  elif valType == "preexistingsplit":
170  validation = PreexistingTrackSplittingValidation(name, self.__config)
171  elif valType == "zmumu":
172  validation = ZMuMuValidation( name,
173  Alignment( alignments.strip(), self.__config ), self.__config )
174  elif valType == "primaryvertex":
175  validation = PrimaryVertexValidation( name,
176  Alignment( alignments.strip(), self.__config ), self.__config )
177  else:
178  raise AllInOneError("Unknown validation mode '%s'"%valType)
179 
180  return validation
181 
def __getValidation(self, valType, name, alignments, config, options)
double split
Definition: MVATrainer.cc:139
def validateAlignments.ValidationJob.createJob (   self)
This is the method called to create the job files.

Definition at line 193 of file validateAlignments.py.

References validateAlignments.ValidationJob.__createJob().

193  def createJob(self):
194  """This is the method called to create the job files."""
195  self.__createJob( self.validation.jobmode,
196  os.path.abspath( self.__commandLineOptions.Name) )
197 
def __createJob(self, jobMode, outpath)
def validateAlignments.ValidationJob.getValidation (   self)
def validateAlignments.ValidationJob.needsproxy (   self)

Definition at line 276 of file validateAlignments.py.

References validateAlignments.ValidationJob.__preexisting.

276  def needsproxy(self):
277  return self.validation.needsproxy and not self.__preexisting and not self.__commandLineOptions.dryRun
278 
279 
def validateAlignments.ValidationJob.runJob (   self)

Definition at line 198 of file validateAlignments.py.

References validateAlignments.ValidationJob.__preexisting, validateAlignments.ValidationJob.__scripts, validateAlignments.ValidationJob.__valName, validateAlignments.ValidationJob.__valType, cmsRelvalreport.exit, helperFunctions.getCommandOutput2(), split, and harvestTrackValidationPlots.str.

198  def runJob( self ):
199  if self.__preexisting:
200  if self.validation.jobid:
201  self.batchJobIds.append(self.validation.jobid)
202  log = "> " + self.validation.name + " is already validated."
203  print log
204  return log
205  else:
206  if self.validation.jobid:
207  print "jobid {} will be ignored, since the validation {} is not preexisting".format(self.validation.jobid, self.validation.name)
208 
209  general = self.__config.getGeneral()
210  log = ""
211  for script in self.__scripts:
212  name = os.path.splitext( os.path.basename( script) )[0]
213  ValidationJob.jobCount += 1
214  if self.__commandLineOptions.dryRun:
215  print "%s would run: %s"%( name, os.path.basename( script) )
216  continue
217  log = "> Validating "+name
218  print "> Validating "+name
219  if self.validation.jobmode == "interactive":
220  log += getCommandOutput2( script )
221  ValidationJob.interactCount += 1
222  elif self.validation.jobmode.split(",")[0] == "lxBatch":
223  repMap = {
224  "commands": self.validation.jobmode.split(",")[1],
225  "logDir": general["logdir"],
226  "jobName": name,
227  "script": script,
228  "bsub": "/afs/cern.ch/cms/caf/scripts/cmsbsub"
229  }
230  for ext in ("stdout", "stderr", "stdout.gz", "stderr.gz"):
231  oldlog = "%(logDir)s/%(jobName)s."%repMap + ext
232  if os.path.exists(oldlog):
233  os.remove(oldlog)
234  bsubOut=getCommandOutput2("%(bsub)s %(commands)s "
235  "-J %(jobName)s "
236  "-o %(logDir)s/%(jobName)s.stdout "
237  "-e %(logDir)s/%(jobName)s.stderr "
238  "%(script)s"%repMap)
239  #Attention: here it is assumed that bsub returns a string
240  #containing a job id like <123456789>
241  jobid=bsubOut.split("<")[1].split(">")[0]
242  self.JobId.append(jobid)
243  ValidationJob.batchJobIds.append(jobid)
244  log+=bsubOut
245  ValidationJob.batchCount += 1
246  elif self.validation.jobmode.split( "," )[0] == "crab":
247  os.chdir( general["logdir"] )
248  crabName = "crab." + os.path.basename( script )[:-3]
249  theCrab = crabWrapper.CrabWrapper()
250  options = { "-create": "",
251  "-cfg": crabName + ".cfg",
252  "-submit": "" }
253  try:
254  theCrab.run( options )
255  except AllInOneError as e:
256  print "crab:", str(e).split("\n")[0]
257  exit(1)
258  ValidationJob.crabCount += 1
259 
260  else:
261  raise AllInOneError("Unknown 'jobmode'!\n"
262  "Please change this parameter either in "
263  "the [general] or in the ["
264  + self.__valType + ":" + self.__valName
265  + "] section to one of the following "
266  "values:\n"
267  "\tinteractive\n\tlxBatch, -q <queue>\n"
268  "\tcrab, -q <queue>")
269 
270  return log
271 
def getCommandOutput2(command)
double split
Definition: MVATrainer.cc:139

Member Data Documentation

validateAlignments.ValidationJob.__commandLineOptions
private

Definition at line 100 of file validateAlignments.py.

validateAlignments.ValidationJob.__config
private
validateAlignments.ValidationJob.__preexisting
private
validateAlignments.ValidationJob.__scripts
private

Definition at line 188 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valName
private

Definition at line 99 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valType
private

Definition at line 98 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.batchCount
static

Definition at line 76 of file validateAlignments.py.

validateAlignments.ValidationJob.batchJobIds
static

Definition at line 77 of file validateAlignments.py.

validateAlignments.ValidationJob.crabCount
static

Definition at line 74 of file validateAlignments.py.

validateAlignments.ValidationJob.interactCount
static

Definition at line 75 of file validateAlignments.py.

validateAlignments.ValidationJob.jobCount
static

Definition at line 78 of file validateAlignments.py.

validateAlignments.ValidationJob.JobId

Definition at line 81 of file validateAlignments.py.

validateAlignments.ValidationJob.validation