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  print ("offlineParallel and offline are now the same. To run an offline parallel validation,\n"
72  "just set parallelJobs to something > 1. There is no reason to call it offlineParallel anymore.")
73  self.__valType = "offline"
74  section = self.__valType + ":" + self.__valName
75  if not self.__config.has_section( section ):
76  raise AllInOneError, ("Validation '%s' of type '%s' is requested in"
77  " '[validation]' section, but is not defined."
78  "\nYou have to add a '[%s]' section."
79  %( self.__valName, self.__valType, section ))
80  self.validation = self.__getValidation( self.__valType, self.__valName,
81  alignments, self.__config,
82  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 143 of file validateAlignments.py.

Referenced by validateAlignments.ValidationJob.createJob().

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

Definition at line 83 of file validateAlignments.py.

References validateAlignments.ValidationJob.__config, and split.

83 
84  def __getValidation( self, valType, name, alignments, config, options ):
85  if valType == "compare":
86  alignmentsList = alignments.split( "," )
87  firstAlignList = alignmentsList[0].split()
88  firstAlignName = firstAlignList[0].strip()
89  if firstAlignName == "IDEAL":
90  raise AllInOneError, ("'IDEAL' has to be the second (reference)"
91  " alignment in 'compare <val_name>: "
92  "<alignment> <reference>'.")
93  if len( firstAlignList ) > 1:
94  firstRun = firstAlignList[1]
95  else:
96  firstRun = "1"
97  firstAlign = Alignment( firstAlignName, self.__config, firstRun )
98  secondAlignList = alignmentsList[1].split()
99  secondAlignName = secondAlignList[0].strip()
100  if len( secondAlignList ) > 1:
101  secondRun = secondAlignList[1]
102  else:
103  secondRun = "1"
104  if secondAlignName == "IDEAL":
105  secondAlign = secondAlignName
106  else:
107  secondAlign = Alignment( secondAlignName, self.__config,
108  secondRun )
109  # check if alignment was already compared previously
110  try:
111  randomWorkdirPart = \
112  globalDictionaries.alignRandDict[firstAlignName]
113  except KeyError:
114  randomWorkdirPart = None
115 
116  validation = GeometryComparison( name, firstAlign, secondAlign,
117  self.__config,
118  self.__commandLineOptions.getImages,
119  randomWorkdirPart )
120  globalDictionaries.alignRandDict[firstAlignName] = \
121  validation.randomWorkdirPart
122  if not secondAlignName == "IDEAL":
123  globalDictionaries.alignRandDict[secondAlignName] = \
124  validation.randomWorkdirPart
125  elif valType == "offline":
126  validation = OfflineValidation( name,
127  Alignment( alignments.strip(), self.__config ), self.__config )
128  elif valType == "offlineDQM":
129  validation = OfflineValidationDQM( name,
130  Alignment( alignments.strip(), self.__config ), self.__config )
131  elif valType == "mcValidate":
132  validation = MonteCarloValidation( name,
133  Alignment( alignments.strip(), self.__config ), self.__config )
134  elif valType == "split":
135  validation = TrackSplittingValidation( name,
136  Alignment( alignments.strip(), self.__config ), self.__config )
137  elif valType == "zmumu":
138  validation = ZMuMuValidation( name,
139  Alignment( alignments.strip(), self.__config ), self.__config )
140  else:
141  raise AllInOneError, "Unknown validation mode '%s'"%valType
142  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 152 of file validateAlignments.py.

References validateAlignments.ValidationJob.__createJob().

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

Definition at line 215 of file validateAlignments.py.

References validateAlignments.ValidationJob.validation.

216  def getValidation( self ):
217  return self.validation
218 
def validateAlignments.ValidationJob.runJob (   self)

Definition at line 157 of file validateAlignments.py.

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

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

Referenced by validateAlignments.ValidationJob.getValidation().