CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes
DTWorkflow.DTWorkflow Class Reference
Inheritance diagram for DTWorkflow.DTWorkflow:
CLIHelper.CLIHelper CrabHelper.CrabHelper DTTtrigWorkflow.DTttrigWorkflow DTVdriftWorkflow.DTvdriftWorkflow

Public Member Functions

def __init__ (self, options)
 
def add_local_calib_db (self, local=False)
 
def add_local_custom_db (self)
 
def add_local_t0_db (self, local=False)
 
def add_local_vdrift_db (self, local=False)
 
def add_preselection (self)
 
def add_raw_option (self)
 
def all (self)
 
def check (self)
 
def check_missing_options (self, requirements_dict)
 
def correction (self)
 
def dump (self)
 
def dump_options (self)
 
def get_config_name (self, command="")
 
def get_output_files (self, crabtask, output_path)
 
def load_options (self, config_file_path)
 
def load_options_command (self, command)
 
def local_path (self)
 
def outpath_workflow_mode_tag (self)
 
def prepare_common_dump (self, db_path)
 
def prepare_common_submit (self)
 
def prepare_common_write (self, do_hadd=True)
 
def prepare_workflow (self)
 
def pset_path (self)
 
def pset_template_base_bath (self)
 
def remote_out_path (self)
 
def result_path (self)
 
def run (self)
 
def runCMSSWtask (self, pset_path="")
 
def submit (self)
 
def tag (self)
 
def user (self)
 
def write (self)
 
def write_pset_file (self)
 
- Public Member Functions inherited from CLIHelper.CLIHelper
def add_parser_options (cls, parser)
 
def fill_required_options_dict (self)
 
def fill_required_options_prepare_dict (self)
 
def get_check_options_parser (cls)
 
def get_common_options_parser (cls)
 
def get_dump_options_parser (cls)
 
def get_input_db_options_parser (cls)
 
def get_local_input_db_options_parser (cls)
 
def get_submission_options_parser (cls)
 
def get_write_options_parser (cls)
 
- Public Member Functions inherited from CrabHelper.CrabHelper
def __init__ (self)
 
def cert_info (self)
 
def check_crabtask (self)
 
def crab (self)
 
def crab_config_filename (self)
 
def crab_config_filepath (self)
 
def crab_taskname (self)
 
def create_crab_config (self)
 
def fill_options_from_crab_config (self)
 
def submit_crab_task (self)
 
def voms_proxy_create (self, passphrase=None)
 
def voms_proxy_time_left (self)
 
def write_crabConfig (self)
 

Static Public Member Functions

def addPoolDBESSource (process, moduleName, record, tag, connect='sqlite_file:', label='')
 

Public Attributes

 digilabel
 
 files_reveived
 
 input_files
 
 options
 
 outpath_command_tag
 
 output_files
 
 process
 
 pset_name
 
 required_options_dict
 
 required_options_prepare_dict
 
 run_all_command
 
- Public Attributes inherited from CrabHelper.CrabHelper
 crab_config
 
 crabFunctions
 

Private Attributes

 _user
 

Detailed Description

This is the base class for all DTWorkflows and contains some
    common tasks 

Definition at line 16 of file DTWorkflow.py.

Constructor & Destructor Documentation

def DTWorkflow.DTWorkflow.__init__ (   self,
  options 
)

Definition at line 19 of file DTWorkflow.py.

19  def __init__(self, options):
20  self.options = options
21  super( DTWorkflow, self ).__init__()
22  self.digilabel = "muonDTDigis"
23  # dict to hold required variables. Can not be marked in argparse to allow
24  # loading of options from config
29  # These variables are determined in the derived classes
30  self.pset_name = ""
32  self.output_files = []
33  self.input_files = []
34 
35  self.run_all_command = False
36  self.files_reveived = False
37  self._user = ""
38  # change to working directory
39  os.chdir(self.options.working_dir)
40 
def fill_required_options_dict(self)
Definition: CLIHelper.py:39
def __init__(self, options)
Definition: DTWorkflow.py:19
def fill_required_options_prepare_dict(self)
Definition: CLIHelper.py:35

Member Function Documentation

def DTWorkflow.DTWorkflow.add_local_calib_db (   self,
  local = False 
)
Add a local calib database as input. Use the option local is used
    if the pset is processed locally and not with crab.

Definition at line 161 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.addPoolDBESSource(), DTVdriftWorkflow.DTvdriftWorkflow.process, DTTtrigWorkflow.DTttrigWorkflow.process, DTWorkflow.DTWorkflow.process, and harvestTrackValidationPlots.str.

Referenced by DTTtrigWorkflow.DTttrigWorkflow.prepare_residuals_correction(), DTTtrigWorkflow.DTttrigWorkflow.prepare_residuals_submit(), DTTtrigWorkflow.DTttrigWorkflow.prepare_timeboxes_correction(), and DTTtrigWorkflow.DTttrigWorkflow.prepare_validation_submit().

