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

— Classes —############################ More...

Public Member Functions

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

Public Attributes

 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

— Classes —############################

Definition at line 44 of file validateAlignments.py.

Constructor & Destructor Documentation

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

Definition at line 53 of file validateAlignments.py.

References split.

53  def __init__( self, validation, config, options ):
54  if validation[1] == "":
55  # intermediate syntax
56  valString = validation[0].split( "->" )[0]
57  alignments = validation[0].split( "->" )[1]
58  # force user to use the normal syntax
59  if "->" in validation[0]:
60  msg = ("Instead of using the intermediate syntax\n'"
61  +valString.strip()+"-> "+alignments.strip()
62  +":'\nyou have to use the now fully supported syntax \n'"
63  +valString.strip()+": "
64  +alignments.strip()+"'.")
65  raise AllInOneError(msg)
66  else:
67  valString = validation[0]
68  alignments = validation[1]
69  valString = valString.split()
70  self.__valType = valString[0]
71  self.__valName = valString[1]
72  self.__commandLineOptions = options
73  self.__config = config
74  self.__preexisting = ("preexisting" in self.__valType)
75  if self.__valType[0] == "*":
76  self.__valType = self.__valType[1:]
77  self.__preexisting = True
78 
79  # workaround for intermediate parallel version
80  if self.__valType == "offlineParallel":
81  print ("offlineParallel and offline are now the same. To run an offline parallel validation,\n"
82  "just set parallelJobs to something > 1. There is no reason to call it offlineParallel anymore.")
83  self.__valType = "offline"
84  section = self.__valType + ":" + self.__valName
85  if not self.__config.has_section( section ):
86  raise AllInOneError("Validation '%s' of type '%s' is requested in"
87  " '[validation]' section, but is not defined."
88  "\nYou have to add a '[%s]' section."
89  %( self.__valName, self.__valType, section ))
90  self.validation = self.__getValidation( self.__valType, self.__valName,
91  alignments, self.__config,
92  options )
93 
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 154 of file validateAlignments.py.

References validateAlignments.ValidationJob.__preexisting.

Referenced by validateAlignments.ValidationJob.createJob().

154  def __createJob( self, jobMode, outpath ):
155  """This private method creates the needed files for the validation job.
156  """
157  self.validation.createConfiguration( outpath )
158  if self.__preexisting:
159  return
160  self.__scripts = sum([addIndex(script, self.validation.NJobs) for script in self.validation.createScript( outpath )], [])
161  if jobMode.split( ',' )[0] == "crab":
162  self.validation.createCrabCfg( outpath )
163  return None
164 
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 94 of file validateAlignments.py.

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

94  def __getValidation( self, valType, name, alignments, config, options ):
95  if valType == "compare":
96  alignmentsList = alignments.split( "," )
97  firstAlignList = alignmentsList[0].split()
98  firstAlignName = firstAlignList[0].strip()
99  if firstAlignName == "IDEAL":
100  raise AllInOneError("'IDEAL' has to be the second (reference)"
101  " alignment in 'compare <val_name>: "
102  "<alignment> <reference>'.")
103  if len( firstAlignList ) > 1:
104  firstRun = firstAlignList[1]
105  else:
106  firstRun = "1"
107  firstAlign = Alignment( firstAlignName, self.__config, firstRun )
108  firstAlignName = firstAlign.name
109  secondAlignList = alignmentsList[1].split()
110  secondAlignName = secondAlignList[0].strip()
111  if len( secondAlignList ) > 1:
112  secondRun = secondAlignList[1]
113  else:
114  secondRun = "1"
115  if secondAlignName == "IDEAL":
116  secondAlign = secondAlignName
117  else:
118  secondAlign = Alignment( secondAlignName, self.__config,
119  secondRun )
120  secondAlignName = secondAlign.name
121 
122  validation = GeometryComparison( name, firstAlign, secondAlign,
123  self.__config,
124  self.__commandLineOptions.getImages)
125  elif valType == "offline":
126  validation = OfflineValidation( name,
127  Alignment( alignments.strip(), self.__config ), self.__config )
128  elif valType == "preexistingoffline":
129  validation = PreexistingOfflineValidation(name, self.__config)
130  elif valType == "offlineDQM":
131  validation = OfflineValidationDQM( name,
132  Alignment( alignments.strip(), self.__config ), self.__config )
133  elif valType == "mcValidate":
134  validation = MonteCarloValidation( name,
135  Alignment( alignments.strip(), self.__config ), self.__config )
136  elif valType == "preexistingmcValidate":
137  validation = PreexistingMonteCarloValidation(name, self.__config)
138  elif valType == "split":
139  validation = TrackSplittingValidation( name,
140  Alignment( alignments.strip(), self.__config ), self.__config )
141  elif valType == "preexistingsplit":
142  validation = PreexistingTrackSplittingValidation(name, self.__config)
143  elif valType == "zmumu":
144  validation = ZMuMuValidation( name,
145  Alignment( alignments.strip(), self.__config ), self.__config )
146  elif valType == "primaryvertex":
147  validation = PrimaryVertexValidation( name,
148  Alignment( alignments.strip(), self.__config ), self.__config )
149  else:
150  raise AllInOneError("Unknown validation mode '%s'"%valType)
151 
152  return validation
153 
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 165 of file validateAlignments.py.

