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

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

Definition at line 94 of file validateAlignments.py.

References validateAlignments.ValidationJob.__config, and split.

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

References validateAlignments.ValidationJob.__createJob().

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

Definition at line 242 of file validateAlignments.py.

References validateAlignments.ValidationJob.validation.

243  def getValidation( self ):
244  return self.validation
245 
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(), and split.

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

Definition at line 73 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.__getValidation().

validateAlignments.ValidationJob.__preexisting
private

Definition at line 74 of file validateAlignments.py.

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

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().

int validateAlignments.ValidationJob.batchCount = 0
static

Definition at line 49 of file validateAlignments.py.

list validateAlignments.ValidationJob.batchJobIds = []
static

Definition at line 50 of file validateAlignments.py.

int validateAlignments.ValidationJob.crabCount = 0
static

Definition at line 47 of file validateAlignments.py.

int validateAlignments.ValidationJob.interactCount = 0
static

Definition at line 48 of file validateAlignments.py.

int validateAlignments.ValidationJob.jobCount = 0
static

Definition at line 51 of file validateAlignments.py.

validateAlignments.ValidationJob.validation

Definition at line 90 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.getValidation().