161  def add_local_calib_db(self, local=False):
162  """ Add a local calib database as input. Use the option local is used
163  if the pset is processed locally and not with crab.
164  """
165  label = ''
166  if self.options.datasettype == "Cosmics":
167  label = 'cosmics'
168  if local:
169  connect = os.path.abspath(self.options.inputCalibDB)
170  else:
171  connect = os.path.basename(self.options.inputCalibDB)
172  self.addPoolDBESSource( process = self.process,
173  moduleName = 'calibDB',
174  record = 'DTTtrigRcd',
175  tag = 'ttrig',
176  connect = str("sqlite_file:%s" % connect),
177  label = label
178  )
179  self.input_files.append( os.path.abspath(self.options.inputCalibDB) )
180 
def addPoolDBESSource(process, moduleName, record, tag, connect='sqlite_file:', label='')
Definition: DTWorkflow.py:246
def add_local_calib_db(self, local=False)
Definition: DTWorkflow.py:161
def DTWorkflow.DTWorkflow.add_local_custom_db (   self)

Definition at line 181 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.addPoolDBESSource(), DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, DTVdriftWorkflow.DTvdriftWorkflow.process, DTTtrigWorkflow.DTttrigWorkflow.process, and DTWorkflow.DTWorkflow.process.

Referenced by DTWorkflow.DTWorkflow.prepare_common_submit(), and DTTtrigWorkflow.DTttrigWorkflow.prepare_residuals_correction().

182  for option in ('inputDBRcd', 'connectStrDBTag'):
183  if hasattr(self.options, option) and not getattr(self.options, option):
184  raise ValueError("Option %s needed for custom input db" % option)
185  self.addPoolDBESSource( process = self.process,
186  record = self.options.inputDBRcd,
187  tag = self.options.inputDBTag,
188  connect = self.options.connectStrDBTag,
189  moduleName = 'customDB%s' % self.options.inputDBRcd
190  )
191 
def addPoolDBESSource(process, moduleName, record, tag, connect='sqlite_file:', label='')
Definition: DTWorkflow.py:246
def add_local_custom_db(self)
Definition: DTWorkflow.py:181
def DTWorkflow.DTWorkflow.add_local_t0_db (   self,
  local = False 
)
Add a local t0 database as input. Use the option local is used
    if the pset is processed locally and not with crab.

Definition at line 131 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.addPoolDBESSource(), DTVdriftWorkflow.DTvdriftWorkflow.process, DTTtrigWorkflow.DTttrigWorkflow.process, and DTWorkflow.DTWorkflow.process.

Referenced by DTWorkflow.DTWorkflow.prepare_common_submit().

131  def add_local_t0_db(self, local=False):
132  """ Add a local t0 database as input. Use the option local is used
133  if the pset is processed locally and not with crab.
134  """
135  if local:
136  connect = os.path.abspath(self.options.inputT0DB)
137  else:
138  connect = os.path.basename(self.options.inputT0DB)
139  self.addPoolDBESSource( process = self.process,
140  moduleName = 't0DB',
141  record = 'DTT0Rcd',
142  tag = 't0',
143  connect = 'sqlite_file:%s' % connect)
144  self.input_files.append(os.path.abspath(self.options.inputT0DB))
145 
def addPoolDBESSource(process, moduleName, record, tag, connect='sqlite_file:', label='')
Definition: DTWorkflow.py:246
def add_local_t0_db(self, local=False)
Definition: DTWorkflow.py:131
def DTWorkflow.DTWorkflow.add_local_vdrift_db (   self,
  local = False 
)
Add a local vdrift database as input. Use the option local is used
    if the pset is processed locally and not with crab.

Definition at line 146 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.addPoolDBESSource(), DTVdriftWorkflow.DTvdriftWorkflow.process, DTTtrigWorkflow.DTttrigWorkflow.process, and DTWorkflow.DTWorkflow.process.

Referenced by DTWorkflow.DTWorkflow.prepare_common_submit(), DTTtrigWorkflow.DTttrigWorkflow.prepare_residuals_correction(), and DTVdriftWorkflow.DTvdriftWorkflow.prepare_segment_write().

146  def add_local_vdrift_db(self, local=False):
147  """ Add a local vdrift database as input. Use the option local is used
148  if the pset is processed locally and not with crab.
149  """
150  if local:
151  connect = os.path.abspath(self.options.inputVDriftDB)
152  else:
153  connect = os.path.basename(self.options.inputVDriftDB)
154  self.addPoolDBESSource( process = self.process,
155  moduleName = 'vDriftDB',
156  record = 'DTMtimeRcd',
157  tag = 'vDrift',
158  connect = 'sqlite_file:%s' % connect)
159  self.input_files.append( os.path.abspath(self.options.inputVDriftDB) )
160 
def add_local_vdrift_db(self, local=False)
Definition: DTWorkflow.py:146
def addPoolDBESSource(process, moduleName, record, tag, connect='sqlite_file:', label='')
Definition: DTWorkflow.py:246
def DTWorkflow.DTWorkflow.add_preselection (   self)
Add preselection to the process object stored in workflow_object

Definition at line 118 of file DTWorkflow.py.

References tools.prependPaths(), DTVdriftWorkflow.DTvdriftWorkflow.process, DTTtrigWorkflow.DTttrigWorkflow.process, and DTWorkflow.DTWorkflow.process.

Referenced by DTWorkflow.DTWorkflow.prepare_common_submit().

