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 17 of file DTWorkflow.py.

Constructor & Destructor Documentation

def DTWorkflow.DTWorkflow.__init__ (   self,
  options 
)

Definition at line 20 of file DTWorkflow.py.

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

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

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

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

Definition at line 182 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().

183  for option in ('inputDBRcd', 'connectStrDBTag'):
184  if hasattr(self.options, option) and not getattr(self.options, option):
185  raise ValueError("Option %s needed for custom input db" % option)
186  self.addPoolDBESSource( process = self.process,
187  record = self.options.inputDBRcd,
188  tag = self.options.inputDBTag,
189  connect = self.options.connectStrDBTag,
190  moduleName = 'customDB%s' % self.options.inputDBRcd
191  )
192 
def addPoolDBESSource(process, moduleName, record, tag, connect='sqlite_file:', label='')
Definition: DTWorkflow.py:247
def add_local_custom_db(self)
Definition: DTWorkflow.py:182
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 132 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().

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

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

Definition at line 119 of file DTWorkflow.py.

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

Referenced by DTWorkflow.DTWorkflow.prepare_common_submit().

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

Definition at line 247 of file DTWorkflow.py.

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

247  label='',):
248 
249  from CondCore.CondDB.CondDB_cfi import CondDB
250 
251  calibDB = cms.ESSource("PoolDBESSource",
252  CondDB,
253  timetype = cms.string('runnumber'),
254  toGet = cms.VPSet(cms.PSet(
255  record = cms.string(record),
256  tag = cms.string(tag),
257  label = cms.untracked.string(label)
258  )),
259  )
260  calibDB.connect = cms.string( str(connect) )
261  #if authPath: calibDB.DBParameters.authenticationPath = authPath
262  if 'oracle:' in connect:
263  calibDB.DBParameters.authenticationPath = '/afs/cern.ch/cms/DB/conddb'
264  setattr(process,moduleName,calibDB)
265  setattr(process,"es_prefer_" + moduleName,cms.ESPrefer('PoolDBESSource',
266  moduleName)
267  )
268 
#define str(s)
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 93 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(), MuonDTLocalMillepedeAlgorithm.run(), crabWrapper.CrabWrapper.run(), HIPAlignmentAlgorithm.run(), DTWorkflow.DTWorkflow.run(), options.ConnectionHLTMenu.run, MuonRecoTest.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, DQMNet::CoreObject.run, MatrixUtil.InputInfo.run, DTLocalTriggerBaseTest.run, HitEff.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.

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

Definition at line 106 of file DTWorkflow.py.

References CrabHelper.CrabHelper.check_crabtask().

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

Definition at line 42 of file DTWorkflow.py.

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

Referenced by DTWorkflow.DTWorkflow.run().

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

Definition at line 116 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.runCMSSWtask().

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

Definition at line 113 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.runCMSSWtask().

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

Definition at line 390 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().

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

Definition at line 384 of file DTWorkflow.py.

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

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

Definition at line 269 of file DTWorkflow.py.

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

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

Definition at line 394 of file DTWorkflow.py.

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

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

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

Definition at line 403 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().

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

Definition at line 333 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().

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

Definition at line 313 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().

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

Definition at line 228 of file DTWorkflow.py.

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

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

Definition at line 193 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().

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

Definition at line 211 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().

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

Definition at line 87 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.run().

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

Definition at line 369 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().

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

Definition at line 359 of file DTWorkflow.py.

360  """ Base path to folder containing pset files for cmsRun"""
361  return os.path.expandvars(os.path.join("$CMSSW_BASE",
362  "src",
363  "CalibMuon",
364  "test",
365  )
366  )
367 
def pset_template_base_bath(self)
Definition: DTWorkflow.py:359
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 291 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(), 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().

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

Definition at line 57 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().

57  def run(self):
58  """ Generalized function to run workflow command"""
59  msg = "Preparing %s workflow" % self.options.workflow
60  if hasattr(self.options, "command"):
61  msg += " for command %s" % self.options.command
62  log.info(msg)
63  if self.options.config_path:
64  self.load_options( self.options.config_path )
65  #check if all options to prepare the command are used
67  self.prepare_workflow()
68  # create output folder if they do not exist yet
69  if not os.path.exists( self.local_path ):
70  os.makedirs(self.local_path)
71  # dump used options
72  self.dump_options()
73  #check if all options to run the command are used
75  try:
76  run_function = getattr(self, self.options.command)
77  except AttributeError:
78  errmsg = "Class `{}` does not implement `{}` for workflow %s" % self.options.workflow
79  if hasattr(self.options, "workflow_mode"):
80  errmsg += "and workflow mode %s" % self.options.workflow_mode
81  raise NotImplementedError( errmsg.format(self.__class__.__name__,
82  self.options.command))
83  log.debug("Running command %s" % self.options.command)
84  # call chosen function
85  run_function()
86 
def check_missing_options(self, requirements_dict)
Definition: DTWorkflow.py:42
def load_options(self, config_file_path)
Definition: DTWorkflow.py:394
def dump_options(self)
Definition: DTWorkflow.py:390
def prepare_workflow(self)
Definition: DTWorkflow.py:87
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 275 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().

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

Definition at line 103 of file DTWorkflow.py.

References CrabHelper.CrabHelper.submit_crab_task().

103  def submit(self):
104  self.submit_crab_task()
105 
def submit_crab_task(self)
Definition: CrabHelper.py:21
def DTWorkflow.DTWorkflow.tag (   self)

Definition at line 319 of file DTWorkflow.py.

References str.

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

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

Definition at line 323 of file DTWorkflow.py.

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

Referenced by DTWorkflow.DTWorkflow.remote_out_path().

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

Definition at line 110 of file DTWorkflow.py.

References DTWorkflow.DTWorkflow.runCMSSWtask().

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

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

Member Data Documentation

DTWorkflow.DTWorkflow._user
private

Definition at line 38 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.user().

DTWorkflow.DTWorkflow.digilabel

Definition at line 23 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.add_raw_option().

DTWorkflow.DTWorkflow.files_reveived

Definition at line 37 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.prepare_common_write().

DTWorkflow.DTWorkflow.input_files

Definition at line 34 of file DTWorkflow.py.

DTWorkflow.DTWorkflow.options

Definition at line 21 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(), confdb.HLTProcess.getRawConfigurationFromDB(), confdb.HLTProcess.getSetupConfigurationFromDB(), 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 33 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 36 of file DTWorkflow.py.

Referenced by DTWorkflow.DTWorkflow.all().