test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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__
 
def createJob
 
def getValidation
 
def runJob
 

Public Attributes

 validation
 

Static Public Attributes

int batchCount = 0
 
list batchJobIds = []
 
int crabCount = 0
 
int interactCount = 0
 
int jobCount = 0
 

Private Member Functions

def __createJob
 
def __getValidation
 

Private Attributes

 __commandLineOptions
 
 __config
 
 __preexisting
 
 __scripts
 
 __valName
 
 __valType
 

Detailed Description

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

Definition at line 42 of file validateAlignments.py.

Constructor & Destructor Documentation

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

Definition at line 51 of file validateAlignments.py.

References split.

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

References validateAlignments.ValidationJob.__preexisting.

Referenced by validateAlignments.ValidationJob.createJob().

150  def __createJob( self, jobMode, outpath ):
151  """This private method creates the needed files for the validation job.
152  """
153  self.validation.createConfiguration( outpath )
154  if self.__preexisting:
155  return
156  self.__scripts = sum([addIndex(script, self.validation.NJobs) for script in self.validation.createScript( outpath )], [])
157  if jobMode.split( ',' )[0] == "crab":
158  self.validation.createCrabCfg( outpath )
159  return None
def validateAlignments.ValidationJob.__getValidation (   self,
  valType,
  name,
  alignments,
  config,
  options 
)
private

Definition at line 92 of file validateAlignments.py.

References validateAlignments.ValidationJob.__config, and split.

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

Definition at line 160 of file validateAlignments.py.

References validateAlignments.ValidationJob.__createJob().

161  def createJob(self):
162  """This is the method called to create the job files."""
163  self.__createJob( self.validation.jobmode,
164  os.path.abspath( self.__commandLineOptions.Name) )
def validateAlignments.ValidationJob.getValidation (   self)

Definition at line 234 of file validateAlignments.py.

References validateAlignments.ValidationJob.validation.

235  def getValidation( self ):
236  return self.validation
237 
def validateAlignments.ValidationJob.runJob (   self)

Definition at line 165 of file validateAlignments.py.

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

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

Member Data Documentation

validateAlignments.ValidationJob.__commandLineOptions
private

Definition at line 70 of file validateAlignments.py.

validateAlignments.ValidationJob.__config
private

Definition at line 71 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.__getValidation().

validateAlignments.ValidationJob.__preexisting
private

Definition at line 72 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.__createJob(), and validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__scripts
private

Definition at line 155 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valName
private

Definition at line 69 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valType
private

Definition at line 68 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

int validateAlignments.ValidationJob.batchCount = 0
static

Definition at line 47 of file validateAlignments.py.

list validateAlignments.ValidationJob.batchJobIds = []
static

Definition at line 48 of file validateAlignments.py.

int validateAlignments.ValidationJob.crabCount = 0
static

Definition at line 45 of file validateAlignments.py.

int validateAlignments.ValidationJob.interactCount = 0
static

Definition at line 46 of file validateAlignments.py.

int validateAlignments.ValidationJob.jobCount = 0
static

Definition at line 49 of file validateAlignments.py.

validateAlignments.ValidationJob.validation

Definition at line 88 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.getValidation().