118  def add_preselection(self):
119  """ Add preselection to the process object stored in workflow_object"""
120  if not hasattr(self, "process"):
121  raise NameError("Process is not initalized in workflow object")
122  pathsequence = self.options.preselection.split(':')[0]
123  seqname = self.options.preselection.split(':')[1]
124  self.process.load(pathsequence)
125  tools.prependPaths(self.process, seqname)
126 
def prependPaths(process, seqname)
Definition: tools.py:65
def add_preselection(self)
Definition: DTWorkflow.py:118
def DTWorkflow.DTWorkflow.add_raw_option (   self)
def DTWorkflow.DTWorkflow.addPoolDBESSource (   process,
  moduleName,
  record,
  tag,
  connect = 'sqlite_file:',
  label = '' 
)
static

Definition at line 246 of file DTWorkflow.py.

References harvestTrackValidationPlots.str.

Referenced by DTWorkflow.DTWorkflow.add_local_calib_db(), DTWorkflow.DTWorkflow.add_local_custom_db(), DTWorkflow.DTWorkflow.add_local_t0_db(), and DTWorkflow.DTWorkflow.add_local_vdrift_db().

246  label='',):
247 
248  from CondCore.CondDB.CondDB_cfi import CondDB
249 
250  calibDB = cms.ESSource("PoolDBESSource",
251  CondDB,
252  timetype = cms.string('runnumber'),
253  toGet = cms.VPSet(cms.PSet(
254  record = cms.string(record),
255  tag = cms.string(tag),
256  label = cms.untracked.string(label)
257  )),
258  )
259  calibDB.connect = cms.string( str(connect) )
260  #if authPath: calibDB.DBParameters.authenticationPath = authPath
261  if 'oracle:' in connect:
262  calibDB.DBParameters.authenticationPath = '/afs/cern.ch/cms/DB/conddb'
263  setattr(process,moduleName,calibDB)
264  setattr(process,"es_prefer_" + moduleName,cms.ESPrefer('PoolDBESSource',
265  moduleName)
266  )
267 
def DTWorkflow.DTWorkflow.all (   self)
generalized function to perform several workflow mode commands in chain.
    All commands mus be specified in self.all_commands list in workflow mode specific
    prepare function in child workflow objects.

Definition at line 92 of file DTWorkflow.py.

References DTVdriftWorkflow.DTvdriftWorkflow.all_commands, DTTtrigWorkflow.DTttrigWorkflow.all_commands, splitter.FileObj.run, uploader.FileObj.run, uploadPayloads.FileObj.run, RPCRunIOV::RunIOV_Item.run, beamspot::BeamSpotContainer.run, TB06Reco.run, TB06RecoH2.run, RPCDQMObject.run, MultiEventFilter::Event.run, DTCalibrationWorker.DTCalibrationWorker.run(), L1Analysis::L1AnalysisEventDataFormat.run, TrackInfoProducerAlgorithm.run(), generateEDF.LumiInfo.run, lumi::Lumi2DB::LumiSource.run, MuonMillepedeAlgorithm.run(), SurveyAlignmentAlgorithm.run(), SeedGeneratorForLaserBeams.run(), EfficiencyPlotter.run, WZInterestingEventSelector::event.run, LaserHitPairGenerator.run(), crabWrapper.CrabWrapper.run(), MuonDTLocalMillepedeAlgorithm.run(), HIPAlignmentAlgorithm.run(), DTWorkflow.DTWorkflow.run(), MuonRecoTest.run, options.ConnectionHLTMenu.run, DTResolutionAnalysisTest.run, BeamSpotRcdReader::theBSfromDB.run, MatacqProducer::MatacqEventId.run, CSCOverlapsAlignmentAlgorithm.run(), DTDataIntegrityTest.run, DTBlockedROChannelsTest.run, DTChamberEfficiencyTest.run, DTResolutionTest.run, ApeSettingAlgorithm.run(), ME::Header.run, ConstantStepOdeSolver.run(), DTEfficiencyTest.run, MillePedeAlignmentAlgorithm.run(), MuonAlignmentFromReference.run(), personalPlayback.Playback.run, HitEff.run, DQMNet::CoreObject.run, MatrixUtil.InputInfo.run, DTLocalTriggerBaseTest.run, EcalDeadCellDeltaRFilter.run, QIE8Simulator.run(), AlignmentAlgorithmBase.run(), cond::RunInfo_t.run, SiPixelErrorEstimation.run, personalPlayback.FrameworkJob.run, SiPixelTrackingRecHitsValid.run, dqm_interfaces.DirWalkerFile.run, JsonOutputProducer::JsonEvent.run, SummaryOutputProducer.run, SummaryOutputProducer::Event.run, and DTWorkflow.DTWorkflow.run_all_command.

92  def all(self):
93  """ generalized function to perform several workflow mode commands in chain.
94  All commands mus be specified in self.all_commands list in workflow mode specific
95  prepare function in child workflow objects.
96  """
97  self.run_all_command = True
98  for command in self.all_commands:
99  self.options.command = command
100  self.run()
101 
def DTWorkflow.DTWorkflow.check (   self)
Function to check status of submitted tasks 

Definition at line 105 of file DTWorkflow.py.

References CrabHelper.CrabHelper.check_crabtask().

