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

References validateAlignments.ValidationJob.__preexisting.

Referenced by validateAlignments.ValidationJob.createJob().

147  def __createJob( self, jobMode, outpath ):
148  """This private method creates the needed files for the validation job.
149  """
150  self.validation.createConfiguration( outpath )
151  if self.__preexisting:
152  return
153  self.__scripts = sum([addIndex(script, self.validation.NJobs) for script in self.validation.createScript( outpath )], [])
154  if jobMode.split( ',' )[0] == "crab":
155  self.validation.createCrabCfg( outpath )
156  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  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 157 of file validateAlignments.py.

References validateAlignments.ValidationJob.__createJob().

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

Definition at line 229 of file validateAlignments.py.

References validateAlignments.ValidationJob.validation.

230  def getValidation( self ):
231  return self.validation
232 
def validateAlignments.ValidationJob.runJob (   self)

Definition at line 162 of file validateAlignments.py.

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

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