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
Inheritance diagram for validateAlignments.ValidationJob:

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

Constructor & Destructor Documentation

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

Definition at line 82 of file validateAlignments.py.

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

References validateAlignments.ValidationJob.__preexisting.

Referenced by validateAlignments.ValidationJob.createJob().

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

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

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

References validateAlignments.ValidationJob.__createJob().

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

Definition at line 280 of file validateAlignments.py.

References validateAlignments.ValidationJob.__preexisting.

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

Definition at line 202 of file validateAlignments.py.

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

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

Member Data Documentation

validateAlignments.ValidationJob.__commandLineOptions
private

Definition at line 102 of file validateAlignments.py.

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

Definition at line 192 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valName
private

Definition at line 101 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valType
private

Definition at line 100 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.batchCount
static

Definition at line 78 of file validateAlignments.py.

validateAlignments.ValidationJob.batchJobIds
static

Definition at line 79 of file validateAlignments.py.

validateAlignments.ValidationJob.crabCount
static

Definition at line 76 of file validateAlignments.py.

validateAlignments.ValidationJob.interactCount
static

Definition at line 77 of file validateAlignments.py.

validateAlignments.ValidationJob.jobCount
static

Definition at line 80 of file validateAlignments.py.

validateAlignments.ValidationJob.JobId

Definition at line 83 of file validateAlignments.py.

validateAlignments.ValidationJob.validation