105  def check(self):
106  """ Function to check status of submitted tasks """
107  self.check_crabtask()
108 
def check_crabtask(self)
Definition: CrabHelper.py:44
def DTWorkflow.DTWorkflow.check_missing_options (   self,
  requirements_dict 
)

Definition at line 41 of file DTWorkflow.py.

References join(), DTCalibrationWorker.DTCalibrationWorker.options, and DTWorkflow.DTWorkflow.options.

Referenced by DTWorkflow.DTWorkflow.run().

41  def check_missing_options(self, requirements_dict):
42  missing_options = []
43  # check if all required options exist
44  if self.options.command in requirements_dict:
45  for option in requirements_dict[self.options.command]:
46  if not (hasattr(self.options, option)
47  and ( (getattr(self.options,option))
48  or type(getattr(self.options,option)) == bool )):
49  missing_options.append(option)
50  if len(missing_options) > 0:
51  err = "The following CLI options are missing"
52  err += " for command %s: " % self.options.command
53  err += " ".join(missing_options)
54  raise ValueError(err)
55 
def check_missing_options(self, requirements_dict)
Definition: DTWorkflow.py:41
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def DTWorkflow.DTWorkflow.correction (   self)

Definition at line 115 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.runCMSSWtask().

115  def correction(self):
116  self.runCMSSWtask()
117 
def runCMSSWtask(self, pset_path="")
Definition: DTWorkflow.py:274
def DTWorkflow.DTWorkflow.dump (   self)

Definition at line 112 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.runCMSSWtask().

112  def dump(self):
113  self.runCMSSWtask()
114 
def runCMSSWtask(self, pset_path="")
Definition: DTWorkflow.py:274
def DTWorkflow.DTWorkflow.dump_options (   self)

Definition at line 389 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.get_config_name(), DTWorkflow.DTWorkflow.local_path(), DTCalibrationWorker.DTCalibrationWorker.options, and DTWorkflow.DTWorkflow.options.

Referenced by DTWorkflow.DTWorkflow.run().

389  def dump_options(self):
390  with open(os.path.join(self.local_path, self.get_config_name()),"w") as out_file:
391  json.dump(vars(self.options), out_file, indent=4)
392 
def get_config_name(self, command="")
Definition: DTWorkflow.py:383
def dump_options(self)
Definition: DTWorkflow.py:389
def DTWorkflow.DTWorkflow.get_config_name (   self,
  command = "" 
)
Create the name for the output json file which will be dumped

Definition at line 383 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.dump_options(), and DTWorkflow.DTWorkflow.load_options_command().

383  def get_config_name(self, command= ""):
384  """ Create the name for the output json file which will be dumped"""
385  if not command:
386  command = self.options.command
387  return "config_" + command + ".json"
388 
def get_config_name(self, command="")
Definition: DTWorkflow.py:383
def DTWorkflow.DTWorkflow.get_output_files (   self,
  crabtask,
  output_path 
)

Definition at line 268 of file DTWorkflow.py.

Referenced by CrabHelper.CrabHelper.check_crabtask(), and DTWorkflow.DTWorkflow.prepare_common_write().

268  def get_output_files(self, crabtask, output_path):
269  self.crab.callCrabCommand( ["getoutput",
270  "--outputpath",
271  output_path,
272  crabtask.crabFolder ] )
273 
def get_output_files(self, crabtask, output_path)
Definition: DTWorkflow.py:268
def DTWorkflow.DTWorkflow.load_options (   self,
  config_file_path 
)

Definition at line 393 of file DTWorkflow.py.

References DTCalibrationWorker.DTCalibrationWorker.options, and DTWorkflow.DTWorkflow.options.

Referenced by DTWorkflow.DTWorkflow.load_options_command(), and DTWorkflow.DTWorkflow.run().

393  def load_options(self, config_file_path):
394  if not os.path.exists(config_file_path):
395  raise IOError("File %s not found" % config_file_path)
396  with open(config_file_path, "r") as input_file:
397  config_json = json.load(input_file)
398  for key, val in config_json.items():
399  if not hasattr(self.options, key) or not getattr(self.options, key):
400  setattr(self.options, key, val)
401 
def load_options(self, config_file_path)
Definition: DTWorkflow.py:393
def DTWorkflow.DTWorkflow.load_options_command (   self,
  command 
)
Load options for previous command in workflow 

Definition at line 402 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.get_config_name(), DTWorkflow.DTWorkflow.load_options(), and DTWorkflow.DTWorkflow.local_path().

Referenced by DTWorkflow.DTWorkflow.prepare_common_write(), DTTtrigWorkflow.DTttrigWorkflow.prepare_residuals_check(), DTTtrigWorkflow.DTttrigWorkflow.prepare_residuals_correction(), DTTtrigWorkflow.DTttrigWorkflow.prepare_residuals_dump(), DTVdriftWorkflow.DTvdriftWorkflow.prepare_segment_check(), DTVdriftWorkflow.DTvdriftWorkflow.prepare_segment_dump(), DTTtrigWorkflow.DTttrigWorkflow.prepare_timeboxes_check(), DTTtrigWorkflow.DTttrigWorkflow.prepare_timeboxes_correction(), DTTtrigWorkflow.DTttrigWorkflow.prepare_timeboxes_dump(), and DTTtrigWorkflow.DTttrigWorkflow.prepare_validation_check().

