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 72 of file validateAlignments.py.

Constructor & Destructor Documentation

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

Definition at line 81 of file validateAlignments.py.

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

References validateAlignments.ValidationJob.__preexisting.

Referenced by validateAlignments.ValidationJob.createJob().

185  def __createJob( self, jobMode, outpath ):
186  """This private method creates the needed files for the validation job.
187  """
188  self.validation.createConfiguration( outpath )
189  if self.__preexisting:
190  return
191  self.__scripts = sum([addIndex(script, self.validation.NJobs) for script in self.validation.createScript( outpath )], [])
192  if jobMode.split( ',' )[0] == "crab":
193  self.validation.createCrabCfg( outpath )
194  return None
195 
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 123 of file validateAlignments.py.

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

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

References validateAlignments.ValidationJob.__createJob().

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

Definition at line 279 of file validateAlignments.py.

References validateAlignments.ValidationJob.__preexisting.

279  def needsproxy(self):
280  return self.validation.needsproxy and not self.__preexisting and not self.__commandLineOptions.dryRun
281 
282 
def validateAlignments.ValidationJob.runJob (   self)

Definition at line 201 of file validateAlignments.py.

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

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

Member Data Documentation

validateAlignments.ValidationJob.__commandLineOptions
private

Definition at line 101 of file validateAlignments.py.

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

Definition at line 191 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valName
private

Definition at line 100 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valType
private

Definition at line 99 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.batchCount
static

Definition at line 77 of file validateAlignments.py.

validateAlignments.ValidationJob.batchJobIds
static

Definition at line 78 of file validateAlignments.py.

validateAlignments.ValidationJob.crabCount
static

Definition at line 75 of file validateAlignments.py.

validateAlignments.ValidationJob.interactCount
static

Definition at line 76 of file validateAlignments.py.

validateAlignments.ValidationJob.jobCount
static

Definition at line 79 of file validateAlignments.py.

validateAlignments.ValidationJob.JobId

Definition at line 82 of file validateAlignments.py.

validateAlignments.ValidationJob.validation