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

Constructor & Destructor Documentation

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

Definition at line 49 of file validateAlignments.py.

References split.

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

References validateAlignments.ValidationJob.__preexisting.

Referenced by validateAlignments.ValidationJob.createJob().

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

Definition at line 90 of file validateAlignments.py.

References validateAlignments.ValidationJob.__config, and split.

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

References validateAlignments.ValidationJob.__createJob().

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

Definition at line 232 of file validateAlignments.py.

References validateAlignments.ValidationJob.validation.

233  def getValidation( self ):
234  return self.validation
235 
def validateAlignments.ValidationJob.runJob (   self)

Definition at line 163 of file validateAlignments.py.

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

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

Member Data Documentation

validateAlignments.ValidationJob.__commandLineOptions
private

Definition at line 68 of file validateAlignments.py.

validateAlignments.ValidationJob.__config
private

Definition at line 69 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.__getValidation().

validateAlignments.ValidationJob.__preexisting
private

Definition at line 70 of file validateAlignments.py.

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

validateAlignments.ValidationJob.__scripts
private

Definition at line 153 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valName
private

Definition at line 67 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valType
private

Definition at line 66 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

int validateAlignments.ValidationJob.batchCount = 0
static

Definition at line 45 of file validateAlignments.py.

list validateAlignments.ValidationJob.batchJobIds = []
static

Definition at line 46 of file validateAlignments.py.

int validateAlignments.ValidationJob.crabCount = 0
static

Definition at line 43 of file validateAlignments.py.

int validateAlignments.ValidationJob.interactCount = 0
static

Definition at line 44 of file validateAlignments.py.

int validateAlignments.ValidationJob.jobCount = 0
static

Definition at line 47 of file validateAlignments.py.

validateAlignments.ValidationJob.validation

Definition at line 86 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.getValidation().