402  def load_options_command(self, command ):
403  """Load options for previous command in workflow """
404  if not self.options.config_path:
405  if not self.options.run:
406  raise RuntimeError("Option run is required if no config path specified")
407  if not os.path.exists(self.local_path):
408  raise IOError("Local path %s does not exist" % self.local_path)
409  self.options.config_path = os.path.join(self.local_path,
410  self.get_config_name(command))
411  self.load_options( self.options.config_path )
412 
413 
def get_config_name(self, command="")
Definition: DTWorkflow.py:383
def load_options_command(self, command)
Definition: DTWorkflow.py:402
def load_options(self, config_file_path)
Definition: DTWorkflow.py:393
def DTWorkflow.DTWorkflow.local_path (   self)
Output path on local machine 

Definition at line 332 of file DTWorkflow.py.

References DTVdriftWorkflow.DTvdriftWorkflow.outpath_command_tag, DTTtrigWorkflow.DTttrigWorkflow.outpath_command_tag, DTWorkflow.DTWorkflow.outpath_command_tag, and DTWorkflow.DTWorkflow.outpath_workflow_mode_tag().

Referenced by CrabHelper.CrabHelper.check_crabtask(), CrabHelper.CrabHelper.crab_config_filepath(), DTWorkflow.DTWorkflow.dump_options(), DTWorkflow.DTWorkflow.load_options_command(), DTWorkflow.DTWorkflow.prepare_common_write(), DTTtrigWorkflow.DTttrigWorkflow.prepare_validation_write(), DTWorkflow.DTWorkflow.pset_path(), DTWorkflow.DTWorkflow.result_path(), DTWorkflow.DTWorkflow.run(), CrabHelper.CrabHelper.write_crabConfig(), and DTWorkflow.DTWorkflow.write_pset_file().

