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
 
 __scripts
 
 __valName
 
 __valType
 

Detailed Description

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

Definition at line 38 of file validateAlignments.py.

Constructor & Destructor Documentation

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

Definition at line 47 of file validateAlignments.py.

References split.

47 
48  def __init__( self, validation, config, options ):
49  if validation[1] == "":
50  # intermediate syntax
51  valString = validation[0].split( "->" )[0]
52  alignments = validation[0].split( "->" )[1]
53  # force user to use the normal syntax
54  if "->" in validation[0]:
55  msg = ("Instead of using the intermediate syntax\n'"
56  +valString.strip()+"-> "+alignments.strip()
57  +":'\nyou have to use the now fully supported syntax \n'"
58  +valString.strip()+": "
59  +alignments.strip()+"'.")
60  raise AllInOneError(msg)
61  else:
62  valString = validation[0]
63  alignments = validation[1]
64  valString = valString.split()
65  self.__valType = valString[0]
66  self.__valName = valString[1]
67  self.__commandLineOptions = options
68  self.__config = config
69  # workaround for intermediate parallel version
70  if self.__valType == "offlineParallel":
71  section = "offline" + ":" + self.__valName
72  else:
73  section = self.__valType + ":" + self.__valName
74  if not self.__config.has_section( section ):
75  raise AllInOneError, ("Validation '%s' of type '%s' is requested in"
76  " '[validation]' section, but is not defined."
77  "\nYou have to add a '[%s]' section."
78  %( self.__valName, self.__valType, section ))
79  self.validation = self.__getValidation( self.__valType, self.__valName,
80  alignments, self.__config,
81  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 145 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.createJob().

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

Definition at line 82 of file validateAlignments.py.

References validateAlignments.ValidationJob.__config, split, and strip().

82 
83  def __getValidation( self, valType, name, alignments, config, options ):
84  if valType == "compare":
85  alignmentsList = alignments.split( "," )
86  firstAlignList = alignmentsList[0].split()
87  firstAlignName = firstAlignList[0].strip()
88  if firstAlignName == "IDEAL":
89  raise AllInOneError, ("'IDEAL' has to be the second (reference)"
90  " alignment in 'compare <val_name>: "
91  "<alignment> <reference>'.")
92  if len( firstAlignList ) > 1:
93  firstRun = firstAlignList[1]
94  else:
95  firstRun = "1"
96  firstAlign = Alignment( firstAlignName, self.__config, firstRun )
97  secondAlignList = alignmentsList[1].split()
98  secondAlignName = secondAlignList[0].strip()
99  if len( secondAlignList ) > 1:
100  secondRun = secondAlignList[1]
101  else:
102  secondRun = "1"
103  if secondAlignName == "IDEAL":
104  secondAlign = secondAlignName
105  else:
106  secondAlign = Alignment( secondAlignName, self.__config,
107  secondRun )
108  # check if alignment was already compared previously
109  try:
110  randomWorkdirPart = \
111  globalDictionaries.alignRandDict[firstAlignName]
112  except KeyError:
113  randomWorkdirPart = None
114 
115  validation = GeometryComparison( name, firstAlign, secondAlign,
116  self.__config,
117  self.__commandLineOptions.getImages,
118  randomWorkdirPart )
119  globalDictionaries.alignRandDict[firstAlignName] = \
120  validation.randomWorkdirPart
121  if not secondAlignName == "IDEAL":
122  globalDictionaries.alignRandDict[secondAlignName] = \
123  validation.randomWorkdirPart
124  elif valType == "offline":
125  validation = OfflineValidation( name,
126  Alignment( alignments.strip(), self.__config ), self.__config )
127  elif valType == "offlineDQM":
128  validation = OfflineValidationDQM( name,
129  Alignment( alignments.strip(), self.__config ), self.__config )
130  elif valType == "offlineParallel":
131  validation = OfflineValidationParallel( 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 == "split":
137  validation = TrackSplittingValidation( name,
138  Alignment( alignments.strip(), self.__config ), self.__config )
139  elif valType == "zmumu":
140  validation = ZMuMuValidation( name,
141  Alignment( alignments.strip(), self.__config ), self.__config )
142  else:
143  raise AllInOneError, "Unknown validation mode '%s'"%valType
144  return validation
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
double split
Definition: MVATrainer.cc:139
def validateAlignments.ValidationJob.createJob (   self)
This is the method called to create the job files.

Definition at line 154 of file validateAlignments.py.

References validateAlignments.ValidationJob.__createJob().

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

Definition at line 217 of file validateAlignments.py.

References validateAlignments.ValidationJob.validation.

218  def getValidation( self ):
219  return self.validation
220 
def validateAlignments.ValidationJob.runJob (   self)

Definition at line 159 of file validateAlignments.py.

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

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

Member Data Documentation

validateAlignments.ValidationJob.__commandLineOptions
private

Definition at line 66 of file validateAlignments.py.

validateAlignments.ValidationJob.__config
private

Definition at line 67 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.__getValidation().

validateAlignments.ValidationJob.__scripts
private

Definition at line 149 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valName
private

Definition at line 65 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

validateAlignments.ValidationJob.__valType
private

Definition at line 64 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.runJob().

int validateAlignments.ValidationJob.batchCount = 0
static

Definition at line 43 of file validateAlignments.py.

list validateAlignments.ValidationJob.batchJobIds = []
static

Definition at line 44 of file validateAlignments.py.

int validateAlignments.ValidationJob.crabCount = 0
static

Definition at line 41 of file validateAlignments.py.

int validateAlignments.ValidationJob.interactCount = 0
static

Definition at line 42 of file validateAlignments.py.

int validateAlignments.ValidationJob.jobCount = 0
static

Definition at line 45 of file validateAlignments.py.

validateAlignments.ValidationJob.validation

Definition at line 78 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.getValidation().