References validateAlignments.ValidationJob.__createJob().

165  def createJob(self):
166  """This is the method called to create the job files."""
167  self.__createJob( self.validation.jobmode,
168  os.path.abspath( self.__commandLineOptions.Name) )
169 
def __createJob(self, jobMode, outpath)
def validateAlignments.ValidationJob.getValidation (   self)
def validateAlignments.ValidationJob.runJob (   self)

Definition at line 170 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.

170  def runJob( self ):
171  if self.__preexisting:
172  if self.validation.jobid:
173  self.batchJobIds.append(self.validation.jobid)
174  log = "> " + self.validation.name + " is already validated."
175  print log
176  return log
177  else:
178  if self.validation.jobid:
179  print "jobid {} will be ignored, since the validation {} is not preexisting".format(self.validation.jobid, self.validation.name)
180 
181  general = self.__config.getGeneral()
182  log = ""
183  for script in self.__scripts:
184  name = os.path.splitext( os.path.basename( script) )[0]
185  ValidationJob.jobCount += 1
186  if self.__commandLineOptions.dryRun:
187  print "%s would run: %s"%( name, os.path.basename( script) )
188  continue
189  log = "> Validating "+name
190  print "> Validating "+name
191  if self.validation.jobmode == "interactive":
192  log += getCommandOutput2( script )
193  ValidationJob.interactCount += 1
194  elif self.validation.jobmode.split(",")[0] == "lxBatch":
195  repMap = {
196  "commands": self.validation.jobmode.split(",")[1],
197  "logDir": general["logdir"],
198  "jobName": name,
199  "script": script,
200  "bsub": "/afs/cern.ch/cms/caf/scripts/cmsbsub"
201  }
202  for ext in ("stdout", "stderr", "stdout.gz", "stderr.gz"):
203  oldlog = "%(logDir)s/%(jobName)s."%repMap + ext
204  if os.path.exists(oldlog):
205  os.remove(oldlog)
206  bsubOut=getCommandOutput2("%(bsub)s %(commands)s "
207  "-J %(jobName)s "
208  "-o %(logDir)s/%(jobName)s.stdout "
209  "-e %(logDir)s/%(jobName)s.stderr "
210  "%(script)s"%repMap)
211  #Attention: here it is assumed that bsub returns a string
212  #containing a job id like <123456789>
213  ValidationJob.batchJobIds.append(bsubOut.split("<")[1].split(">")[0])
214  log+=bsubOut
215  ValidationJob.batchCount += 1
216  elif self.validation.jobmode.split( "," )[0] == "crab":
217  os.chdir( general["logdir"] )
218  crabName = "crab." + os.path.basename( script )[:-3]
219  theCrab = crabWrapper.CrabWrapper()
220  options = { "-create": "",
221  "-cfg": crabName + ".cfg",
222  "-submit": "" }
223  try:
224  theCrab.run( options )
225  except AllInOneError as e:
226  print "crab:", str(e).split("\n")[0]
227  exit(1)
228  ValidationJob.crabCount += 1
229 
230  else:
231  raise AllInOneError("Unknown 'jobmode'!\n"
232  "Please change this parameter either in "
233  "the [general] or in the ["
234  + self.__valType + ":" + self.__valName
235  + "] section to one of the following "
236  "values:\n"
237  "\tinteractive\n\tlxBatch, -q <queue>\n"
238  "\tcrab, -q <queue>")
239 
240  return log
241 
def getCommandOutput2(command)
double split
Definition: MVATrainer.cc:139

Member Data Documentation

validateAlignments.ValidationJob.__commandLineOptions
private

Definition at line 72 of file validateAlignments.py.

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

Definition at line 160 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valName
private

Definition at line 71 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valType
private

Definition at line 70 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.batchCount
static

Definition at line 49 of file validateAlignments.py.

validateAlignments.ValidationJob.batchJobIds
static

Definition at line 50 of file validateAlignments.py.

validateAlignments.ValidationJob.crabCount
static

Definition at line 47 of file validateAlignments.py.

validateAlignments.ValidationJob.interactCount
static

Definition at line 48 of file validateAlignments.py.

validateAlignments.ValidationJob.jobCount
static

Definition at line 51 of file validateAlignments.py.

validateAlignments.ValidationJob.validation