332  def local_path(self):
333  """ Output path on local machine """
334  if self.options.run and self.options.label:
335  prefix = "Run%d-%s_v%d" % ( self.options.run,
336  self.options.label,
337  self.options.trial)
338  else:
339  prefix = ""
341  path = os.path.join( self.options.working_dir,
342  prefix,
344  else:
345  path = os.path.join( self.options.working_dir,
346  prefix,
347  self.outpath_command_tag )
348  return path
349 
def outpath_workflow_mode_tag(self)
Definition: DTWorkflow.py:312
def DTWorkflow.DTWorkflow.outpath_workflow_mode_tag (   self)

Definition at line 312 of file DTWorkflow.py.

References DTVdriftWorkflow.DTvdriftWorkflow.outpath_workflow_mode_dict, and DTTtrigWorkflow.DTttrigWorkflow.outpath_workflow_mode_dict.

Referenced by DTWorkflow.DTWorkflow.local_path(), and DTWorkflow.DTWorkflow.remote_out_path().

313  if not self.options.workflow_mode in self.outpath_workflow_mode_dict:
314  raise NotImplementedError("%s missing in outpath_workflow_mode_dict" % self.options.workflow_mode)
315  return self.outpath_workflow_mode_dict[self.options.workflow_mode]
316 
def outpath_workflow_mode_tag(self)
Definition: DTWorkflow.py:312
def DTWorkflow.DTWorkflow.prepare_common_dump (   self,
  db_path 
)

Definition at line 227 of file DTWorkflow.py.

Referenced by DTTtrigWorkflow.DTttrigWorkflow.prepare_residuals_dump(), DTVdriftWorkflow.DTvdriftWorkflow.prepare_segment_dump(), and DTTtrigWorkflow.DTttrigWorkflow.prepare_timeboxes_dump().

227  def prepare_common_dump(self, db_path):
228  self.process = tools.loadCmsProcess(self.pset_template)
229  self.process.calibDB.connect = 'sqlite_file:%s' % db_path
230  try:
231  path = self.result_path
232  except:
233  path = os.getcwd()
234  print "path", path
235  out_path = os.path.abspath(os.path.join(path,
236  os.path.splitext(db_path)[0] + ".txt"))
237 
238  self.process.dumpToFile.outputFileName = out_path
239 
def loadCmsProcess(psetPath)
Definition: tools.py:55
def prepare_common_dump(self, db_path)
Definition: DTWorkflow.py:227
def DTWorkflow.DTWorkflow.prepare_common_submit (   self)
Common operations used in most prepare_[workflow_mode]_submit functions

Definition at line 192 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.add_local_custom_db(), DTWorkflow.DTWorkflow.add_local_t0_db(), DTWorkflow.DTWorkflow.add_local_vdrift_db(), DTWorkflow.DTWorkflow.add_preselection(), DTWorkflow.DTWorkflow.add_raw_option(), DTCalibrationWorker.DTCalibrationWorker.options, and DTWorkflow.DTWorkflow.options.

Referenced by DTTtrigWorkflow.DTttrigWorkflow.prepare_residuals_submit(), and DTTtrigWorkflow.DTttrigWorkflow.prepare_validation_submit().

193  """ Common operations used in most prepare_[workflow_mode]_submit functions"""
194  if not self.options.run:
195  raise ValueError("Option run is required for submission!")
196  if hasattr(self.options, "inputT0DB") and self.options.inputT0DB:
197  self.add_local_t0_db()
198 
199  if hasattr(self.options, "inputVDriftDB") and self.options.inputVDriftDB:
200  self.add_local_vdrift_db()
201 
202  if hasattr(self.options, "inputDBTag") and self.options.inputDBTag:
203  self.add_local_custom_db()
204 
205  if self.options.run_on_RAW:
206  self.add_raw_option()
207  if self.options.preselection:
208  self.add_preselection()
209 
def add_local_vdrift_db(self, local=False)
Definition: DTWorkflow.py:146
def add_local_t0_db(self, local=False)
Definition: DTWorkflow.py:131
def add_raw_option(self)
Definition: DTWorkflow.py:127
def prepare_common_submit(self)
Definition: DTWorkflow.py:192
def add_preselection(self)
Definition: DTWorkflow.py:118
def add_local_custom_db(self)
Definition: DTWorkflow.py:181
def DTWorkflow.DTWorkflow.prepare_common_write (   self,
  do_hadd = True 
)
Common operations used in most prepare_[workflow_mode]_erite functions

Definition at line 210 of file DTWorkflow.py.

References CrabHelper.CrabHelper.crab_config_filepath(), DTWorkflow.DTWorkflow.files_reveived, DTWorkflow.DTWorkflow.get_output_files(), tools.haddLocal(), DTWorkflow.DTWorkflow.load_options_command(), DTWorkflow.DTWorkflow.local_path(), DTVdriftWorkflow.DTvdriftWorkflow.output_file, DTTtrigWorkflow.DTttrigWorkflow.output_file, HltDiff.output_file, and DTWorkflow.DTWorkflow.result_path().

Referenced by DTTtrigWorkflow.DTttrigWorkflow.prepare_residuals_correction(), DTVdriftWorkflow.DTvdriftWorkflow.prepare_segment_write(), and DTTtrigWorkflow.DTttrigWorkflow.prepare_validation_write().

210  def prepare_common_write(self, do_hadd=True):
211  """ Common operations used in most prepare_[workflow_mode]_erite functions"""
212  self.load_options_command("submit")
213  output_path = os.path.join( self.local_path, "unmerged_results" )
214  merged_file = os.path.join(self.result_path, self.output_file)
215  crabtask = self.crabFunctions.CrabTask(crab_config = self.crab_config_filepath,
216  initUpdate = False)
217  if not (self.options.skip_stageout or self.files_reveived or self.options.no_exec):
218  self.get_output_files(crabtask, output_path)
219  log.info("Received files from storage element")
220  log.info("Using hadd to merge output files")
221  if not self.options.no_exec and do_hadd:
222  returncode = tools.haddLocal(output_path, merged_file)
223  if returncode != 0:
224  raise RuntimeError("Failed to merge files with hadd")
225  return crabtask.crabConfig.Data.outputDatasetTag
226 
def load_options_command(self, command)
Definition: DTWorkflow.py:402
def prepare_common_write(self, do_hadd=True)
Definition: DTWorkflow.py:210
def haddLocal(localdir, result_file, extension='root')
Definition: tools.py:40
def get_output_files(self, crabtask, output_path)
Definition: DTWorkflow.py:268
def crab_config_filepath(self)
Definition: CrabHelper.py:224
def DTWorkflow.DTWorkflow.prepare_workflow (   self)
Abstract implementation of prepare workflow function

Definition at line 86 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.run().

86  def prepare_workflow(self):
87  """ Abstract implementation of prepare workflow function"""
88  errmsg = "Class `{}` does not implement `{}`"
89  raise NotImplementedError( errmsg.format(self.__class__.__name__,
90  "prepare_workflow"))
91 
def prepare_workflow(self)
Definition: DTWorkflow.py:86
def DTWorkflow.DTWorkflow.pset_path (   self)
full path to the pset file 

Definition at line 368 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.local_path(), DTWorkflow.DTWorkflow.pset_name, DTVdriftWorkflow.DTvdriftWorkflow.pset_name, and DTTtrigWorkflow.DTttrigWorkflow.pset_name.

Referenced by DTWorkflow.DTWorkflow.runCMSSWtask(), and DTWorkflow.DTWorkflow.write_pset_file().

368  def pset_path(self):
369  """ full path to the pset file """
370  basepath = os.path.join( self.local_path, "psets")
371  if not os.path.exists( basepath ):
372  os.makedirs( basepath )
373  return os.path.join( basepath, self.pset_name )
374 
def DTWorkflow.DTWorkflow.pset_template_base_bath (   self)
Base path to folder containing pset files for cmsRun

Definition at line 358 of file DTWorkflow.py.

359  """ Base path to folder containing pset files for cmsRun"""
360  return os.path.expandvars(os.path.join("$CMSSW_BASE",
361  "src",
362  "CalibMuon",
363  "test",
364  )
365  )
366 
def pset_template_base_bath(self)
Definition: DTWorkflow.py:358
def DTWorkflow.DTWorkflow.remote_out_path (   self)
Output path on remote excluding user base path
Returns a dict if crab is used due to crab path setting policy

Definition at line 290 of file DTWorkflow.py.

References DTVdriftWorkflow.DTvdriftWorkflow.outpath_command_tag, DTTtrigWorkflow.DTttrigWorkflow.outpath_command_tag, DTWorkflow.DTWorkflow.outpath_command_tag, DTWorkflow.DTWorkflow.outpath_workflow_mode_tag(), harvestTrackValidationPlots.str, tnp::TagProbePair.tag, cond::persistency::IOVProxyData.tag, cond::persistency::IOVEditorData.tag, MeasurementEstimator::OpaquePayload.tag, Inspector.Inspector.tag, BeamSpotFakeConditions.tag, Entry< T >.tag, MCPdgIndexFilter.tag, TrackListMerger::TkEDGetTokenss.tag, cond::Tag_t.tag, MuIsolatorResultProducer< BT >::DepositConf.tag, DQMNet::CoreObject.tag, personalPlayback.FrameworkJob.tag, DTWorkflow.DTWorkflow.tag(), dataset.BaseDataset.user, EcalTPGParamReaderFromDB.user, production_tasks.Task.user, popcon::RpcDataT.user, popcon::RPCObPVSSmapData.user, popcon::RpcDataV.user, popcon::RpcObGasData.user, popcon::RpcDataUXC.user, popcon::RpcDataI.user, popcon::RpcDataFebmap.user, popcon::RpcDataGasMix.user, popcon::RpcDataS.user, MatrixInjector.MatrixInjector.user, cmsPerfSuite.PerfSuite.user, production_tasks.ParseOptions.user, EcalDBConnection.user, production_tasks.FindOnCastor.user, production_tasks.CheckForMask.user, production_tasks.CheckForWrite.user, and DTWorkflow.DTWorkflow.user().

290  def remote_out_path(self):
291  """ Output path on remote excluding user base path
292  Returns a dict if crab is used due to crab path setting policy"""
293  if self.options.command =="submit":
294  return {
295  "outLFNDirBase" : os.path.join( "/store",
296  "user",
297  self.user,
298  'DTCalibration/',
299  self.outpath_command_tag,
301  "outputDatasetTag" : self.tag
302  }
303  else:
304  return os.path.join( 'DTCalibration/',
305  datasetstr,
306  'Run' + str(self.options.run),
307  self.outpath_command_tag,
309  'v' + str(self.options.trial),
310  )
def remote_out_path(self)
Definition: DTWorkflow.py:290
def outpath_workflow_mode_tag(self)
Definition: DTWorkflow.py:312
def DTWorkflow.DTWorkflow.run (   self)
Generalized function to run workflow command

Definition at line 56 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.check_missing_options(), DTWorkflow.DTWorkflow.dump_options(), DTWorkflow.DTWorkflow.load_options(), DTWorkflow.DTWorkflow.local_path(), DTCalibrationWorker.DTCalibrationWorker.options, DTWorkflow.DTWorkflow.options, DTVdriftWorkflow.DTvdriftWorkflow.prepare_workflow(), DTTtrigWorkflow.DTttrigWorkflow.prepare_workflow(), DTWorkflow.DTWorkflow.prepare_workflow(), DTWorkflow.DTWorkflow.required_options_dict, and DTWorkflow.DTWorkflow.required_options_prepare_dict.

Referenced by DTWorkflow.DTWorkflow.all(), Types.EventID.cppID(), Types.LuminosityBlockID.cppID(), and o2olib.O2OTool.execute().

56  def run(self):
57  """ Generalized function to run workflow command"""
58  msg = "Preparing %s workflow" % self.options.workflow
59  if hasattr(self.options, "command"):
60  msg += " for command %s" % self.options.command
61  log.info(msg)
62  if self.options.config_path:
63  self.load_options( self.options.config_path )
64  #check if all options to prepare the command are used
66  self.prepare_workflow()
67  # create output folder if they do not exist yet
68  if not os.path.exists( self.local_path ):
69  os.makedirs(self.local_path)
70  # dump used options
71  self.dump_options()
72  #check if all options to run the command are used
74  try:
75  run_function = getattr(self, self.options.command)
76  except AttributeError:
77  errmsg = "Class `{}` does not implement `{}` for workflow %s" % self.options.workflow
78  if hasattr(self.options, "workflow_mode"):
79  errmsg += "and workflow mode %s" % self.options.workflow_mode
80  raise NotImplementedError( errmsg.format(self.__class__.__name__,
81  self.options.command))
82  log.debug("Running command %s" % self.options.command)
83  # call chosen function
84  run_function()
85 
def check_missing_options(self, requirements_dict)
Definition: DTWorkflow.py:41
def load_options(self, config_file_path)
Definition: DTWorkflow.py:393
def dump_options(self)
Definition: DTWorkflow.py:389
def prepare_workflow(self)
Definition: DTWorkflow.py:86
def DTWorkflow.DTWorkflow.runCMSSWtask (   self,
  pset_path = "" 
)
Run a cmsRun job locally. The member variable self.pset_path is used
    if pset_path argument is not given

Definition at line 274 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.pset_name, DTVdriftWorkflow.DTvdriftWorkflow.pset_name, DTTtrigWorkflow.DTttrigWorkflow.pset_name, and DTWorkflow.DTWorkflow.pset_path().

Referenced by DTWorkflow.DTWorkflow.correction(), DTWorkflow.DTWorkflow.dump(), and DTWorkflow.DTWorkflow.write().

274  def runCMSSWtask(self, pset_path=""):
275  """ Run a cmsRun job locally. The member variable self.pset_path is used
276  if pset_path argument is not given"""
277  if self.options.no_exec:
278  return 0
279  process = subprocess.Popen( "cmsRun %s" % self.pset_path,
280  stdout=subprocess.PIPE,
281  stderr=subprocess.STDOUT,
282  shell = True)
283  stdout = process.communicate()[0]
284  log.info(stdout)
285  if process.returncode != 0:
286  raise RuntimeError("Failed to use cmsRun for pset %s" % self.pset_name)
287  return process.returncode
288 
def runCMSSWtask(self, pset_path="")
Definition: DTWorkflow.py:274
def DTWorkflow.DTWorkflow.submit (   self)

Definition at line 102 of file DTWorkflow.py.

References CrabHelper.CrabHelper.submit_crab_task().

102  def submit(self):
103  self.submit_crab_task()
104 
def submit_crab_task(self)
Definition: CrabHelper.py:20
def DTWorkflow.DTWorkflow.tag (   self)

Definition at line 318 of file DTWorkflow.py.

References harvestTrackValidationPlots.str.

Referenced by DTTtrigWorkflow.DTttrigWorkflow.prepare_timeboxes_correction(), and DTWorkflow.DTWorkflow.remote_out_path().

318  def tag(self):
319  return 'Run' + str(self.options.run) + '_v' + str(self.options.trial)
320 
def DTWorkflow.DTWorkflow.user (   self)

Definition at line 322 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow._user, DTCalibrationWorker.DTCalibrationWorker.options, and DTWorkflow.DTWorkflow.options.

Referenced by DTWorkflow.DTWorkflow.remote_out_path().

322  def user(self):
323  if self._user:
324  return self._user
325  if hasattr(self.options, "user") and self.options.user:
326  self._user = self.options.user
327  else:
328  self._user = self.crab.checkusername()
329  return self._user
330 
def DTWorkflow.DTWorkflow.write (   self)

Definition at line 109 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.runCMSSWtask().

Referenced by pkg.AbstractPkg.generate(), and querying.connection.write_and_commit().

109  def write(self):
110  self.runCMSSWtask()
111 
def runCMSSWtask(self, pset_path="")
Definition: DTWorkflow.py:274

Member Data Documentation

DTWorkflow.DTWorkflow._user
private

Definition at line 37 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.user().

DTWorkflow.DTWorkflow.digilabel

Definition at line 22 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.add_raw_option().

DTWorkflow.DTWorkflow.files_reveived

Definition at line 36 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.prepare_common_write().

DTWorkflow.DTWorkflow.input_files

Definition at line 33 of file DTWorkflow.py.

DTWorkflow.DTWorkflow.options

Definition at line 20 of file DTWorkflow.py.

Referenced by DOTExport.DotProducer.__call__(), betterConfigParser.BetterConfigParser.__updateDict(), DTWorkflow.DTWorkflow.add_local_custom_db(), confdb.HLTProcess.buildOptions(), DTWorkflow.DTWorkflow.check_missing_options(), betterConfigParser.BetterConfigParser.checkInput(), DOTExport.DotProducer.connectTags(), CrabHelper.CrabHelper.crab_config_filename(), CrabHelper.CrabHelper.crab_taskname(), DTWorkflow.DTWorkflow.dump_options(), DOTExport.DotExport.export(), CrabHelper.CrabHelper.fill_options_from_crab_config(), confdb.HLTProcess.fixPrescales(), DOTExport.DotProducer.getTopLevel(), DTWorkflow.DTWorkflow.load_options(), DOTExport.DotProducer.makePath(), DOTExport.DotProducer.nodeLabel(), DOTExport.DotProducer.nodeURL(), DTWorkflow.DTWorkflow.prepare_common_submit(), DOTExport.DotProducer.produceLegend(), DOTExport.DotProducer.produceNodes(), DOTExport.DotProducer.producePaths(), DOTExport.DotProducer.produceServices(), DOTExport.DotProducer.produceSource(), edmIntegrityCheck.IntegrityCheck.query(), cmsswPreprocessor.CmsswPreprocessor.run(), DTWorkflow.DTWorkflow.run(), production_tasks.BaseDataset.run(), production_tasks.GenerateMask.run(), production_tasks.RunCMSBatch.run(), production_tasks.MonitorJobs.run(), production_tasks.CheckJobStatus.run(), production_tasks.CleanJobFiles.run(), DOTExport.DotProducer.seqRecurseChildren(), FileExportPlugin.FileExportPlugin.setOption(), DTWorkflow.DTWorkflow.user(), and DOTExport.DotExport.write_output().

DTWorkflow.DTWorkflow.outpath_command_tag
DTWorkflow.DTWorkflow.output_files

Definition at line 32 of file DTWorkflow.py.

DTWorkflow.DTWorkflow.pset_name
DTWorkflow.DTWorkflow.required_options_dict
DTWorkflow.DTWorkflow.required_options_prepare_dict
DTWorkflow.DTWorkflow.run_all_command

Definition at line 35 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.all().