CMS 3D CMS Logo

Classes | Functions | Variables
cmsHarvester Namespace Reference

Classes

class  CMSHarvester
 CMSHarvester class. More...
 
class  CMSHarvesterHelpFormatter
 Helper class: CMSHarvesterHelpFormatter. More...
 
class  DBSXMLHandler
 Helper class: DBSXMLHandler. More...
 
class  Error
 Helper class: Error exception. More...
 
class  Usage
 Helper class: Usage exception. More...
 

Functions

def build_dataset_ignore_list (self)
 
def build_dataset_list (self, input_method, input_name)
 def dbs_check_dataset_num_events(self, dataset_name): """Figure out the number of events in each run of this dataset. More...
 
def build_dataset_use_list (self)
 
def build_datasets_information (self)
 
def build_runs_ignore_list (self)
 
def build_runs_list (self, input_method, input_name)
 
def build_runs_use_list (self)
 
def check_cmssw (self)
 
def check_dataset_list (self)
 
def check_dbs (self)
 
def check_globaltag (self, globaltag=None)
 
def check_globaltag_contains_ref_hist_key (self, globaltag, connect_name)
 
def check_globaltag_exists (self, globaltag, connect_name)
 
def check_input_status (self)
 
def check_ref_hist_mappings (self)
 
def check_ref_hist_tag (self, tag_name)
 
def create_and_check_castor_dir (self, castor_dir)
 
def create_and_check_castor_dirs (self)
 
def create_castor_path_name_common (self, dataset_name)
 
def create_castor_path_name_special (self, dataset_name, run_number, castor_path_common)
 
def create_config_file_name (self, dataset_name, run_number)
 
def create_crab_config (self)
 
def create_es_prefer_snippet (self, dataset_name)
 
def create_harvesting_config (self, dataset_name)
 
def create_harvesting_config_file_name (self, dataset_name)
 
def create_harvesting_output_file_name (self, dataset_name, run_number)
 
def create_me_extraction_config (self, dataset_name)
 def create_harvesting_config_two_step(self, dataset_name): """Create the Python harvesting configuration for two-step harvesting. More...
 
def create_me_summary_config_file_name (self, dataset_name)
 
def create_me_summary_output_file_name (self, dataset_name)
 
def create_multicrab_block_name (self, dataset_name, run_number, index)
 
def create_multicrab_config (self)
 
def create_output_file_name (self, dataset_name, run_number=None)
 
def dbs_check_dataset_spread (self, dataset_name)
 def dbs_resolve_dataset_number_of_sites(self, dataset_name): """Ask DBS across how many sites this dataset has been spread out. More...
 
def dbs_resolve_cmssw_version (self, dataset_name)
 
def dbs_resolve_dataset_name (self, dataset_name)
 
def dbs_resolve_datatype (self, dataset_name)
 
def dbs_resolve_globaltag (self, dataset_name)
 
def dbs_resolve_number_of_events (self, dataset_name, run_number=None)
 
def dbs_resolve_runs (self, dataset_name)
 def dbs_resolve_dataset_number_of_events(self, dataset_name): """Ask DBS across how many events this dataset has been spread out. More...
 
def escape_dataset_name (self, dataset_name)
 
def load_ref_hist_mappings (self)
 
def option_handler_caf_access (self, option, opt_str, value, parser)
 
def option_handler_castor_dir (self, option, opt_str, value, parser)
 def option_handler_dataset_name(self, option, opt_str, value, parser): """Specify the name(s) of the dataset(s) to be processed. More...
 
def option_handler_crab_submission (self, option, opt_str, value, parser)
 
def option_handler_list_types (self, option, opt_str, value, parser)
 
def option_handler_no_t1access (self, option, opt_str, value, parser)
 
def option_handler_preferred_site (self, option, opt_str, value, parser)
 
def option_handler_saveByLumiSection (self, option, opt_str, value, parser)
 
def option_handler_sites (self, option, opt_str, value, parser)
 
def parse_cmd_line_options (self)
 
def pick_a_site (self, sites, cmssw_version)
 
def process_dataset_ignore_list (self)
 
def process_runs_use_and_ignore_lists (self)
 
def ref_hist_mappings_needed (self, dataset_name=None)
 
def run (self)
 
def setup_dbs (self)
 
def setup_harvesting_info (self)
 
def show_exit_message (self)
 
def singlify_datasets (self)
 
def write_crab_config (self)
 def create_harvesting_config(self, dataset_name): """Create the Python harvesting configuration for a given job. More...
 
def write_harvesting_config (self, dataset_name)
 
def write_me_extraction_config (self, dataset_name)
 
def write_multicrab_config (self)
 

Variables

 __author__
 
 __version__
 
 all_file_names
 
 all_sites_found
 
 caf_access
 
 castor_base_dir
 
 castor_path_checks_cache
 self.logger.debug("Path is now `%s'" % \ path) More...
 
 castor_path_common
 
 castor_paths
 
 cmd
 
 cmd_line_opts
 
 cmssw_version
 
 complete_sites
 site_names_ref = set(files_info[run_number].values()[0][1]) for site_names_tmp in files_info[run_number].values()[1:]: if set(site_names_tmp[1]) != site_names_ref: mirrored = False break More...
 
 config_contents
 
 config_file_name
 
 crab_submission
 
 dataset_names_after_checks
 
 dataset_names_after_checks_tmp
 
 datasets_information
 
 datasets_to_ignore
 
 datasets_to_use
 
 dbs_api
 
 empty_runs
 
 exit_code
 
 file_name
 
 files_at_site
 
 files_info
 
 files_without_sites
 
 globaltag
 
 harvesting_info
 
 harvesting_mode
 
 harvesting_type
 
 Jsonfilename
 
 Jsonlumi
 
 mirrored
 
 msg
 class Handler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): if name == "result": site_name = str(attrs["STORAGEELEMENT_SENAME"]) More...
 
 nevents
 
 non_t1access
 
 nr_max_sites
 
 num_events_catalog
 
 num_events_dataset
 
 num_sites
 if self.datasets_information[dataset_name]["num_events"][run_number] != 0: pdb.set_trace() DEBUG DEBUG DEBUG end More...
 
 option_parser
 
 output
 
 path
 else: More...
 
 permissions
 
 permissions_new
 
 permissions_target
 
 preferred_site
 
 ref_hist_mappings_file_name
 
 run_number
 
 runs_to_ignore
 
 runs_to_use
 
 saveByLumiSection
 
 site_names
 
 sites_with_complete_copies
 
 skip_this_path_piece
 self.logger.debug("Checking CASTOR path piece `%s'" % \ piece) More...
 
 status
 
 tmp
 tmp = self.datasets_information[dataset_name] \ ["num_events"] More...
 
 traceback_string
 
 twiki_url
 

Function Documentation

◆ build_dataset_ignore_list()

def cmsHarvester.build_dataset_ignore_list (   self)
Build a list of datasets to ignore.

NOTE: We should always have a list of datasets to process, but
it may be that we don't have a list of datasets to ignore.

Definition at line 3444 of file cmsHarvester.py.

3444  def build_dataset_ignore_list(self):
3445  """Build a list of datasets to ignore.
3446 
3447  NOTE: We should always have a list of datasets to process, but
3448  it may be that we don't have a list of datasets to ignore.
3449 
3450  """
3451 
3452  self.logger.info("Building list of datasets to ignore...")
3453 
3454  input_method = self.input_method["datasets"]["ignore"]
3455  input_name = self.input_name["datasets"]["ignore"]
3456  dataset_names = self.build_dataset_list(input_method,
3457  input_name)
3458  self.datasets_to_ignore = dict(list(zip(dataset_names,
3459  [None] * len(dataset_names))))
3460 
3461  self.logger.info(" found %d dataset(s) to ignore:" % \
3462  len(dataset_names))
3463  for dataset in dataset_names:
3464  self.logger.info(" `%s'" % dataset)
3465 
3466  # End of build_dataset_ignore_list.
3467 

References info().

◆ build_dataset_list()

def cmsHarvester.build_dataset_list (   self,
  input_method,
  input_name 
)

def dbs_check_dataset_num_events(self, dataset_name): """Figure out the number of events in each run of this dataset.

This is a more efficient way of doing this than calling dbs_resolve_number_of_events for each run.

BUG BUG BUG

This might very well not work at all for spread-out samples. (?)

BUG BUG BUG end

"""

DEBUG DEBUG DEBUG

If we get here DBS should have been set up already.

assert not self.dbs_api is None

DEBUG DEBUG DEBUG end

api = self.dbs_api dbs_query = "find run.number, file.name, file.numevents where dataset = %s " \ "and dataset.status = VALID" % \ dataset_name try: api_result = api.executeQuery(dbs_query) except DbsApiException: msg = "ERROR: Could not execute DBS query" self.logger.fatal(msg) raise Error(msg) try: files_info = {} class Handler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): if name == "result": run_number = int(attrs["RUNS_RUNNUMBER"]) file_name = str(attrs["FILES_LOGICALFILENAME"]) nevents = int(attrs["FILES_NUMBEROFEVENTS"]) try: files_info[run_number][file_name] = nevents except KeyError: files_info[run_number] = {file_name: nevents} xml.sax.parseString(api_result, Handler()) except SAXParseException: msg = "ERROR: Could not parse DBS server output" self.logger.fatal(msg) raise Error(msg) num_events_catalog = {} for run_number in files_info.keys(): num_events_catalog[run_number] = sum(files_info[run_number].values())

End of dbs_check_dataset_num_events.

return num_events_catalog End of old version.

Build a list of all datasets to be processed.

Definition at line 3358 of file cmsHarvester.py.

3358  def build_dataset_list(self, input_method, input_name):
3359  """Build a list of all datasets to be processed.
3360 
3361  """
3362 
3363  dataset_names = []
3364 
3365  # It may be, but only for the list of datasets to ignore, that
3366  # the input method and name are None because nothing was
3367  # specified. In that case just an empty list is returned.
3368  if input_method is None:
3369  pass
3370  elif input_method == "dataset":
3371  # Input comes from a dataset name directly on the command
3372  # line. But, this can also contain wildcards so we need
3373  # DBS to translate it conclusively into a list of explicit
3374  # dataset names.
3375  self.logger.info("Asking DBS for dataset names")
3376  dataset_names = self.dbs_resolve_dataset_name(input_name)
3377  elif input_method == "datasetfile":
3378  # In this case a file containing a list of dataset names
3379  # is specified. Still, each line may contain wildcards so
3380  # this step also needs help from DBS.
3381  # NOTE: Lines starting with a `#' are ignored.
3382  self.logger.info("Reading input from list file `%s'" % \
3383  input_name)
3384  try:
3385  listfile = open("/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/harvesting/bin/%s" %input_name, "r")
3386  print("open listfile")
3387  for dataset in listfile:
3388  # Skip empty lines.
3389  dataset_stripped = dataset.strip()
3390  if len(dataset_stripped) < 1:
3391  continue
3392  # Skip lines starting with a `#'.
3393  if dataset_stripped[0] != "#":
3394  dataset_names.extend(self. \
3395  dbs_resolve_dataset_name(dataset_stripped))
3396  listfile.close()
3397  except IOError:
3398  msg = "ERROR: Could not open input list file `%s'" % \
3399  input_name
3400  self.logger.fatal(msg)
3401  raise Error(msg)
3402  else:
3403  # DEBUG DEBUG DEBUG
3404  # We should never get here.
3405  assert False, "Unknown input method `%s'" % input_method
3406  # DEBUG DEBUG DEBUG end
3407 
3408  # Remove duplicates from the dataset list.
3409  # NOTE: There should not be any duplicates in any list coming
3410  # from DBS, but maybe the user provided a list file with less
3411  # care.
3412  # Store for later use.
3413  dataset_names = sorted(set(dataset_names))
3414 
3415 
3416  # End of build_dataset_list.
3417  return dataset_names
3418 

References dbs_resolve_dataset_name(), info(), and edm.print().

◆ build_dataset_use_list()

def cmsHarvester.build_dataset_use_list (   self)
Build a list of datasets to process.

Definition at line 3421 of file cmsHarvester.py.

3421  def build_dataset_use_list(self):
3422  """Build a list of datasets to process.
3423 
3424  """
3425 
3426  self.logger.info("Building list of datasets to consider...")
3427 
3428  input_method = self.input_method["datasets"]["use"]
3429  input_name = self.input_name["datasets"]["use"]
3430  dataset_names = self.build_dataset_list(input_method,
3431  input_name)
3432  self.datasets_to_use = dict(list(zip(dataset_names,
3433  [None] * len(dataset_names))))
3434 
3435  self.logger.info(" found %d dataset(s) to process:" % \
3436  len(dataset_names))
3437  for dataset in dataset_names:
3438  self.logger.info(" `%s'" % dataset)
3439 
3440  # End of build_dataset_use_list.
3441 

References info(), list(), and ComparisonHelper.zip().

◆ build_datasets_information()

def cmsHarvester.build_datasets_information (   self)
Obtain all information on the datasets that we need to run.

Use DBS to figure out all required information on our
datasets, like the run numbers and the GlobalTag. All
information is stored in the datasets_information member
variable.

Definition at line 5321 of file cmsHarvester.py.

5321  def build_datasets_information(self):
5322  """Obtain all information on the datasets that we need to run.
5323 
5324  Use DBS to figure out all required information on our
5325  datasets, like the run numbers and the GlobalTag. All
5326  information is stored in the datasets_information member
5327  variable.
5328 
5329  """
5330 
5331  # Get a list of runs in the dataset.
5332  # NOTE: The harvesting has to be done run-by-run, so we
5333  # split up datasets based on the run numbers. Strictly
5334  # speaking this is not (yet?) necessary for Monte Carlo
5335  # since all those samples use run number 1. Still, this
5336  # general approach should work for all samples.
5337 
5338  # Now loop over all datasets in the list and process them.
5339  # NOTE: This processing has been split into several loops
5340  # to be easier to follow, sacrificing a bit of efficiency.
5341  self.datasets_information = {}
5342  self.logger.info("Collecting information for all datasets to process")
5343  dataset_names = sorted(self.datasets_to_use.keys())
5344  for dataset_name in dataset_names:
5345 
5346  # Tell the user which dataset: nice with many datasets.
5347  sep_line = "-" * 30
5348  self.logger.info(sep_line)
5349  self.logger.info(" `%s'" % dataset_name)
5350  self.logger.info(sep_line)
5351 
5352  runs = self.dbs_resolve_runs(dataset_name)
5353  self.logger.info(" found %d run(s)" % len(runs))
5354  if len(runs) > 0:
5355  self.logger.debug(" run number(s): %s" % \
5356  ", ".join([str(i) for i in runs]))
5357  else:
5358  # DEBUG DEBUG DEBUG
5359  # This should never happen after the DBS checks.
5360  self.logger.warning(" --> skipping dataset "
5361  "without any runs")
5362  assert False, "Panic: found a dataset without runs " \
5363  "after DBS checks!"
5364  # DEBUG DEBUG DEBUG end
5365 
5366  cmssw_version = self.dbs_resolve_cmssw_version(dataset_name)
5367  self.logger.info(" found CMSSW version `%s'" % cmssw_version)
5368 
5369  # Figure out if this is data or MC.
5370  datatype = self.dbs_resolve_datatype(dataset_name)
5371  self.logger.info(" sample is data or MC? --> %s" % \
5372  datatype)
5373 
5374 
5375 
5376  # Try and figure out the GlobalTag to be used.
5377  if self.globaltag is None:
5378  globaltag = self.dbs_resolve_globaltag(dataset_name)
5379  else:
5380  globaltag = self.globaltag
5381 
5382  self.logger.info(" found GlobalTag `%s'" % globaltag)
5383 
5384  # DEBUG DEBUG DEBUG
5385  if globaltag == "":
5386  # Actually we should not even reach this point, after
5387  # our dataset sanity checks.
5388  assert datatype == "data", \
5389  "ERROR Empty GlobalTag for MC dataset!!!"
5390  # DEBUG DEBUG DEBUG end
5391 
5392 
5393 
5394  # DEBUG DEBUG DEBUG
5395  #tmp = self.dbs_check_dataset_spread_old(dataset_name)
5396  # DEBUG DEBUG DEBUG end
5397  sites_catalog = self.dbs_check_dataset_spread(dataset_name)
5398 
5399  # Extract the total event counts.
5400  num_events = {}
5401  for run_number in sites_catalog.keys():
5402  num_events[run_number] = sites_catalog \
5403  [run_number]["all_sites"]
5404  del sites_catalog[run_number]["all_sites"]
5405 
5406  # Extract the information about whether or not datasets
5407  # are mirrored.
5408  mirror_catalog = {}
5409  for run_number in sites_catalog.keys():
5410  mirror_catalog[run_number] = sites_catalog \
5411  [run_number]["mirrored"]
5412  del sites_catalog[run_number]["mirrored"]
5413 
5414  # BUG BUG BUG
5415  # I think I could now get rid of that and just fill the
5416  # "sites" entry with the `inverse' of this
5417  # num_events_catalog(?).
5418  #num_sites = self.dbs_resolve_dataset_number_of_sites(dataset_name)
5419  #sites_catalog = self.dbs_check_dataset_spread(dataset_name)
5420  #sites_catalog = dict(zip(num_events_catalog.keys(),
5421  # [[j for i in num_events_catalog.values() for j in i.keys()]]))
5422  # BUG BUG BUG end
5423 

◆ build_runs_ignore_list()

def cmsHarvester.build_runs_ignore_list (   self)
Build a list of runs to ignore.

NOTE: We should always have a list of runs to process, but
it may be that we don't have a list of runs to ignore.

Definition at line 3542 of file cmsHarvester.py.

3542  def build_runs_ignore_list(self):
3543  """Build a list of runs to ignore.
3544 
3545  NOTE: We should always have a list of runs to process, but
3546  it may be that we don't have a list of runs to ignore.
3547 
3548  """
3549 
3550  self.logger.info("Building list of runs to ignore...")
3551 
3552  input_method = self.input_method["runs"]["ignore"]
3553  input_name = self.input_name["runs"]["ignore"]
3554  runs = self.build_runs_list(input_method, input_name)
3555  self.runs_to_ignore = dict(list(zip(runs, [None] * len(runs))))
3556 
3557  self.logger.info(" found %d run(s) to ignore:" % \
3558  len(runs))
3559  if len(runs) > 0:
3560  self.logger.info(" %s" % ", ".join([str(i) for i in runs]))
3561 
3562  # End of build_runs_ignore_list().
3563 

References info().

◆ build_runs_list()

def cmsHarvester.build_runs_list (   self,
  input_method,
  input_name 
)

Definition at line 3470 of file cmsHarvester.py.

3470  def build_runs_list(self, input_method, input_name):
3471 
3472  runs = []
3473 
3474  # A list of runs (either to use or to ignore) is not
3475  # required. This protects against `empty cases.'
3476  if input_method is None:
3477  pass
3478  elif input_method == "runs":
3479  # A list of runs was specified directly from the command
3480  # line.
3481  self.logger.info("Reading list of runs from the " \
3482  "command line")
3483  runs.extend([int(i.strip()) \
3484  for i in input_name.split(",") \
3485  if len(i.strip()) > 0])
3486  elif input_method == "runslistfile":
3487  # We were passed a file containing a list of runs.
3488  self.logger.info("Reading list of runs from file `%s'" % \
3489  input_name)
3490  try:
3491  listfile = open(input_name, "r")
3492  for run in listfile:
3493  # Skip empty lines.
3494  run_stripped = run.strip()
3495  if len(run_stripped) < 1:
3496  continue
3497  # Skip lines starting with a `#'.
3498  if run_stripped[0] != "#":
3499  runs.append(int(run_stripped))
3500  listfile.close()
3501  except IOError:
3502  msg = "ERROR: Could not open input list file `%s'" % \
3503  input_name
3504  self.logger.fatal(msg)
3505  raise Error(msg)
3506 
3507  else:
3508  # DEBUG DEBUG DEBUG
3509  # We should never get here.
3510  assert False, "Unknown input method `%s'" % input_method
3511  # DEBUG DEBUG DEBUG end
3512 
3513  # Remove duplicates, sort and done.
3514  runs = list(set(runs))
3515 
3516  # End of build_runs_list().
3517  return runs
3518 

References info(), createfilelist.int, and list().

◆ build_runs_use_list()

def cmsHarvester.build_runs_use_list (   self)
Build a list of runs to process.

Definition at line 3521 of file cmsHarvester.py.

3521  def build_runs_use_list(self):
3522  """Build a list of runs to process.
3523 
3524  """
3525 
3526  self.logger.info("Building list of runs to consider...")
3527 
3528  input_method = self.input_method["runs"]["use"]
3529  input_name = self.input_name["runs"]["use"]
3530  runs = self.build_runs_list(input_method, input_name)
3531  self.runs_to_use = dict(list(zip(runs, [None] * len(runs))))
3532 
3533  self.logger.info(" found %d run(s) to process:" % \
3534  len(runs))
3535  if len(runs) > 0:
3536  self.logger.info(" %s" % ", ".join([str(i) for i in runs]))
3537 
3538  # End of build_runs_list().
3539 

References info().

◆ check_cmssw()

def cmsHarvester.check_cmssw (   self)
Check if CMSSW is setup.

Definition at line 2334 of file cmsHarvester.py.

2334  def check_cmssw(self):
2335  """Check if CMSSW is setup.
2336 
2337  """
2338 
2339  # Try to access the CMSSW_VERSION environment variable. If
2340  # it's something useful we consider CMSSW to be set up
2341  # properly. Otherwise we raise an error.
2342  cmssw_version = os.getenv("CMSSW_VERSION")
2343  if cmssw_version is None:
2344  self.logger.fatal("It seems CMSSW is not setup...")
2345  self.logger.fatal("($CMSSW_VERSION is empty)")
2346  raise Error("ERROR: CMSSW needs to be setup first!")
2347 
2348  self.cmssw_version = cmssw_version
2349  self.logger.info("Found CMSSW version %s properly set up" % \
2350  self.cmssw_version)
2351 
2352  # End of check_cmsssw.
2353  return True
2354 

◆ check_dataset_list()

def cmsHarvester.check_dataset_list (   self)
Check list of dataset names for impossible ones.

Two kinds of checks are done:
- Checks for things that do not make sense. These lead to
  errors and skipped datasets.
- Sanity checks. For these warnings are issued but the user is
  considered to be the authoritative expert.

Checks performed:
- The CMSSW version encoded in the dataset name should match
  self.cmssw_version. This is critical.
- There should be some events in the dataset/run. This is
  critical in the sense that CRAB refuses to create jobs for
  zero events. And yes, this does happen in practice. E.g. the
  reprocessed CRAFT08 datasets contain runs with zero events.
- A cursory check is performed to see if the harvesting type
  makes sense for the data type. This should prevent the user
  from inadvertently running RelVal for data.
- It is not possible to run single-step harvesting jobs on
  samples that are not fully contained at a single site.
- Each dataset/run has to be available at at least one site.

Definition at line 3795 of file cmsHarvester.py.

3795  def check_dataset_list(self):
3796  """Check list of dataset names for impossible ones.
3797 
3798  Two kinds of checks are done:
3799  - Checks for things that do not make sense. These lead to
3800  errors and skipped datasets.
3801  - Sanity checks. For these warnings are issued but the user is
3802  considered to be the authoritative expert.
3803 
3804  Checks performed:
3805  - The CMSSW version encoded in the dataset name should match
3806  self.cmssw_version. This is critical.
3807  - There should be some events in the dataset/run. This is
3808  critical in the sense that CRAB refuses to create jobs for
3809  zero events. And yes, this does happen in practice. E.g. the
3810  reprocessed CRAFT08 datasets contain runs with zero events.
3811  - A cursory check is performed to see if the harvesting type
3812  makes sense for the data type. This should prevent the user
3813  from inadvertently running RelVal for data.
3814  - It is not possible to run single-step harvesting jobs on
3815  samples that are not fully contained at a single site.
3816  - Each dataset/run has to be available at at least one site.
3817 
3818  """
3819 
3820  self.logger.info("Performing sanity checks on dataset list...")
3821 
3822  dataset_names_after_checks = copy.deepcopy(self.datasets_to_use)
3823 
3824  for dataset_name in self.datasets_to_use.keys():
3825 
3826  # Check CMSSW version.
3827  version_from_dataset = self.datasets_information[dataset_name] \
3828  ["cmssw_version"]
3829  if version_from_dataset != self.cmssw_version:
3830  msg = " CMSSW version mismatch for dataset `%s' " \
3831  "(%s vs. %s)" % \
3832  (dataset_name,
3833  self.cmssw_version, version_from_dataset)
3834  if self.force_running:
3835  # Expert mode: just warn, then continue.
3836  self.logger.warning("%s " \
3837  "--> `force mode' active: " \
3838  "run anyway" % msg)
3839  else:
3840  del dataset_names_after_checks[dataset_name]
3841  self.logger.warning("%s " \
3842  "--> skipping" % msg)
3843  continue
3844 
3845 
3846 
3847  # Check that the harvesting type makes sense for the
3848  # sample. E.g. normally one would not run the DQMOffline
3849  # harvesting on Monte Carlo.
3850  # TODO TODO TODO
3851  # This should be further refined.
3852  suspicious = False
3853  datatype = self.datasets_information[dataset_name]["datatype"]
3854  if datatype == "data":
3855  # Normally only DQM harvesting is run on data.
3856  if self.harvesting_type != "DQMOffline":
3857  suspicious = True
3858  elif datatype == "mc":
3859  if self.harvesting_type == "DQMOffline":
3860  suspicious = True
3861  else:
3862  # Doh!
3863  assert False, "ERROR Impossible data type `%s' " \
3864  "for dataset `%s'" % \
3865  (datatype, dataset_name)
3866  if suspicious:
3867  msg = " Normally one does not run `%s' harvesting " \
3868  "on %s samples, are you sure?" % \
3869  (self.harvesting_type, datatype)
3870  if self.force_running:
3871  self.logger.warning("%s " \
3872  "--> `force mode' active: " \
3873  "run anyway" % msg)
3874  else:
3875  del dataset_names_after_checks[dataset_name]
3876  self.logger.warning("%s " \
3877  "--> skipping" % msg)
3878  continue
3879 
3880  # TODO TODO TODO end
3881 
3882 
3883 
3884  # BUG BUG BUG
3885  # For the moment, due to a problem with DBS, I cannot
3886  # figure out the GlobalTag for data by myself. (For MC
3887  # it's no problem.) This means that unless a GlobalTag was
3888  # specified from the command line, we will have to skip
3889  # any data datasets.
3890 
3891  if datatype == "data":
3892  if self.globaltag is None:
3893  msg = "For data datasets (like `%s') " \
3894  "we need a GlobalTag" % \
3895  dataset_name
3896  del dataset_names_after_checks[dataset_name]
3897  self.logger.warning("%s " \
3898  "--> skipping" % msg)
3899  continue
3900 
3901  # BUG BUG BUG end
3902 
3903 
3904 
3905  # Check if the GlobalTag exists and (if we're using
3906  # reference histograms) if it's ready to be used with
3907  # reference histograms.
3908  globaltag = self.datasets_information[dataset_name]["globaltag"]
3909  if not globaltag in self.globaltag_check_cache:
3910  if self.check_globaltag(globaltag):
3911  self.globaltag_check_cache.append(globaltag)
3912  else:
3913  msg = "Something is wrong with GlobalTag `%s' " \
3914  "used by dataset `%s'!" % \
3915  (globaltag, dataset_name)
3916  if self.use_ref_hists:
3917  msg += "\n(Either it does not exist or it " \
3918  "does not contain the required key to " \
3919  "be used with reference histograms.)"
3920  else:
3921  msg += "\n(It probably just does not exist.)"
3922  self.logger.fatal(msg)
3923  raise Usage(msg)
3924 
3925 
3926 
3927  # Require that each run is available at least somewhere.
3928  runs_without_sites = [i for (i, j) in \
3929  self.datasets_information[dataset_name] \
3930  ["sites"].items() \
3931  if len(j) < 1 and \
3932  i in self.datasets_to_use[dataset_name]]
3933  if len(runs_without_sites) > 0:
3934  for run_without_sites in runs_without_sites:
3935  try:
3936  dataset_names_after_checks[dataset_name].remove(run_without_sites)
3937  except KeyError:
3938  pass
3939  self.logger.warning(" removed %d unavailable run(s) " \
3940  "from dataset `%s'" % \
3941  (len(runs_without_sites), dataset_name))
3942  self.logger.debug(" (%s)" % \
3943  ", ".join([str(i) for i in \
3944  runs_without_sites]))
3945 
3946 
3947 
3948  # Unless we're running two-step harvesting: only allow
3949  # samples located on a single site.
3950  if not self.harvesting_mode == "two-step":
3951  for run_number in self.datasets_to_use[dataset_name]:
3952  # DEBUG DEBUG DEBUG

References info(), relativeConstraints.keys, and MessageLogger_cfi.warning.

◆ check_dbs()

def cmsHarvester.check_dbs (   self)
Check if DBS is setup.

Definition at line 2357 of file cmsHarvester.py.

2357  def check_dbs(self):
2358  """Check if DBS is setup.
2359 
2360  """
2361 
2362  # Try to access the DBSCMD_HOME environment variable. If this
2363  # looks useful we consider DBS to be set up
2364  # properly. Otherwise we raise an error.
2365  dbs_home = os.getenv("DBSCMD_HOME")
2366  if dbs_home is None:
2367  self.logger.fatal("It seems DBS is not setup...")
2368  self.logger.fatal(" $DBSCMD_HOME is empty")
2369  raise Error("ERROR: DBS needs to be setup first!")
2370 

References debug.

◆ check_globaltag()

def cmsHarvester.check_globaltag (   self,
  globaltag = None 
)
Check if globaltag exists.

Check if globaltag exists as GlobalTag in the database given
by self.frontier_connection_name['globaltag']. If globaltag is
None, self.globaltag is used instead.

If we're going to use reference histograms this method also
checks for the existence of the required key in the GlobalTag.

Definition at line 4501 of file cmsHarvester.py.

4501  def check_globaltag(self, globaltag=None):
4502  """Check if globaltag exists.
4503 
4504  Check if globaltag exists as GlobalTag in the database given
4505  by self.frontier_connection_name['globaltag']. If globaltag is
4506  None, self.globaltag is used instead.
4507 
4508  If we're going to use reference histograms this method also
4509  checks for the existence of the required key in the GlobalTag.
4510 
4511  """
4512 
4513  if globaltag is None:
4514  globaltag = self.globaltag
4515 
4516  # All GlobalTags should end in `::All', right?
4517  if globaltag.endswith("::All"):
4518  globaltag = globaltag[:-5]
4519 
4520  connect_name = self.frontier_connection_name["globaltag"]
4521  # BUG BUG BUG
4522  # There is a bug in cmscond_tagtree_list: some magic is
4523  # missing from the implementation requiring one to specify
4524  # explicitly the name of the squid to connect to. Since the
4525  # cmsHarvester can only be run from the CERN network anyway,
4526  # cmsfrontier:8000 is hard-coded in here. Not nice but it
4527  # works.
4528  connect_name = connect_name.replace("frontier://",
4529  "frontier://cmsfrontier:8000/")
4530  # BUG BUG BUG end
4531  connect_name += self.db_account_name_cms_cond_globaltag()
4532 
4533  tag_exists = self.check_globaltag_exists(globaltag, connect_name)
4534 
4535  #----------
4536 
4537  tag_contains_ref_hist_key = False
4538  if self.use_ref_hists and tag_exists:
4539  # Check for the key required to use reference histograms.
4540  tag_contains_ref_hist_key = self.check_globaltag_contains_ref_hist_key(globaltag, connect_name)
4541 
4542  #----------
4543 
4544  if self.use_ref_hists:
4545  ret_val = tag_exists and tag_contains_ref_hist_key
4546  else:
4547  ret_val = tag_exists
4548 
4549  #----------
4550 
4551  # End of check_globaltag.
4552  return ret_val
4553 

◆ check_globaltag_contains_ref_hist_key()

def cmsHarvester.check_globaltag_contains_ref_hist_key (   self,
  globaltag,
  connect_name 
)
Check if globaltag contains the required RefHistos key.

Definition at line 4598 of file cmsHarvester.py.

4598  def check_globaltag_contains_ref_hist_key(self, globaltag, connect_name):
4599  """Check if globaltag contains the required RefHistos key.
4600 
4601  """
4602 
4603  # Check for the key required to use reference histograms.
4604  tag_contains_key = None
4605  ref_hist_key = "RefHistos"
4606  self.logger.info("Checking existence of reference " \
4607  "histogram key `%s' in GlobalTag `%s'" % \
4608  (ref_hist_key, globaltag))
4609  self.logger.debug(" (Using database connection `%s')" % \
4610  connect_name)
4611  cmd = "cmscond_tagtree_list -c %s -T %s -n %s" % \
4612  (connect_name, globaltag, ref_hist_key)
4613  (status, output) = commands.getstatusoutput(cmd)
4614  if status != 0 or \
4615  output.find("error") > -1:
4616  msg = "Could not check existence of key `%s'" % \
4617  (ref_hist_key, connect_name)
4618  self.logger.fatal(msg)
4619  self.logger.debug("Command used:")
4620  self.logger.debug(" %s" % cmd)
4621  self.logger.debug("Output received:")
4622  self.logger.debug(" %s" % output)
4623  raise Error(msg)
4624  if len(output) < 1:
4625  self.logger.debug("Required key for use of reference " \
4626  "histograms `%s' does not exist " \
4627  "in GlobalTag `%s':" % \
4628  (ref_hist_key, globaltag))
4629  self.logger.debug("Output received:")
4630  self.logger.debug(output)
4631  tag_contains_key = False
4632  else:
4633  tag_contains_key = True
4634 
4635  self.logger.info(" GlobalTag contains `%s' key? -> %s" % \
4636  (ref_hist_key, tag_contains_key))
4637 
4638  # End of check_globaltag_contains_ref_hist_key.
4639  return tag_contains_key
4640 

References debug, and info().

◆ check_globaltag_exists()

def cmsHarvester.check_globaltag_exists (   self,
  globaltag,
  connect_name 
)
Check if globaltag exists.

Definition at line 4556 of file cmsHarvester.py.

4556  def check_globaltag_exists(self, globaltag, connect_name):
4557  """Check if globaltag exists.
4558 
4559  """
4560 
4561  self.logger.info("Checking existence of GlobalTag `%s'" % \
4562  globaltag)
4563  self.logger.debug(" (Using database connection `%s')" % \
4564  connect_name)
4565 
4566  cmd = "cmscond_tagtree_list -c %s -T %s" % \
4567  (connect_name, globaltag)
4568  (status, output) = commands.getstatusoutput(cmd)
4569  if status != 0 or \
4570  output.find("error") > -1:
4571  msg = "Could not check existence of GlobalTag `%s' in `%s'" % \
4572  (globaltag, connect_name)
4573  if output.find(".ALL_TABLES not found") > -1:
4574  msg = "%s\n" \
4575  "Missing database account `%s'" % \
4576  (msg, output.split(".ALL_TABLES")[0].split()[-1])
4577  self.logger.fatal(msg)
4578  self.logger.debug("Command used:")
4579  self.logger.debug(" %s" % cmd)
4580  self.logger.debug("Output received:")
4581  self.logger.debug(output)
4582  raise Error(msg)
4583  if output.find("does not exist") > -1:
4584  self.logger.debug("GlobalTag `%s' does not exist in `%s':" % \
4585  (globaltag, connect_name))
4586  self.logger.debug("Output received:")
4587  self.logger.debug(output)
4588  tag_exists = False
4589  else:
4590  tag_exists = True
4591  self.logger.info(" GlobalTag exists? -> %s" % tag_exists)
4592 
4593  # End of check_globaltag_exists.
4594  return tag_exists
4595 

References debug, info(), and cms::dd.split().

◆ check_input_status()

def cmsHarvester.check_input_status (   self)
Check completeness and correctness of input information.

Check that all required information has been specified and
that, at least as far as can be easily checked, it makes
sense.

NOTE: This is also where any default values are applied.

Definition at line 2193 of file cmsHarvester.py.

2193  def check_input_status(self):
2194  """Check completeness and correctness of input information.
2195 
2196  Check that all required information has been specified and
2197  that, at least as far as can be easily checked, it makes
2198  sense.
2199 
2200  NOTE: This is also where any default values are applied.
2201 
2202  """
2203 
2204  self.logger.info("Checking completeness/correctness of input...")
2205 
2206  # The cmsHarvester does not take (i.e. understand) any
2207  # arguments so there should not be any.
2208  if len(self.args) > 0:
2209  msg = "Sorry but I don't understand `%s'" % \
2210  (" ".join(self.args))
2211  self.logger.fatal(msg)
2212  raise Usage(msg)
2213 
2214  # BUG BUG BUG
2215  # While we wait for some bugs left and right to get fixed, we
2216  # disable two-step.
2217  if self.harvesting_mode == "two-step":
2218  msg = "--------------------\n" \
2219  " Sorry, but for the moment (well, till it works)" \
2220  " the two-step mode has been disabled.\n" \
2221  "--------------------\n"
2222  self.logger.fatal(msg)
2223  raise Error(msg)
2224  # BUG BUG BUG end
2225 
2226  # We need a harvesting method to be specified
2227  if self.harvesting_type is None:
2228  msg = "Please specify a harvesting type"
2229  self.logger.fatal(msg)
2230  raise Usage(msg)
2231  # as well as a harvesting mode.
2232  if self.harvesting_mode is None:
2233  self.harvesting_mode = self.harvesting_mode_default
2234  msg = "No harvesting mode specified --> using default `%s'" % \
2235  self.harvesting_mode
2236  self.logger.warning(msg)
2237  #raise Usage(msg)
2238 
2239 
2240 
2241  # We need an input method so we can find the dataset name(s).
2242  if self.input_method["datasets"]["use"] is None:
2243  msg = "Please specify an input dataset name " \
2244  "or a list file name"
2245  self.logger.fatal(msg)
2246  raise Usage(msg)
2247 
2248  # DEBUG DEBUG DEBUG
2249  # If we get here, we should also have an input name.
2250  assert not self.input_name["datasets"]["use"] is None
2251  # DEBUG DEBUG DEBUG end
2252 
2253 
2254 
2255  # The same holds for the reference histogram mapping file (if
2256  # we're using references).
2257  if self.use_ref_hists:
2258  if self.ref_hist_mappings_file_name is None:
2259  self.ref_hist_mappings_file_name = self.ref_hist_mappings_file_name_default
2260  msg = "No reference histogram mapping file specified --> " \
2261  "using default `%s'" % \
2262  self.ref_hist_mappings_file_name
2263  self.logger.warning(msg)
2264 
2265 
2266 
2267  # We need to know where to put the stuff (okay, the results)
2268  # on CASTOR.
2269  if self.castor_base_dir is None:
2270  self.castor_base_dir = self.castor_base_dir_default
2271  msg = "No CASTOR area specified -> using default `%s'" % \
2272  self.castor_base_dir
2273  self.logger.warning(msg)
2274  #raise Usage(msg)
2275 
2276  # Only the CERN CASTOR area is supported.
2277  if not self.castor_base_dir.startswith(self.castor_prefix):
2278  msg = "CASTOR area does not start with `%s'" % \
2279  self.castor_prefix
2280  self.logger.fatal(msg)
2281  if self.castor_base_dir.find("castor") > -1 and \
2282  not self.castor_base_dir.find("cern.ch") > -1:
2283  self.logger.fatal("Only CERN CASTOR is supported")
2284  raise Usage(msg)
2285 
2286 
2287 
2288  # TODO TODO TODO
2289  # This should be removed in the future, once I find out how to
2290  # get the config file used to create a given dataset from DBS.
2291 
2292  # For data we need to have a GlobalTag. (For MC we can figure
2293  # it out by ourselves.)
2294  if self.globaltag is None:
2295  self.logger.warning("No GlobalTag specified. This means I cannot")
2296  self.logger.warning("run on data, only on MC.")
2297  self.logger.warning("I will skip all data datasets.")
2298 
2299  # TODO TODO TODO end
2300 
2301  # Make sure the GlobalTag ends with `::All'.
2302  if not self.globaltag is None:
2303  if not self.globaltag.endswith("::All"):
2304  self.logger.warning("Specified GlobalTag `%s' does " \
2305  "not end in `::All' --> " \
2306  "appending this missing piece" % \
2307  self.globaltag)
2308  self.globaltag = "%s::All" % self.globaltag
2309 
2310 
2311 
2312  # Dump some info about the Frontier connections used.
2313  for (key, value) in six.iteritems(self.frontier_connection_name):
2314  frontier_type_str = "unknown"
2315  if key == "globaltag":
2316  frontier_type_str = "the GlobalTag"
2317  elif key == "refhists":
2318  frontier_type_str = "the reference histograms"
2319  non_str = None
2320  if self.frontier_connection_overridden[key] == True:
2321  non_str = "non-"
2322  else:
2323  non_str = ""
2324  self.logger.info("Using %sdefault Frontier " \
2325  "connection for %s: `%s'" % \
2326  (non_str, frontier_type_str, value))
2327 
2328 
2329 
2330  # End of check_input_status.
2331 

References info(), and join().

◆ check_ref_hist_mappings()

def cmsHarvester.check_ref_hist_mappings (   self)
Make sure all necessary reference histograms exist.

Check that for each of the datasets to be processed a
reference histogram is specified and that that histogram
exists in the database.

NOTE: There's a little complication here. Since this whole
thing was designed to allow (in principle) harvesting of both
data and MC datasets in one go, we need to be careful to check
the availability fof reference mappings only for those
datasets that need it.

Definition at line 5281 of file cmsHarvester.py.

5281  def check_ref_hist_mappings(self):
5282  """Make sure all necessary reference histograms exist.
5283 
5284  Check that for each of the datasets to be processed a
5285  reference histogram is specified and that that histogram
5286  exists in the database.
5287 
5288  NOTE: There's a little complication here. Since this whole
5289  thing was designed to allow (in principle) harvesting of both
5290  data and MC datasets in one go, we need to be careful to check
5291  the availability fof reference mappings only for those
5292  datasets that need it.
5293 
5294  """
5295 
5296  self.logger.info("Checking reference histogram mappings")
5297 
5298  for dataset_name in self.datasets_to_use:
5299  try:
5300  ref_hist_name = self.ref_hist_mappings[dataset_name]
5301  except KeyError:
5302  msg = "ERROR: No reference histogram mapping found " \
5303  "for dataset `%s'" % \
5304  dataset_name
5305  self.logger.fatal(msg)
5306  raise Error(msg)
5307 
5308  if not self.check_ref_hist_tag(ref_hist_name):
5309  msg = "Reference histogram tag `%s' " \
5310  "(used for dataset `%s') does not exist!" % \
5311  (ref_hist_name, dataset_name)
5312  self.logger.fatal(msg)
5313  raise Usage(msg)
5314 
5315  self.logger.info(" Done checking reference histogram mappings.")
5316 
5317  # End of check_ref_hist_mappings.
5318 

References info().

◆ check_ref_hist_tag()

def cmsHarvester.check_ref_hist_tag (   self,
  tag_name 
)
Check the existence of tag_name in database connect_name.

Check if tag_name exists as a reference histogram tag in the
database given by self.frontier_connection_name['refhists'].

Definition at line 4643 of file cmsHarvester.py.

4643  def check_ref_hist_tag(self, tag_name):
4644  """Check the existence of tag_name in database connect_name.
4645 
4646  Check if tag_name exists as a reference histogram tag in the
4647  database given by self.frontier_connection_name['refhists'].
4648 
4649  """
4650 
4651  connect_name = self.frontier_connection_name["refhists"]
4652  connect_name += self.db_account_name_cms_cond_dqm_summary()
4653 
4654  self.logger.debug("Checking existence of reference " \
4655  "histogram tag `%s'" % \
4656  tag_name)
4657  self.logger.debug(" (Using database connection `%s')" % \
4658  connect_name)
4659 
4660  cmd = "cmscond_list_iov -c %s" % \
4661  connect_name
4662  (status, output) = commands.getstatusoutput(cmd)
4663  if status != 0:
4664  msg = "Could not check existence of tag `%s' in `%s'" % \
4665  (tag_name, connect_name)
4666  self.logger.fatal(msg)
4667  self.logger.debug("Command used:")
4668  self.logger.debug(" %s" % cmd)
4669  self.logger.debug("Output received:")
4670  self.logger.debug(output)
4671  raise Error(msg)
4672  if not tag_name in output.split():
4673  self.logger.debug("Reference histogram tag `%s' " \
4674  "does not exist in `%s'" % \
4675  (tag_name, connect_name))
4676  self.logger.debug(" Existing tags: `%s'" % \
4677  "', `".join(output.split()))
4678  tag_exists = False
4679  else:
4680  tag_exists = True
4681  self.logger.debug(" Reference histogram tag exists? " \
4682  "-> %s" % tag_exists)
4683 
4684  # End of check_ref_hist_tag.
4685  return tag_exists
4686 

References debug, and join().

◆ create_and_check_castor_dir()

def cmsHarvester.create_and_check_castor_dir (   self,
  castor_dir 
)
Check existence of the give CASTOR dir, if necessary create
it.

Some special care has to be taken with several things like
setting the correct permissions such that CRAB can store the
output results. Of course this means that things like
/castor/cern.ch/ and user/j/ have to be recognised and treated
properly.

NOTE: Only CERN CASTOR area (/castor/cern.ch/) supported for
the moment.

NOTE: This method uses some slightly tricky caching to make
sure we don't keep over and over checking the same base paths.

Definition at line 1491 of file cmsHarvester.py.

1491  def create_and_check_castor_dir(self, castor_dir):
1492  """Check existence of the give CASTOR dir, if necessary create
1493  it.
1494 
1495  Some special care has to be taken with several things like
1496  setting the correct permissions such that CRAB can store the
1497  output results. Of course this means that things like
1498  /castor/cern.ch/ and user/j/ have to be recognised and treated
1499  properly.
1500 
1501  NOTE: Only CERN CASTOR area (/castor/cern.ch/) supported for
1502  the moment.
1503 
1504  NOTE: This method uses some slightly tricky caching to make
1505  sure we don't keep over and over checking the same base paths.
1506 
1507  """
1508 
1509 
1510 
1511  # Local helper function to fully split a path into pieces.
1512  def split_completely(path):
1513  (parent_path, name) = os.path.split(path)
1514  if name == "":
1515  return (parent_path, )
1516  else:
1517  return split_completely(parent_path) + (name, )
1518 
1519 
1520 
1521  # Local helper function to check rfio (i.e. CASTOR)
1522  # directories.
1523  def extract_permissions(rfstat_output):
1524  """Parse the output from rfstat and return the
1525  5-digit permissions string."""
1526 
1527  permissions_line = [i for i in output.split("\n") \
1528  if i.lower().find("protection") > -1]
1529  regexp = re.compile(".*\(([0123456789]{5})\).*")
1530  match = regexp.search(rfstat_output)
1531  if not match or len(match.groups()) != 1:
1532  msg = "Could not extract permissions " \
1533  "from output: %s" % rfstat_output
1534  self.logger.fatal(msg)
1535  raise Error(msg)
1536  permissions = match.group(1)
1537 
1538  # End of extract_permissions.
1539  return permissions
1540 
1541 
1542 
1543  # These are the pieces of CASTOR directories that we do not
1544  # want to touch when modifying permissions.
1545 
1546  # NOTE: This is all a bit involved, basically driven by the
1547  # fact that one wants to treat the `j' directory of
1548  # `/castor/cern.ch/user/j/jhegeman/' specially.
1549  # BUG BUG BUG
1550  # This should be simplified, for example by comparing to the
1551  # CASTOR prefix or something like that.
1552  # BUG BUG BUG end
1553  castor_paths_dont_touch = {
1554  0: ["/", "castor", "cern.ch", "cms", "store", "temp",
1555  "dqm", "offline", "user"],
1556  -1: ["user", "store"]
1557  }
1558 
1559  self.logger.debug("Checking CASTOR path `%s'" % castor_dir)
1560 
1561 
1562 
1563  # First we take the full CASTOR path apart.
1564  castor_path_pieces = split_completely(castor_dir)
1565 
1566  # Now slowly rebuild the CASTOR path and see if a) all
1567  # permissions are set correctly and b) the final destination
1568  # exists.
1569  path = ""
1570  check_sizes = sorted(castor_paths_dont_touch.keys())
1571  len_castor_path_pieces = len(castor_path_pieces)
1572  for piece_index in range (len_castor_path_pieces):
1573  skip_this_path_piece = False
1574  piece = castor_path_pieces[piece_index]

References debug, and spr.find().

◆ create_and_check_castor_dirs()

def cmsHarvester.create_and_check_castor_dirs (   self)
Make sure all required CASTOR output dirs exist.

This checks the CASTOR base dir specified by the user as well
as all the subdirs required by the current set of jobs.

Definition at line 1432 of file cmsHarvester.py.

1432  def create_and_check_castor_dirs(self):
1433  """Make sure all required CASTOR output dirs exist.
1434 
1435  This checks the CASTOR base dir specified by the user as well
1436  as all the subdirs required by the current set of jobs.
1437 
1438  """
1439 
1440  self.logger.info("Checking (and if necessary creating) CASTOR " \
1441  "output area(s)...")
1442 
1443  # Call the real checker method for the base dir.
1444  self.create_and_check_castor_dir(self.castor_base_dir)
1445 
1446  # Now call the checker for all (unique) subdirs.
1447  castor_dirs = []
1448  for (dataset_name, runs) in six.iteritems(self.datasets_to_use):
1449 
1450  for run in runs:
1451  castor_dirs.append(self.datasets_information[dataset_name] \
1452  ["castor_path"][run])
1453  castor_dirs_unique = sorted(set(castor_dirs))
1454  # This can take some time. E.g. CRAFT08 has > 300 runs, each
1455  # of which will get a new directory. So we show some (rough)
1456  # info in between.
1457  ndirs = len(castor_dirs_unique)
1458  step = max(ndirs / 10, 1)
1459  for (i, castor_dir) in enumerate(castor_dirs_unique):
1460  if (i + 1) % step == 0 or \
1461  (i + 1) == ndirs:
1462  self.logger.info(" %d/%d" % \
1463  (i + 1, ndirs))
1464  self.create_and_check_castor_dir(castor_dir)
1465 
1466  # Now check if the directory is empty. If (an old version
1467  # of) the output file already exists CRAB will run new
1468  # jobs but never copy the results back. We assume the user
1469  # knows what they are doing and only issue a warning in
1470  # case the directory is not empty.
1471  self.logger.debug("Checking if path `%s' is empty" % \
1472  castor_dir)
1473  cmd = "rfdir %s" % castor_dir
1474  (status, output) = commands.getstatusoutput(cmd)
1475  if status != 0:
1476  msg = "Could not access directory `%s'" \
1477  " !!! This is bad since I should have just" \
1478  " created it !!!" % castor_dir
1479  self.logger.fatal(msg)
1480  raise Error(msg)
1481  if len(output) > 0:
1482  self.logger.warning("Output directory `%s' is not empty:" \
1483  " new jobs will fail to" \
1484  " copy back output" % \
1485  castor_dir)
1486 
1487  # End of create_and_check_castor_dirs.
1488 

References debug, info(), SiStripPI.max, and MessageLogger_cfi.warning.

◆ create_castor_path_name_common()

def cmsHarvester.create_castor_path_name_common (   self,
  dataset_name 
)
Build the common part of the output path to be used on
CASTOR.

This consists of the CASTOR area base path specified by the
user and a piece depending on the data type (data vs. MC), the
harvesting type and the dataset name followed by a piece
containing the run number and event count. (See comments in
create_castor_path_name_special for details.) This method
creates the common part, without run number and event count.

Definition at line 1328 of file cmsHarvester.py.

1328  def create_castor_path_name_common(self, dataset_name):
1329  """Build the common part of the output path to be used on
1330  CASTOR.
1331 
1332  This consists of the CASTOR area base path specified by the
1333  user and a piece depending on the data type (data vs. MC), the
1334  harvesting type and the dataset name followed by a piece
1335  containing the run number and event count. (See comments in
1336  create_castor_path_name_special for details.) This method
1337  creates the common part, without run number and event count.
1338 
1339  """
1340 
1341  castor_path = self.castor_base_dir
1342 
1343 
1344 
1345  # The data type: data vs. mc.
1346  datatype = self.datasets_information[dataset_name]["datatype"]
1347  datatype = datatype.lower()
1348  castor_path = os.path.join(castor_path, datatype)
1349 
1350  # The harvesting type.
1351  harvesting_type = self.harvesting_type
1352  harvesting_type = harvesting_type.lower()
1353  castor_path = os.path.join(castor_path, harvesting_type)
1354 
1355  # The CMSSW release version (only the `digits'). Note that the
1356  # CMSSW version used here is the version used for harvesting,
1357  # not the one from the dataset. This does make the results
1358  # slightly harder to find. On the other hand it solves
1359  # problems in case one re-harvests a given dataset with a
1360  # different CMSSW version, which would lead to ambiguous path
1361  # names. (Of course for many cases the harvesting is done with
1362  # the same CMSSW version the dataset was created with.)
1363  release_version = self.cmssw_version
1364  release_version = release_version.lower(). \
1365  replace("cmssw", ""). \
1366  strip("_")
1367  castor_path = os.path.join(castor_path, release_version)
1368 
1369  # The dataset name.
1370  dataset_name_escaped = self.escape_dataset_name(dataset_name)
1371  castor_path = os.path.join(castor_path, dataset_name_escaped)
1372 
1373 
1374 
1375  castor_path = os.path.normpath(castor_path)
1376 
1377  # End of create_castor_path_name_common.
1378  return castor_path
1379 

References python.rootplot.root2matplotlib.replace(), and digitizers_cfi.strip.

◆ create_castor_path_name_special()

def cmsHarvester.create_castor_path_name_special (   self,
  dataset_name,
  run_number,
  castor_path_common 
)
Create the specialised part of the CASTOR output dir name.

NOTE: To avoid clashes with `incremental harvesting'
(re-harvesting when a dataset grows) we have to include the
event count in the path name. The underlying `problem' is that
CRAB does not overwrite existing output files so if the output
file already exists CRAB will fail to copy back the output.

NOTE: It's not possible to create different kinds of
harvesting jobs in a single call to this tool. However, in
principle it could be possible to create both data and MC jobs
in a single go.

NOTE: The number of events used in the path name is the
_total_ number of events in the dataset/run at the time of
harvesting. If we're doing partial harvesting the final
results will reflect lower statistics. This is a) the easiest
to code and b) the least likely to lead to confusion if
someone ever decides to swap/copy around file blocks between
sites.

Definition at line 1382 of file cmsHarvester.py.

1383  dataset_name, run_number,
1384  castor_path_common):
1385  """Create the specialised part of the CASTOR output dir name.
1386 
1387  NOTE: To avoid clashes with `incremental harvesting'
1388  (re-harvesting when a dataset grows) we have to include the
1389  event count in the path name. The underlying `problem' is that
1390  CRAB does not overwrite existing output files so if the output
1391  file already exists CRAB will fail to copy back the output.
1392 
1393  NOTE: It's not possible to create different kinds of
1394  harvesting jobs in a single call to this tool. However, in
1395  principle it could be possible to create both data and MC jobs
1396  in a single go.
1397 
1398  NOTE: The number of events used in the path name is the
1399  _total_ number of events in the dataset/run at the time of
1400  harvesting. If we're doing partial harvesting the final
1401  results will reflect lower statistics. This is a) the easiest
1402  to code and b) the least likely to lead to confusion if
1403  someone ever decides to swap/copy around file blocks between
1404  sites.
1405 
1406  """
1407 
1408  castor_path = castor_path_common
1409 
1410 
1411 
1412  # The run number part.
1413  castor_path = os.path.join(castor_path, "run_%d" % run_number)
1414 
1415 
1416 
1417  # The event count (i.e. the number of events we currently see
1418  # for this dataset).
1419  #nevents = self.datasets_information[dataset_name] \
1420  # ["num_events"][run_number]
1421  castor_path = os.path.join(castor_path, "nevents")
1422 
1423 
1424 
1425  castor_path = os.path.normpath(castor_path)
1426 
1427  # End of create_castor_path_name_special.
1428  return castor_path
1429 

◆ create_config_file_name()

def cmsHarvester.create_config_file_name (   self,
  dataset_name,
  run_number 
)
Generate the name of the configuration file to be run by
CRAB.

Depending on the harvesting mode (single-step or two-step)
this is the name of the real harvesting configuration or the
name of the first-step ME summary extraction configuration.

Definition at line 4065 of file cmsHarvester.py.

4065  def create_config_file_name(self, dataset_name, run_number):
4066  """Generate the name of the configuration file to be run by
4067  CRAB.
4068 
4069  Depending on the harvesting mode (single-step or two-step)
4070  this is the name of the real harvesting configuration or the
4071  name of the first-step ME summary extraction configuration.
4072 
4073  """
4074 
4075  if self.harvesting_mode == "single-step":
4076  config_file_name = self.create_harvesting_config_file_name(dataset_name)
4077  elif self.harvesting_mode == "single-step-allow-partial":
4078  config_file_name = self.create_harvesting_config_file_name(dataset_name)

Referenced by create_multicrab_config().

◆ create_crab_config()

def cmsHarvester.create_crab_config (   self)
Create a CRAB configuration for a given job.

NOTE: This is _not_ a complete (as in: submittable) CRAB
configuration. It is used to store the common settings for the
multicrab configuration.

NOTE: Only CERN CASTOR area (/castor/cern.ch/) is supported.

NOTE: According to CRAB, you `Must define exactly two of
total_number_of_events, events_per_job, or
number_of_jobs.'. For single-step harvesting we force one job,
for the rest we don't really care.

# BUG BUG BUG
# With the current version of CRAB (2.6.1), in which Daniele
# fixed the behaviour of no_block_boundary for me, one _has to
# specify_ the total_number_of_events and one single site in
# the se_white_list.
# BUG BUG BUG end

Definition at line 4233 of file cmsHarvester.py.

4233  def create_crab_config(self):
4234  """Create a CRAB configuration for a given job.
4235 
4236  NOTE: This is _not_ a complete (as in: submittable) CRAB
4237  configuration. It is used to store the common settings for the
4238  multicrab configuration.
4239 
4240  NOTE: Only CERN CASTOR area (/castor/cern.ch/) is supported.
4241 
4242  NOTE: According to CRAB, you `Must define exactly two of
4243  total_number_of_events, events_per_job, or
4244  number_of_jobs.'. For single-step harvesting we force one job,
4245  for the rest we don't really care.
4246 
4247  # BUG BUG BUG
4248  # With the current version of CRAB (2.6.1), in which Daniele
4249  # fixed the behaviour of no_block_boundary for me, one _has to
4250  # specify_ the total_number_of_events and one single site in
4251  # the se_white_list.
4252  # BUG BUG BUG end
4253 
4254  """
4255 
4256  tmp = []
4257 
4258  # This is the stuff we will need to fill in.
4259  castor_prefix = self.castor_prefix
4260 
4261  tmp.append(self.config_file_header())
4262  tmp.append("")
4263 
4264 
4266  tmp.append("[CRAB]")
4267  tmp.append("jobtype = cmssw")
4268  tmp.append("")
4269 
4270 
4272  tmp.append("[GRID]")
4273  tmp.append("virtual_organization=cms")
4274  tmp.append("")
4275 
4276 
4278  tmp.append("[USER]")
4279  tmp.append("copy_data = 1")
4280  tmp.append("")
4281 
4282 
4284  tmp.append("[CMSSW]")
4285  tmp.append("# This reveals data hosted on T1 sites,")
4286  tmp.append("# which is normally hidden by CRAB.")
4287  tmp.append("show_prod = 1")
4288  tmp.append("number_of_jobs = 1")
4289  if self.Jsonlumi == True:
4290  tmp.append("lumi_mask = %s" % self.Jsonfilename)
4291  tmp.append("total_number_of_lumis = -1")
4292  else:
4293  if self.harvesting_type == "DQMOffline":
4294  tmp.append("total_number_of_lumis = -1")
4295  else:
4296  tmp.append("total_number_of_events = -1")
4297  if self.harvesting_mode.find("single-step") > -1:
4298  tmp.append("# Force everything to run in one job.")
4299  tmp.append("no_block_boundary = 1")
4300  tmp.append("")
4301 
4302 
4304  tmp.append("[CAF]")
4305 
4306  crab_config = "\n".join(tmp)
4307 
4308  # End of create_crab_config.
4309  return crab_config
4310 

References spr.find(), and join().

◆ create_es_prefer_snippet()

def cmsHarvester.create_es_prefer_snippet (   self,
  dataset_name 
)
Build the es_prefer snippet for the reference histograms.

The building of the snippet is wrapped in some care-taking
code that figures out the name of the reference histogram set
and makes sure the corresponding tag exists.

Definition at line 4689 of file cmsHarvester.py.

4689  def create_es_prefer_snippet(self, dataset_name):
4690  """Build the es_prefer snippet for the reference histograms.
4691 
4692  The building of the snippet is wrapped in some care-taking
4693  code that figures out the name of the reference histogram set
4694  and makes sure the corresponding tag exists.
4695 
4696  """
4697 
4698  # Figure out the name of the reference histograms tag.
4699  # NOTE: The existence of these tags has already been checked.
4700  ref_hist_tag_name = self.ref_hist_mappings[dataset_name]
4701 
4702  connect_name = self.frontier_connection_name["refhists"]
4703  connect_name += self.db_account_name_cms_cond_dqm_summary()
4704  record_name = "DQMReferenceHistogramRootFileRcd"
4705 
4706  # Build up the code snippet.
4707  code_lines = []
4708  code_lines.append("from CondCore.DBCommon.CondDBSetup_cfi import *")
4709  code_lines.append("process.ref_hist_source = cms.ESSource(\"PoolDBESSource\", CondDBSetup,")
4710  code_lines.append(" connect = cms.string(\"%s\")," % connect_name)
4711  code_lines.append(" toGet = cms.VPSet(cms.PSet(record = cms.string(\"%s\")," % record_name)
4712  code_lines.append(" tag = cms.string(\"%s\"))," % ref_hist_tag_name)
4713  code_lines.append(" )")
4714  code_lines.append(" )")
4715  code_lines.append("process.es_prefer_ref_hist_source = cms.ESPrefer(\"PoolDBESSource\", \"ref_hist_source\")")
4716 
4717  snippet = "\n".join(code_lines)
4718 
4719  # End of create_es_prefer_snippet.
4720  return snippet
4721 

References join().

◆ create_harvesting_config()

def cmsHarvester.create_harvesting_config (   self,
  dataset_name 
)
Create the Python harvesting configuration for harvesting.

The basic configuration is created by
Configuration.PyReleaseValidation.ConfigBuilder. (This mimics
what cmsDriver.py does.) After that we add some specials
ourselves.

NOTE: On one hand it may not be nice to circumvent
cmsDriver.py, on the other hand cmsDriver.py does not really
do anything itself. All the real work is done by the
ConfigBuilder so there is not much risk that we miss out on
essential developments of cmsDriver in the future.

Definition at line 4724 of file cmsHarvester.py.

4724  def create_harvesting_config(self, dataset_name):
4725  """Create the Python harvesting configuration for harvesting.
4726 
4727  The basic configuration is created by
4728  Configuration.PyReleaseValidation.ConfigBuilder. (This mimics
4729  what cmsDriver.py does.) After that we add some specials
4730  ourselves.
4731 
4732  NOTE: On one hand it may not be nice to circumvent
4733  cmsDriver.py, on the other hand cmsDriver.py does not really
4734  do anything itself. All the real work is done by the
4735  ConfigBuilder so there is not much risk that we miss out on
4736  essential developments of cmsDriver in the future.
4737 
4738  """
4739 
4740  # Setup some options needed by the ConfigBuilder.
4741  config_options = defaultOptions
4742 
4743  # These are fixed for all kinds of harvesting jobs. Some of
4744  # them are not needed for the harvesting config, but to keep
4745  # the ConfigBuilder happy.
4746  config_options.name = "harvesting"
4747  config_options.scenario = "pp"
4748  config_options.number = 1
4749  config_options.arguments = self.ident_string()
4750  config_options.evt_type = config_options.name
4751  config_options.customisation_file = None
4752  config_options.filein = "dummy_value"
4753  config_options.filetype = "EDM"
4754  # This seems to be new in CMSSW 3.3.X, no clue what it does.
4755  config_options.gflash = "dummy_value"
4756  # This seems to be new in CMSSW 3.3.0.pre6, no clue what it
4757  # does.
4758  #config_options.himix = "dummy_value"
4759  config_options.dbsquery = ""
4760 
4761 
4762 
4763  # These options depend on the type of harvesting we're doing
4764  # and are stored in self.harvesting_info.
4765 
4766  config_options.step = "HARVESTING:%s" % \
4767  self.harvesting_info[self.harvesting_type] \
4768  ["step_string"]
4769  config_options.beamspot = self.harvesting_info[self.harvesting_type] \
4770  ["beamspot"]
4771  config_options.eventcontent = self.harvesting_info \
4772  [self.harvesting_type] \
4773  ["eventcontent"]
4774  config_options.harvesting = self.harvesting_info \
4775  [self.harvesting_type] \
4776  ["harvesting"]
4777 
4778 
4779 
4780  # This one is required (see also above) for each dataset.
4781 
4782  datatype = self.datasets_information[dataset_name]["datatype"]
4783  config_options.isMC = (datatype.lower() == "mc")
4784  config_options.isData = (datatype.lower() == "data")
4785  globaltag = self.datasets_information[dataset_name]["globaltag"]
4786 
4787  config_options.conditions = self.format_conditions_string(globaltag)
4788 
4789 
4790 
4791  if "with_input" in getargspec(ConfigBuilder.__init__)[0]:
4792  # This is the case for 3.3.X.
4793  config_builder = ConfigBuilder(config_options, with_input=True)
4794  else:
4795  # This is the case in older CMSSW versions.
4796  config_builder = ConfigBuilder(config_options)
4797  config_builder.prepare(True)
4798  config_contents = config_builder.pythonCfgCode
4799 
4800 
4801 
4802  # Add our signature to the top of the configuration. and add
4803  # some markers to the head and the tail of the Python code
4804  # generated by the ConfigBuilder.
4805  marker_lines = []
4806  sep = "#" * 30
4807  marker_lines.append(sep)
4808  marker_lines.append("# Code between these markers was generated by")
4809  marker_lines.append("# Configuration.PyReleaseValidation." \
4810  "ConfigBuilder")
4811 
4812  marker_lines.append(sep)
4813  marker = "\n".join(marker_lines)
4814 
4815  tmp = [self.config_file_header()]
4816  tmp.append("")
4817  tmp.append(marker)
4818  tmp.append("")
4819  tmp.append(config_contents)
4820  tmp.append("")
4821  tmp.append(marker)
4822  tmp.append("")
4823  config_contents = "\n".join(tmp)
4824 
4825 
4826 
4827  # Now we add some stuff of our own.
4828  customisations = [""]
4829 
4830  customisations.append("# Now follow some customisations")
4831  customisations.append("")
4832  connect_name = self.frontier_connection_name["globaltag"]
4833  connect_name += self.db_account_name_cms_cond_globaltag()
4834  customisations.append("process.GlobalTag.connect = \"%s\"" % \
4835  connect_name)
4836 
4837 
4838  if self.saveByLumiSection == True:
4839  customisations.append("process.dqmSaver.saveByLumiSection = 1")
4840 
4842 
4843  customisations.append("")
4844 
4845  # About the reference histograms... For data there is only one
4846  # set of references and those are picked up automatically
4847  # based on the GlobalTag. For MC we have to do some more work
4848  # since the reference histograms to be used depend on the MC
4849  # sample at hand. In this case we glue in an es_prefer snippet
4850  # to pick up the references. We do this only for RelVals since
4851  # for MC there are no meaningful references so far.
4852 
4853  # NOTE: Due to the lack of meaningful references for
4854  # MC samples reference histograms are explicitly
4855  # switched off in this case.
4856 
4857  use_es_prefer = (self.harvesting_type == "RelVal")
4858  use_refs = use_es_prefer or \
4859  (not self.harvesting_type == "MC")
4860  # Allow global override.
4861  use_refs = use_refs and self.use_ref_hists
4862 
4863  if not use_refs:
4864  # Disable reference histograms explicitly. The histograms
4865  # are loaded by the dqmRefHistoRootFileGetter
4866  # EDAnalyzer. This analyzer can be run from several
4867  # sequences. Here we remove it from each sequence that
4868  # exists.
4869  customisations.append("print \"Not using reference histograms\"")
4870  customisations.append("if hasattr(process, \"dqmRefHistoRootFileGetter\"):")
4871  customisations.append(" for (sequence_name, sequence) in six.iteritems(process.sequences):")
4872  customisations.append(" if sequence.remove(process.dqmRefHistoRootFileGetter):")
4873  customisations.append(" print \"Removed process.dqmRefHistoRootFileGetter from sequence `%s'\" % \\")
4874  customisations.append(" sequence_name")
4875  customisations.append("process.dqmSaver.referenceHandling = \"skip\"")
4876  else:
4877  # This makes sure all reference histograms are saved to
4878  # the output ROOT file.
4879  customisations.append("process.dqmSaver.referenceHandling = \"all\"")
4880  if use_es_prefer:
4881  es_prefer_snippet = self.create_es_prefer_snippet(dataset_name)
4882  customisations.append(es_prefer_snippet)
4883 
4884  # Make sure we get the `workflow' correct. As far as I can see
4885  # this is only important for the output file name.
4886  workflow_name = dataset_name
4887  if self.harvesting_mode == "single-step-allow-partial":
4888  workflow_name += "_partial"
4889  customisations.append("process.dqmSaver.workflow = \"%s\"" % \
4890  workflow_name)
4891 
4892  # BUG BUG BUG
4893  # This still does not work. The current two-step harvesting
4894  # efforts are on hold waiting for the solution to come from
4895  # elsewhere. (In this case the elsewhere is Daniele Spiga.)
4896 

References join().

◆ create_harvesting_config_file_name()

def cmsHarvester.create_harvesting_config_file_name (   self,
  dataset_name 
)

Definition at line 4097 of file cmsHarvester.py.

4097  def create_harvesting_config_file_name(self, dataset_name):
4098  "Generate the name to be used for the harvesting config file."
4099 
4100  file_name_base = "harvesting.py"
4101  dataset_name_escaped = self.escape_dataset_name(dataset_name)
4102  config_file_name = file_name_base.replace(".py",
4103  "_%s.py" % \
4104  dataset_name_escaped)
4105 
4106  # End of create_harvesting_config_file_name.
4107  return config_file_name
4108 

Referenced by write_harvesting_config().

◆ create_harvesting_output_file_name()

def cmsHarvester.create_harvesting_output_file_name (   self,
  dataset_name,
  run_number 
)
Generate the name to be used for the harvesting output file.

This harvesting output file is the _final_ ROOT output file
containing the harvesting results. In case of two-step
harvesting there is an intermediate ME output file as well.

Definition at line 4169 of file cmsHarvester.py.

4169  def create_harvesting_output_file_name(self, dataset_name, run_number):
4170  """Generate the name to be used for the harvesting output file.
4171 
4172  This harvesting output file is the _final_ ROOT output file
4173  containing the harvesting results. In case of two-step
4174  harvesting there is an intermediate ME output file as well.
4175 
4176  """
4177 
4178  dataset_name_escaped = self.escape_dataset_name(dataset_name)
4179 
4180  # Hmmm, looking at the code for the DQMFileSaver this might
4181  # actually be the place where the first part of this file
4182  # naming scheme comes from.
4183  # NOTE: It looks like the `V0001' comes from the DQM
4184  # version. This is something that cannot be looked up from
4185  # here, so let's hope it does not change too often.
4186  output_file_name = "DQM_V0001_R%09d__%s.root" % \
4187  (run_number, dataset_name_escaped)
4188  if self.harvesting_mode.find("partial") > -1:
4189  # Only add the alarming piece to the file name if this is
4190  # a spread-out dataset.
4191  if self.datasets_information[dataset_name] \
4192  ["mirrored"][run_number] == False:
4193  output_file_name = output_file_name.replace(".root", \
4194  "_partial.root")
4195 
4196  # End of create_harvesting_output_file_name.
4197  return output_file_name
4198 

References spr.find().

◆ create_me_extraction_config()

def cmsHarvester.create_me_extraction_config (   self,
  dataset_name 
)

def create_harvesting_config_two_step(self, dataset_name): """Create the Python harvesting configuration for two-step harvesting.

"""

BUG BUG BUG

config_contents = self.create_harvesting_config_single_step(dataset_name)

BUG BUG BUG end

End of create_harvesting_config_two_step.

return config_contents

 

Definition at line 4950 of file cmsHarvester.py.

4950  def create_me_extraction_config(self, dataset_name):
4951  """
4952 
4953  """
4954 
4955  # Big chunk of hard-coded Python. Not such a big deal since
4956  # this does not do much and is not likely to break.
4957  tmp = []
4958  tmp.append(self.config_file_header())
4959  tmp.append("")
4960  tmp.append("import FWCore.ParameterSet.Config as cms")
4961  tmp.append("")
4962  tmp.append("process = cms.Process(\"ME2EDM\")")
4963  tmp.append("")
4964  tmp.append("# Import of standard configurations")
4965  tmp.append("process.load(\"Configuration/EventContent/EventContent_cff\")")
4966  tmp.append("")
4967  tmp.append("# We don't really process any events, just keep this set to one to")
4968  tmp.append("# make sure things work.")
4969  tmp.append("process.maxEvents = cms.untracked.PSet(")
4970  tmp.append(" input = cms.untracked.int32(1)")
4971  tmp.append(" )")
4972  tmp.append("")
4973  tmp.append("process.options = cms.untracked.PSet(")
4974  tmp.append(" Rethrow = cms.untracked.vstring(\"ProductNotFound\")")
4975  tmp.append(" )")
4976  tmp.append("")
4977  tmp.append("process.source = cms.Source(\"PoolSource\",")
4978  tmp.append(" processingMode = \\")
4979  tmp.append(" cms.untracked.string(\"RunsAndLumis\"),")
4980  tmp.append(" fileNames = \\")
4981  tmp.append(" cms.untracked.vstring(\"no_file_specified\")")
4982  tmp.append(" )")
4983  tmp.append("")
4984  tmp.append("# Output definition: drop everything except for the monitoring.")
4985  tmp.append("process.output = cms.OutputModule(")
4986  tmp.append(" \"PoolOutputModule\",")
4987  tmp.append(" outputCommands = \\")
4988  tmp.append(" cms.untracked.vstring(\"drop *\", \\")
4989  tmp.append(" \"keep *_MEtoEDMConverter_*_*\"),")
4990  output_file_name = self. \
4991  create_output_file_name(dataset_name)
4992  tmp.append(" fileName = \\")
4993  tmp.append(" cms.untracked.string(\"%s\")," % output_file_name)
4994  tmp.append(" dataset = cms.untracked.PSet(")
4995  tmp.append(" dataTier = cms.untracked.string(\"RECO\"),")
4996  tmp.append(" filterName = cms.untracked.string(\"\")")
4997  tmp.append(" )")
4998  tmp.append(" )")
4999  tmp.append("")
5000  tmp.append("# Additional output definition")
5001  tmp.append("process.out_step = cms.EndPath(process.output)")
5002  tmp.append("")
5003  tmp.append("# Schedule definition")
5004  tmp.append("process.schedule = cms.Schedule(process.out_step)")
5005  tmp.append("")
5006 
5007  config_contents = "\n".join(tmp)
5008 
5009  # End of create_me_extraction_config.
5010  return config_contents
5011 

References create_output_file_name(), and join().

◆ create_me_summary_config_file_name()

def cmsHarvester.create_me_summary_config_file_name (   self,
  dataset_name 
)

Definition at line 4111 of file cmsHarvester.py.

4111  def create_me_summary_config_file_name(self, dataset_name):
4112  "Generate the name of the ME summary extraction config file."
4113 
4114  file_name_base = "me_extraction.py"
4115  dataset_name_escaped = self.escape_dataset_name(dataset_name)
4116  config_file_name = file_name_base.replace(".py",
4117  "_%s.py" % \
4118  dataset_name_escaped)
4119 
4120  # End of create_me_summary_config_file_name.
4121  return config_file_name
4122 

Referenced by write_me_extraction_config().

◆ create_me_summary_output_file_name()

def cmsHarvester.create_me_summary_output_file_name (   self,
  dataset_name 
)
Generate the name of the intermediate ME file name to be
used in two-step harvesting.

Definition at line 4201 of file cmsHarvester.py.

4201  def create_me_summary_output_file_name(self, dataset_name):
4202  """Generate the name of the intermediate ME file name to be
4203  used in two-step harvesting.
4204 
4205  """
4206 
4207  dataset_name_escaped = self.escape_dataset_name(dataset_name)
4208  output_file_name = "me_summary_%s.root" % \
4209  dataset_name_escaped
4210 
4211  # End of create_me_summary_output_file_name.
4212  return output_file_name
4213 

◆ create_multicrab_block_name()

def cmsHarvester.create_multicrab_block_name (   self,
  dataset_name,
  run_number,
  index 
)
Create the block name to use for this dataset/run number.

This is what appears in the brackets `[]' in multicrab.cfg. It
is used as the name of the job and to create output
directories.

Definition at line 4216 of file cmsHarvester.py.

4216  def create_multicrab_block_name(self, dataset_name, run_number, index):
4217  """Create the block name to use for this dataset/run number.
4218 
4219  This is what appears in the brackets `[]' in multicrab.cfg. It
4220  is used as the name of the job and to create output
4221  directories.
4222 
4223  """
4224 
4225  dataset_name_escaped = self.escape_dataset_name(dataset_name)
4226  block_name = "%s_%09d_%s" % (dataset_name_escaped, run_number, index)
4227 
4228  # End of create_multicrab_block_name.
4229  return block_name
4230 

◆ create_multicrab_config()

def cmsHarvester.create_multicrab_config (   self)
Create a multicrab.cfg file for all samples.

This creates the contents for a multicrab.cfg file that uses
the crab.cfg file (generated elsewhere) for the basic settings
and contains blocks for each run of each dataset.

# BUG BUG BUG
# The fact that it's necessary to specify the se_white_list
# and the total_number_of_events is due to our use of CRAB
# version 2.6.1. This should no longer be necessary in the
# future.
# BUG BUG BUG end

Definition at line 4313 of file cmsHarvester.py.

4313  def create_multicrab_config(self):
4314  """Create a multicrab.cfg file for all samples.
4315 
4316  This creates the contents for a multicrab.cfg file that uses
4317  the crab.cfg file (generated elsewhere) for the basic settings
4318  and contains blocks for each run of each dataset.
4319 
4320  # BUG BUG BUG
4321  # The fact that it's necessary to specify the se_white_list
4322  # and the total_number_of_events is due to our use of CRAB
4323  # version 2.6.1. This should no longer be necessary in the
4324  # future.
4325  # BUG BUG BUG end
4326 
4327  """
4328 
4329  cmd="who i am | cut -f1 -d' '"
4330  (status, output)=commands.getstatusoutput(cmd)
4331  UserName = output
4332 
4333  if self.caf_access == True:
4334  print("Extracting %s as user name" %UserName)
4335 
4336  number_max_sites = self.nr_max_sites + 1
4337 
4338  multicrab_config_lines = []
4339  multicrab_config_lines.append(self.config_file_header())
4340  multicrab_config_lines.append("")
4341  multicrab_config_lines.append("[MULTICRAB]")
4342  multicrab_config_lines.append("cfg = crab.cfg")
4343  multicrab_config_lines.append("")
4344 
4345  dataset_names = sorted(self.datasets_to_use.keys())
4346 
4347  for dataset_name in dataset_names:
4348  runs = self.datasets_to_use[dataset_name]
4349  dataset_name_escaped = self.escape_dataset_name(dataset_name)
4350  castor_prefix = self.castor_prefix
4351 
4352  for run in runs:
4353 
4354  # CASTOR output dir.
4355  castor_dir = self.datasets_information[dataset_name] \
4356  ["castor_path"][run]
4357 
4358  cmd = "rfdir %s" % castor_dir
4359  (status, output) = commands.getstatusoutput(cmd)
4360 
4361  if len(output) <= 0:
4362 
4363  # DEBUG DEBUG DEBUG
4364  # We should only get here if we're treating a
4365  # dataset/run that is fully contained at a single
4366  # site.
4367  assert (len(self.datasets_information[dataset_name] \
4368  ["sites"][run]) == 1) or \
4369  self.datasets_information[dataset_name]["mirrored"]
4370  # DEBUG DEBUG DEBUG end
4371 
4372  site_names = self.datasets_information[dataset_name] \
4373  ["sites"][run].keys()
4374 
4375  for i in range(1, number_max_sites, 1):
4376  if len(site_names) > 0:
4377  index = "site_%02d" % (i)
4378 
4379  config_file_name = self. \
4380  create_config_file_name(dataset_name, run)
4381  output_file_name = self. \
4382  create_output_file_name(dataset_name, run)
4383 
4384 
4385  # If we're looking at a mirrored dataset we just pick
4386  # one of the sites. Otherwise there is nothing to
4387  # choose.
4388 
4389  # Loop variable
4390  loop = 0
4391 
4392  if len(site_names) > 1:
4393  cmssw_version = self.datasets_information[dataset_name] \
4394  ["cmssw_version"]
4395  self.logger.info("Picking site for mirrored dataset " \
4396  "`%s', run %d" % \
4397  (dataset_name, run))
4398  site_name = self.pick_a_site(site_names, cmssw_version)
4399  if site_name in site_names:
4400  site_names.remove(site_name)
4401 
4402  else:
4403  site_name = site_names[0]
4404  site_names.remove(site_name)
4405 
4406  if site_name is self.no_matching_site_found_str:
4407  if loop < 1:
4408  break
4409 
4410  nevents = self.datasets_information[dataset_name]["num_events"][run]
4411 
4412  # The block name.
4413  multicrab_block_name = self.create_multicrab_block_name( \
4414  dataset_name, run, index)
4415  multicrab_config_lines.append("[%s]" % \
4416  multicrab_block_name)
4417 
4418 
4420  if site_name == "caf.cern.ch":
4421  multicrab_config_lines.append("CRAB.use_server=0")
4422  multicrab_config_lines.append("CRAB.scheduler=caf")
4423  else:
4424  multicrab_config_lines.append("scheduler = glite")
4425 
4426 
4428  if site_name == "caf.cern.ch":
4429  pass
4430  else:
4431  multicrab_config_lines.append("GRID.se_white_list = %s" % \
4432  site_name)
4433  multicrab_config_lines.append("# This removes the default blacklisting of T1 sites.")
4434  multicrab_config_lines.append("GRID.remove_default_blacklist = 1")
4435  multicrab_config_lines.append("GRID.rb = CERN")
4436  if not self.non_t1access:
4437  multicrab_config_lines.append("GRID.role = t1access")
4438 
4439 
4441 
4442  castor_dir = castor_dir.replace(castor_prefix, "")
4443  multicrab_config_lines.append("USER.storage_element=srm-cms.cern.ch")
4444  multicrab_config_lines.append("USER.user_remote_dir = %s" % \
4445  castor_dir)
4446  multicrab_config_lines.append("USER.check_user_remote_dir=0")
4447 
4448  if site_name == "caf.cern.ch":
4449  multicrab_config_lines.append("USER.storage_path=%s" % castor_prefix)
4450  #multicrab_config_lines.append("USER.storage_element=T2_CH_CAF")
4451  #castor_dir = castor_dir.replace("/cms/store/caf/user/%s" %UserName, "")
4452  #multicrab_config_lines.append("USER.user_remote_dir = %s" % \
4453  # castor_dir)
4454  else:
4455  multicrab_config_lines.append("USER.storage_path=/srm/managerv2?SFN=%s" % castor_prefix)
4456  #multicrab_config_lines.append("USER.user_remote_dir = %s" % \
4457  # castor_dir)
4458  #multicrab_config_lines.append("USER.storage_element=srm-cms.cern.ch")
4459 
4460 
4462  multicrab_config_lines.append("CMSSW.pset = %s" % \
4463  config_file_name)
4464  multicrab_config_lines.append("CMSSW.datasetpath = %s" % \
4465  dataset_name)
4466  multicrab_config_lines.append("CMSSW.runselection = %d" % \
4467  run)
4468 
4469  if self.Jsonlumi == True:
4470  pass
4471  else:
4472  if self.harvesting_type == "DQMOffline":
4473  pass
4474  else:
4475  multicrab_config_lines.append("CMSSW.total_number_of_events = %d" % \
4476  nevents)
4477  # The output file name.
4478  multicrab_config_lines.append("CMSSW.output_file = %s" % \
4479  output_file_name)
4480 
4481 
4483  if site_name == "caf.cern.ch":
4484  multicrab_config_lines.append("CAF.queue=cmscaf1nd")
4485 
4486 
4487  # End of block.
4488  multicrab_config_lines.append("")
4489 
4490  loop = loop + 1
4491 
4492  self.all_sites_found = True
4493 
4494  multicrab_config = "\n".join(multicrab_config_lines)
4495 
4496  # End of create_multicrab_config.
4497  return multicrab_config
4498 

References create_config_file_name(), create_output_file_name(), info(), join(), relativeConstraints.keys, edm.print(), and FastTimerService_cff.range.

◆ create_output_file_name()

def cmsHarvester.create_output_file_name (   self,
  dataset_name,
  run_number = None 
)
Create the name of the output file name to be used.

This is the name of the output file of the `first step'. In
the case of single-step harvesting this is already the final
harvesting output ROOT file. In the case of two-step
harvesting it is the name of the intermediary ME summary
file.

Definition at line 4125 of file cmsHarvester.py.

4125  def create_output_file_name(self, dataset_name, run_number=None):
4126  """Create the name of the output file name to be used.
4127 
4128  This is the name of the output file of the `first step'. In
4129  the case of single-step harvesting this is already the final
4130  harvesting output ROOT file. In the case of two-step
4131  harvesting it is the name of the intermediary ME summary
4132  file.
4133 
4134  """
4135 
4136  # BUG BUG BUG
4137  # This method has become a bit of a mess. Originally it was
4138  # nice to have one entry point for both single- and two-step
4139  # output file names. However, now the former needs the run
4140  # number, while the latter does not even know about run
4141  # numbers. This should be fixed up a bit.
4142  # BUG BUG BUG end
4143 
4144  if self.harvesting_mode == "single-step":
4145  # DEBUG DEBUG DEBUG
4146  assert not run_number is None
4147  # DEBUG DEBUG DEBUG end
4148  output_file_name = self.create_harvesting_output_file_name(dataset_name, run_number)
4149  elif self.harvesting_mode == "single-step-allow-partial":
4150  # DEBUG DEBUG DEBUG
4151  assert not run_number is None
4152  # DEBUG DEBUG DEBUG end
4153  output_file_name = self.create_harvesting_output_file_name(dataset_name, run_number)
4154  elif self.harvesting_mode == "two-step":
4155  # DEBUG DEBUG DEBUG
4156  assert run_number is None
4157  # DEBUG DEBUG DEBUG end
4158  output_file_name = self.create_me_summary_output_file_name(dataset_name)
4159  else:
4160  # This should not be possible, but hey...
4161  assert False, "ERROR Unknown harvesting mode `%s'" % \
4162  self.harvesting_mode
4163 
4164  # End of create_harvesting_output_file_name.
4165  return output_file_name
4166 

Referenced by create_me_extraction_config(), and create_multicrab_config().

◆ dbs_check_dataset_spread()

def cmsHarvester.dbs_check_dataset_spread (   self,
  dataset_name 
)

def dbs_resolve_dataset_number_of_sites(self, dataset_name): """Ask DBS across how many sites this dataset has been spread out.

This is especially useful to check that we do not submit a job supposed to run on a complete sample that is not contained at a single site. """

DEBUG DEBUG DEBUG

If we get here DBS should have been set up already.

assert not self.dbs_api is None

DEBUG DEBUG DEBUG end

api = self.dbs_api dbs_query = "find count(site) where dataset = %s " \ "and dataset.status = VALID" % \ dataset_name try: api_result = api.executeQuery(dbs_query) except DbsApiException: raise Error("ERROR: Could not execute DBS query") try: num_sites = [] class Handler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): if name == "result": num_sites.append(str(attrs["COUNT_STORAGEELEMENT"])) xml.sax.parseString(api_result, Handler()) except SAXParseException: raise Error("ERROR: Could not parse DBS server output")

DEBUG DEBUG DEBUG

assert len(num_sites) == 1

DEBUG DEBUG DEBUG end

num_sites = int(num_sites[0])

End of dbs_resolve_dataset_number_of_sites.

return num_sites def dbs_check_dataset_spread(self, dataset_name): """Figure out across how many sites this dataset is spread. NOTE: This is something we need to figure out per run, since we want to submit harvesting jobs per run. Basically three things can happen with a given dataset:

  • the whole dataset is available on a single site,
  • the whole dataset is available (mirrored) at multiple sites,
  • the dataset is spread across multiple sites and there is no single site containing the full dataset in one place. NOTE: If all goes well, it should not be possible that anything but a full dataset is mirrored. So we ignore the possibility in which for example one site contains the full dataset and two others mirror half of it. ANOTHER NOTE: According to some people this last case could actually happen. I will not design for it, but make sure it ends up as a false negative, in which case we just loose some efficiency and treat the dataset (unnecessarily) as spread-out. We don't really care about the first two possibilities, but in the third case we need to make sure to run the harvesting in two-step mode. This method checks with DBS which of the above cases is true for the dataset name given, and returns a 1 for the first two cases, and the number of sites across which the dataset is spread for the third case. The way in which this is done is by asking how many files each site has for the dataset. In the first case there is only one site, in the second case all sites should have the same number of files (i.e. the total number of files in the dataset) and in the third case the file counts from all sites should add up to the total file count for the dataset. """

DEBUG DEBUG DEBUG

If we get here DBS should have been set up already.

assert not self.dbs_api is None

DEBUG DEBUG DEBUG end

api = self.dbs_api dbs_query = "find run, run.numevents, site, file.count " \ "where dataset = %s " \ "and dataset.status = VALID" % \ dataset_name try: api_result = api.executeQuery(dbs_query) except DbsApiException: msg = "ERROR: Could not execute DBS query" self.logger.fatal(msg) raise Error(msg)

Index things by run number. No cross-check is done to make

sure we get results for each and every run in the

dataset. I'm not sure this would make sense since we'd be

cross-checking DBS info with DBS info anyway. Note that we

use the file count per site to see if we're dealing with an

incomplete vs. a mirrored dataset.

sample_info = {} try: class Handler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): if name == "result": run_number = int(attrs["RUNS_RUNNUMBER"]) site_name = str(attrs["STORAGEELEMENT_SENAME"]) file_count = int(attrs["COUNT_FILES"])

BUG BUG BUG

Doh! For some reason DBS never returns any other

event count than zero.

event_count = int(attrs["RUNS_NUMBEROFEVENTS"])

BUG BUG BUG end

info = (site_name, file_count, event_count) try: sample_info[run_number].append(info) except KeyError: sample_info[run_number] = [info] xml.sax.parseString(api_result, Handler()) except SAXParseException: msg = "ERROR: Could not parse DBS server output" self.logger.fatal(msg) raise Error(msg)

Now translate this into a slightly more usable mapping.

sites = {} for (run_number, site_info) in six.iteritems(sample_info):

Quick-n-dirty trick to see if all file counts are the

same.

unique_file_counts = set([i[1] for i in site_info]) if len(unique_file_counts) == 1:

Okay, so this must be a mirrored dataset.

We have to pick one but we have to be careful. We

cannot submit to things like a T0, a T1, or CAF.

site_names = [self.pick_a_site([i[0] for i in site_info])] nevents = [site_info[0][2]] else:

Looks like this is a spread-out sample.

site_names = [i[0] for i in site_info] nevents = [i[2] for i in site_info] sites[run_number] = zip(site_names, nevents) self.logger.debug("Sample `%s' spread is:" % dataset_name) run_numbers = sites.keys() run_numbers.sort() for run_number in run_numbers: self.logger.debug(" run # %6d: %d sites (%s)" % \ (run_number, len(sites[run_number]), ", ".join([i[0] for i in sites[run_number]])))

End of dbs_check_dataset_spread.

return sites

DEBUG DEBUG DEBUG

Just kept for debugging now.

def dbs_check_dataset_spread_old(self, dataset_name): """Figure out across how many sites this dataset is spread. NOTE: This is something we need to figure out per run, since we want to submit harvesting jobs per run. Basically three things can happen with a given dataset:

  • the whole dataset is available on a single site,
  • the whole dataset is available (mirrored) at multiple sites,
  • the dataset is spread across multiple sites and there is no single site containing the full dataset in one place. NOTE: If all goes well, it should not be possible that anything but a full dataset is mirrored. So we ignore the possibility in which for example one site contains the full dataset and two others mirror half of it. ANOTHER NOTE: According to some people this last case could actually happen. I will not design for it, but make sure it ends up as a false negative, in which case we just loose some efficiency and treat the dataset (unnecessarily) as spread-out. We don't really care about the first two possibilities, but in the third case we need to make sure to run the harvesting in two-step mode. This method checks with DBS which of the above cases is true for the dataset name given, and returns a 1 for the first two cases, and the number of sites across which the dataset is spread for the third case. The way in which this is done is by asking how many files each site has for the dataset. In the first case there is only one site, in the second case all sites should have the same number of files (i.e. the total number of files in the dataset) and in the third case the file counts from all sites should add up to the total file count for the dataset. """

DEBUG DEBUG DEBUG

If we get here DBS should have been set up already.

assert not self.dbs_api is None

DEBUG DEBUG DEBUG end

api = self.dbs_api dbs_query = "find run, run.numevents, site, file.count " \ "where dataset = %s " \ "and dataset.status = VALID" % \ dataset_name try: api_result = api.executeQuery(dbs_query) except DbsApiException: msg = "ERROR: Could not execute DBS query" self.logger.fatal(msg) raise Error(msg)

Index things by run number. No cross-check is done to make

sure we get results for each and every run in the

dataset. I'm not sure this would make sense since we'd be

cross-checking DBS info with DBS info anyway. Note that we

use the file count per site to see if we're dealing with an

incomplete vs. a mirrored dataset.

sample_info = {} try: class Handler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): if name == "result": run_number = int(attrs["RUNS_RUNNUMBER"]) site_name = str(attrs["STORAGEELEMENT_SENAME"]) file_count = int(attrs["COUNT_FILES"])

BUG BUG BUG

Doh! For some reason DBS never returns any other

event count than zero.

event_count = int(attrs["RUNS_NUMBEROFEVENTS"])

BUG BUG BUG end

info = (site_name, file_count, event_count) try: sample_info[run_number].append(info) except KeyError: sample_info[run_number] = [info] xml.sax.parseString(api_result, Handler()) except SAXParseException: msg = "ERROR: Could not parse DBS server output" self.logger.fatal(msg) raise Error(msg)

Now translate this into a slightly more usable mapping.

sites = {} for (run_number, site_info) in six.iteritems(sample_info):

Quick-n-dirty trick to see if all file counts are the

same.

unique_file_counts = set([i[1] for i in site_info]) if len(unique_file_counts) == 1:

Okay, so this must be a mirrored dataset.

We have to pick one but we have to be careful. We

cannot submit to things like a T0, a T1, or CAF.

site_names = [self.pick_a_site([i[0] for i in site_info])] nevents = [site_info[0][2]] else:

Looks like this is a spread-out sample.

site_names = [i[0] for i in site_info] nevents = [i[2] for i in site_info] sites[run_number] = zip(site_names, nevents) self.logger.debug("Sample `%s' spread is:" % dataset_name) run_numbers = sites.keys() run_numbers.sort() for run_number in run_numbers: self.logger.debug(" run # %6d: %d site(s) (%s)" % \ (run_number, len(sites[run_number]), ", ".join([i[0] for i in sites[run_number]])))

End of dbs_check_dataset_spread_old.

return sites

DEBUG DEBUG DEBUG end

Figure out the number of events in each run of this dataset.

This is a more efficient way of doing this than calling
dbs_resolve_number_of_events for each run.

Definition at line 3077 of file cmsHarvester.py.

3077  def dbs_check_dataset_spread(self, dataset_name):
3078  """Figure out the number of events in each run of this dataset.
3079 
3080  This is a more efficient way of doing this than calling
3081  dbs_resolve_number_of_events for each run.
3082 
3083  """
3084 
3085  self.logger.debug("Checking spread of dataset `%s'" % dataset_name)
3086 
3087  # DEBUG DEBUG DEBUG
3088  # If we get here DBS should have been set up already.
3089  assert not self.dbs_api is None
3090  # DEBUG DEBUG DEBUG end
3091 
3092  api = self.dbs_api
3093  dbs_query = "find run.number, site, file.name, file.numevents " \
3094  "where dataset = %s " \
3095  "and dataset.status = VALID" % \
3096  dataset_name
3097  try:
3098  api_result = api.executeQuery(dbs_query)
3099  except DBSAPI.dbsApiException.DbsApiException:
3100  msg = "ERROR: Could not execute DBS query"
3101  self.logger.fatal(msg)
3102  raise Error(msg)
3103 
3104  handler = DBSXMLHandler(["run.number", "site", "file.name", "file.numevents"])
3105  parser = xml.sax.make_parser()
3106  parser.setContentHandler(handler)
3107 
3108  try:
3109  # OBSOLETE OBSOLETE OBSOLETE

References cms::cuda.assert(), and debug.

◆ dbs_resolve_cmssw_version()

def cmsHarvester.dbs_resolve_cmssw_version (   self,
  dataset_name 
)
Ask DBS for the CMSSW version used to create this dataset.

Definition at line 2476 of file cmsHarvester.py.

2476  def dbs_resolve_cmssw_version(self, dataset_name):
2477  """Ask DBS for the CMSSW version used to create this dataset.
2478 
2479  """
2480 
2481  # DEBUG DEBUG DEBUG
2482  # If we get here DBS should have been set up already.
2483  assert not self.dbs_api is None
2484  # DEBUG DEBUG DEBUG end
2485 
2486  api = self.dbs_api
2487  dbs_query = "find algo.version where dataset = %s " \
2488  "and dataset.status = VALID" % \
2489  dataset_name
2490  try:
2491  api_result = api.executeQuery(dbs_query)
2492  except DBSAPI.dbsApiException.DbsApiException:
2493  msg = "ERROR: Could not execute DBS query"
2494  self.logger.fatal(msg)
2495  raise Error(msg)
2496 
2497  handler = DBSXMLHandler(["algo.version"])
2498  parser = xml.sax.make_parser()
2499  parser.setContentHandler(handler)
2500 
2501  try:
2502  xml.sax.parseString(api_result, handler)
2503  except SAXParseException:
2504  msg = "ERROR: Could not parse DBS server output"
2505  self.logger.fatal(msg)
2506  raise Error(msg)
2507 
2508  # DEBUG DEBUG DEBUG
2509  assert(handler.check_results_validity()), "ERROR The DBSXMLHandler screwed something up!"
2510  # DEBUG DEBUG DEBUG end
2511 
2512  cmssw_version = handler.results.values()[0]
2513 
2514  # DEBUG DEBUG DEBUG
2515  assert len(cmssw_version) == 1
2516  # DEBUG DEBUG DEBUG end
2517 
2518  cmssw_version = cmssw_version[0]
2519 
2520  # End of dbs_resolve_cmssw_version.
2521  return cmssw_version
2522 

References cms::cuda.assert().

◆ dbs_resolve_dataset_name()

def cmsHarvester.dbs_resolve_dataset_name (   self,
  dataset_name 
)
Use DBS to resolve a wildcarded dataset name.

Definition at line 2420 of file cmsHarvester.py.

2420  def dbs_resolve_dataset_name(self, dataset_name):
2421  """Use DBS to resolve a wildcarded dataset name.
2422 
2423  """
2424 
2425  # DEBUG DEBUG DEBUG
2426  # If we get here DBS should have been set up already.
2427  assert not self.dbs_api is None
2428  # DEBUG DEBUG DEBUG end
2429 
2430  # Some minor checking to make sure that whatever we've been
2431  # given as dataset name actually sounds like a dataset name.
2432  if not (dataset_name.startswith("/") and \
2433  dataset_name.endswith("RECO")):
2434  self.logger.warning("Dataset name `%s' does not sound " \
2435  "like a valid dataset name!" % \
2436  dataset_name)
2437 
2438  #----------
2439 
2440  api = self.dbs_api
2441  dbs_query = "find dataset where dataset like %s " \
2442  "and dataset.status = VALID" % \
2443  dataset_name
2444  try:
2445  api_result = api.executeQuery(dbs_query)
2446  except DBSAPI.dbsApiException.DbsApiException:
2447  msg = "ERROR: Could not execute DBS query"
2448  self.logger.fatal(msg)
2449  raise Error(msg)
2450 
2451  # Setup parsing.
2452  handler = DBSXMLHandler(["dataset"])
2453  parser = xml.sax.make_parser()
2454  parser.setContentHandler(handler)
2455 
2456  # Parse.
2457  try:
2458  xml.sax.parseString(api_result, handler)
2459  except SAXParseException:
2460  msg = "ERROR: Could not parse DBS server output"
2461  self.logger.fatal(msg)
2462  raise Error(msg)
2463 
2464  # DEBUG DEBUG DEBUG
2465  assert(handler.check_results_validity()), "ERROR The DBSXMLHandler screwed something up!"
2466  # DEBUG DEBUG DEBUG end
2467 
2468  # Extract the results.
2469  datasets = handler.results.values()[0]
2470 
2471  # End of dbs_resolve_dataset_name.
2472  return datasets
2473 

References cms::cuda.assert(), and MessageLogger_cfi.warning.

Referenced by build_dataset_list().

◆ dbs_resolve_datatype()

def cmsHarvester.dbs_resolve_datatype (   self,
  dataset_name 
)
Ask DBS for the the data type (data or mc) of a given
dataset.

Definition at line 2683 of file cmsHarvester.py.

2683  def dbs_resolve_datatype(self, dataset_name):
2684  """Ask DBS for the the data type (data or mc) of a given
2685  dataset.
2686 
2687  """
2688 
2689  # DEBUG DEBUG DEBUG
2690  # If we get here DBS should have been set up already.
2691  assert not self.dbs_api is None
2692  # DEBUG DEBUG DEBUG end
2693 
2694  api = self.dbs_api
2695  dbs_query = "find datatype.type where dataset = %s " \
2696  "and dataset.status = VALID" % \
2697  dataset_name
2698  try:
2699  api_result = api.executeQuery(dbs_query)
2700  except DBSAPI.dbsApiException.DbsApiException:
2701  msg = "ERROR: Could not execute DBS query"
2702  self.logger.fatal(msg)
2703  raise Error(msg)
2704 
2705  handler = DBSXMLHandler(["datatype.type"])
2706  parser = xml.sax.make_parser()
2707  parser.setContentHandler(handler)
2708 
2709  try:
2710  xml.sax.parseString(api_result, handler)
2711  except SAXParseException:
2712  msg = "ERROR: Could not parse DBS server output"
2713  self.logger.fatal(msg)
2714  raise Error(msg)
2715 
2716  # DEBUG DEBUG DEBUG
2717  assert(handler.check_results_validity()), "ERROR The DBSXMLHandler screwed something up!"
2718  # DEBUG DEBUG DEBUG end
2719 
2720  datatype = handler.results.values()[0]
2721 
2722  # DEBUG DEBUG DEBUG
2723  assert len(datatype) == 1
2724  # DEBUG DEBUG DEBUG end
2725 
2726  datatype = datatype[0]
2727 
2728  # End of dbs_resolve_datatype.
2729  return datatype
2730 

References cms::cuda.assert().

◆ dbs_resolve_globaltag()

def cmsHarvester.dbs_resolve_globaltag (   self,
  dataset_name 
)
Ask DBS for the globaltag corresponding to a given dataset.

# BUG BUG BUG
# This does not seem to work for data datasets? E.g. for
# /Cosmics/Commissioning08_CRAFT0831X_V1_311_ReReco_FromSuperPointing_v1/RAW-RECO
# Probaly due to the fact that the GlobalTag changed during
# datataking...
BUG BUG BUG end

Definition at line 2627 of file cmsHarvester.py.

2627  def dbs_resolve_globaltag(self, dataset_name):
2628  """Ask DBS for the globaltag corresponding to a given dataset.
2629 
2630  # BUG BUG BUG
2631  # This does not seem to work for data datasets? E.g. for
2632  # /Cosmics/Commissioning08_CRAFT0831X_V1_311_ReReco_FromSuperPointing_v1/RAW-RECO
2633  # Probaly due to the fact that the GlobalTag changed during
2634  # datataking...
2635  BUG BUG BUG end
2636 
2637  """
2638 
2639  # DEBUG DEBUG DEBUG
2640  # If we get here DBS should have been set up already.
2641  assert not self.dbs_api is None
2642  # DEBUG DEBUG DEBUG end
2643 
2644  api = self.dbs_api
2645  dbs_query = "find dataset.tag where dataset = %s " \
2646  "and dataset.status = VALID" % \
2647  dataset_name
2648  try:
2649  api_result = api.executeQuery(dbs_query)
2650  except DBSAPI.dbsApiException.DbsApiException:
2651  msg = "ERROR: Could not execute DBS query"
2652  self.logger.fatal(msg)
2653  raise Error(msg)
2654 
2655  handler = DBSXMLHandler(["dataset.tag"])
2656  parser = xml.sax.make_parser()
2657  parser.setContentHandler(parser)
2658 
2659  try:
2660  xml.sax.parseString(api_result, handler)
2661  except SAXParseException:
2662  msg = "ERROR: Could not parse DBS server output"
2663  self.logger.fatal(msg)
2664  raise Error(msg)
2665 
2666  # DEBUG DEBUG DEBUG
2667  assert(handler.check_results_validity()), "ERROR The DBSXMLHandler screwed something up!"
2668  # DEBUG DEBUG DEBUG end
2669 
2670  globaltag = handler.results.values()[0]
2671 
2672  # DEBUG DEBUG DEBUG
2673  assert len(globaltag) == 1
2674  # DEBUG DEBUG DEBUG end
2675 
2676  globaltag = globaltag[0]
2677 
2678  # End of dbs_resolve_globaltag.
2679  return globaltag
2680 

References cms::cuda.assert().

◆ dbs_resolve_number_of_events()

def cmsHarvester.dbs_resolve_number_of_events (   self,
  dataset_name,
  run_number = None 
)
Determine the number of events in a given dataset (and run).

Ask DBS for the number of events in a dataset. If a run number
is specified the number of events returned is that in that run
of that dataset. If problems occur we throw an exception.

# BUG BUG BUG
# Since DBS does not return the number of events correctly,
# neither for runs nor for whole datasets, we have to work
# around that a bit...
# BUG BUG BUG end

Definition at line 2736 of file cmsHarvester.py.

2736  def dbs_resolve_number_of_events(self, dataset_name, run_number=None):
2737  """Determine the number of events in a given dataset (and run).
2738 
2739  Ask DBS for the number of events in a dataset. If a run number
2740  is specified the number of events returned is that in that run
2741  of that dataset. If problems occur we throw an exception.
2742 
2743  # BUG BUG BUG
2744  # Since DBS does not return the number of events correctly,
2745  # neither for runs nor for whole datasets, we have to work
2746  # around that a bit...
2747  # BUG BUG BUG end
2748 
2749  """
2750 
2751  # DEBUG DEBUG DEBUG
2752  # If we get here DBS should have been set up already.
2753  assert not self.dbs_api is None
2754  # DEBUG DEBUG DEBUG end
2755 
2756  api = self.dbs_api
2757  dbs_query = "find file.name, file.numevents where dataset = %s " \
2758  "and dataset.status = VALID" % \
2759  dataset_name
2760  if not run_number is None:
2761  dbs_query = dbq_query + (" and run = %d" % run_number)
2762  try:
2763  api_result = api.executeQuery(dbs_query)
2764  except DBSAPI.dbsApiException.DbsApiException:
2765  msg = "ERROR: Could not execute DBS query"
2766  self.logger.fatal(msg)
2767  raise Error(msg)
2768 
2769  handler = DBSXMLHandler(["file.name", "file.numevents"])
2770  parser = xml.sax.make_parser()
2771  parser.setContentHandler(handler)
2772 
2773  try:
2774  xml.sax.parseString(api_result, handler)
2775  except SAXParseException:
2776  msg = "ERROR: Could not parse DBS server output"
2777  self.logger.fatal(msg)
2778  raise Error(msg)
2779 
2780  # DEBUG DEBUG DEBUG
2781  assert(handler.check_results_validity()), "ERROR The DBSXMLHandler screwed something up!"
2782  # DEBUG DEBUG DEBUG end
2783 
2784  num_events = sum(handler.results["file.numevents"])
2785 
2786  # End of dbs_resolve_number_of_events.
2787  return num_events
2788 

References cms::cuda.assert().

◆ dbs_resolve_runs()

def cmsHarvester.dbs_resolve_runs (   self,
  dataset_name 
)

def dbs_resolve_dataset_number_of_events(self, dataset_name): """Ask DBS across how many events this dataset has been spread out.

This is especially useful to check that we do not submit a job supposed to run on a complete sample that is not contained at a single site. """

DEBUG DEBUG DEBUG

If we get here DBS should have been set up already.

assert not self.dbs_api is None

DEBUG DEBUG DEBUG end

api = self.dbs_api dbs_query = "find count(site) where dataset = %s " \ "and dataset.status = VALID" % \ dataset_name try: api_result = api.executeQuery(dbs_query) except DbsApiException: raise Error("ERROR: Could not execute DBS query") try: num_events = [] class Handler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): if name == "result": num_events.append(str(attrs["COUNT_STORAGEELEMENT"])) xml.sax.parseString(api_result, Handler()) except SAXParseException: raise Error("ERROR: Could not parse DBS server output")

DEBUG DEBUG DEBUG

assert len(num_events) == 1

DEBUG DEBUG DEBUG end

num_events = int(num_events[0])

End of dbs_resolve_dataset_number_of_events.

return num_events

Ask DBS for the list of runs in a given dataset.

# NOTE: This does not (yet?) skip/remove empty runs. There is
# a bug in the DBS entry run.numevents (i.e. it always returns
# zero) which should be fixed in the `next DBS release'.
# See also:
#   https://savannah.cern.ch/bugs/?53452
#   https://savannah.cern.ch/bugs/?53711

Definition at line 2570 of file cmsHarvester.py.

2570  def dbs_resolve_runs(self, dataset_name):
2571  """Ask DBS for the list of runs in a given dataset.
2572 
2573  # NOTE: This does not (yet?) skip/remove empty runs. There is
2574  # a bug in the DBS entry run.numevents (i.e. it always returns
2575  # zero) which should be fixed in the `next DBS release'.
2576  # See also:
2577  # https://savannah.cern.ch/bugs/?53452
2578  # https://savannah.cern.ch/bugs/?53711
2579 
2580  """
2581 
2582  # TODO TODO TODO
2583  # We should remove empty runs as soon as the above mentioned
2584  # bug is fixed.
2585  # TODO TODO TODO end
2586 
2587  # DEBUG DEBUG DEBUG
2588  # If we get here DBS should have been set up already.
2589  assert not self.dbs_api is None
2590  # DEBUG DEBUG DEBUG end
2591 
2592  api = self.dbs_api
2593  dbs_query = "find run where dataset = %s " \
2594  "and dataset.status = VALID" % \
2595  dataset_name
2596  try:
2597  api_result = api.executeQuery(dbs_query)
2598  except DBSAPI.dbsApiException.DbsApiException:
2599  msg = "ERROR: Could not execute DBS query"
2600  self.logger.fatal(msg)
2601  raise Error(msg)
2602 
2603  handler = DBSXMLHandler(["run"])
2604  parser = xml.sax.make_parser()
2605  parser.setContentHandler(handler)
2606 
2607  try:
2608  xml.sax.parseString(api_result, handler)
2609  except SAXParseException:
2610  msg = "ERROR: Could not parse DBS server output"
2611  self.logger.fatal(msg)
2612  raise Error(msg)
2613 
2614  # DEBUG DEBUG DEBUG
2615  assert(handler.check_results_validity()), "ERROR The DBSXMLHandler screwed something up!"
2616  # DEBUG DEBUG DEBUG end
2617 
2618  runs = handler.results.values()[0]
2619  # Turn strings into integers.
2620  runs = sorted([int(i) for i in runs])
2621 
2622  # End of dbs_resolve_runs.
2623  return runs
2624 

References cms::cuda.assert(), and createfilelist.int.

◆ escape_dataset_name()

def cmsHarvester.escape_dataset_name (   self,
  dataset_name 
)
Escape a DBS dataset name.

Escape a DBS dataset name such that it does not cause trouble
with the file system. This means turning each `/' into `__',
except for the first one which is just removed.

Definition at line 4046 of file cmsHarvester.py.

4046  def escape_dataset_name(self, dataset_name):
4047  """Escape a DBS dataset name.
4048 
4049  Escape a DBS dataset name such that it does not cause trouble
4050  with the file system. This means turning each `/' into `__',
4051  except for the first one which is just removed.
4052 
4053  """
4054 
4055  escaped_dataset_name = dataset_name
4056  escaped_dataset_name = escaped_dataset_name.strip("/")
4057  escaped_dataset_name = escaped_dataset_name.replace("/", "__")
4058 
4059  return escaped_dataset_name
4060 

◆ load_ref_hist_mappings()

def cmsHarvester.load_ref_hist_mappings (   self)
Load the reference histogram mappings from file.

The dataset name to reference histogram name mappings are read
from a text file specified in self.ref_hist_mappings_file_name.

Definition at line 5205 of file cmsHarvester.py.

5205  def load_ref_hist_mappings(self):
5206  """Load the reference histogram mappings from file.
5207 
5208  The dataset name to reference histogram name mappings are read
5209  from a text file specified in self.ref_hist_mappings_file_name.
5210 
5211  """
5212 
5213  # DEBUG DEBUG DEBUG
5214  assert len(self.ref_hist_mappings) < 1, \
5215  "ERROR Should not be RE-loading " \
5216  "reference histogram mappings!"
5217  # DEBUG DEBUG DEBUG end
5218 
5219  self.logger.info("Loading reference histogram mappings " \
5220  "from file `%s'" % \
5221  self.ref_hist_mappings_file_name)
5222 
5223  mappings_lines = None
5224  try:
5225  mappings_file = file(self.ref_hist_mappings_file_name, "r")
5226  mappings_lines = mappings_file.readlines()
5227  mappings_file.close()
5228  except IOError:
5229  msg = "ERROR: Could not open reference histogram mapping "\
5230  "file `%s'" % self.ref_hist_mappings_file_name
5231  self.logger.fatal(msg)
5232  raise Error(msg)
5233 
5234 
5235 
5236  # The format we expect is: two white-space separated pieces
5237  # per line. The first the dataset name for which the reference
5238  # should be used, the second one the name of the reference
5239  # histogram in the database.
5240 
5241  for mapping in mappings_lines:
5242  # Skip comment lines.
5243  if not mapping.startswith("#"):
5244  mapping = mapping.strip()
5245  if len(mapping) > 0:
5246  mapping_pieces = mapping.split()
5247  if len(mapping_pieces) != 2:
5248  msg = "ERROR: The reference histogram mapping " \
5249  "file contains a line I don't " \
5250  "understand:\n %s" % mapping
5251  self.logger.fatal(msg)
5252  raise Error(msg)
5253  dataset_name = mapping_pieces[0].strip()
5254  ref_hist_name = mapping_pieces[1].strip()
5255  # We don't want people to accidentally specify
5256  # multiple mappings for the same dataset. Just
5257  # don't accept those cases.
5258  if dataset_name in self.ref_hist_mappings:
5259  msg = "ERROR: The reference histogram mapping " \
5260  "file contains multiple mappings for " \
5261  "dataset `%s'."
5262  self.logger.fatal(msg)
5263  raise Error(msg)
5264 
5265  # All is well that ends well.
5266  self.ref_hist_mappings[dataset_name] = ref_hist_name
5267 
5268 
5269 
5270  self.logger.info(" Successfully loaded %d mapping(s)" % \
5271  len(self.ref_hist_mappings))
5272  max_len = max([len(i) for i in self.ref_hist_mappings.keys()])
5273  for (map_from, map_to) in six.iteritems(self.ref_hist_mappings):
5274  self.logger.info(" %-*s -> %s" % \
5275  (max_len, map_from, map_to))
5276 
5277  # End of load_ref_hist_mappings.
5278 

References FrontierConditions_GlobalTag_cff.file, info(), relativeConstraints.keys, SiStripPI.max, and digitizers_cfi.strip.

◆ option_handler_caf_access()

def cmsHarvester.option_handler_caf_access (   self,
  option,
  opt_str,
  value,
  parser 
)
Set the self.caf_access flag to try and create jobs that
run on the CAF.

Definition at line 1104 of file cmsHarvester.py.

1104  def option_handler_caf_access(self, option, opt_str, value, parser):
1105  """Set the self.caf_access flag to try and create jobs that
1106  run on the CAF.
1107 
1108  """
1109  self.caf_access = True
1110 
1111  self.logger.warning("Running in `caf_access' mode. " \
1112  "Will try to create jobs that run " \
1113  "on CAF but no" \
1114  "further promises...")
1115 
1116  # End of option_handler_caf_access.
1117 

◆ option_handler_castor_dir()

def cmsHarvester.option_handler_castor_dir (   self,
  option,
  opt_str,
  value,
  parser 
)

def option_handler_dataset_name(self, option, opt_str, value, parser): """Specify the name(s) of the dataset(s) to be processed.

It is checked to make sure that no dataset name or listfile names are given yet. If all is well (i.e. we still have a clean slate) the dataset name is stored for later use, otherwise a Usage exception is raised. """ if not self.input_method is None: if self.input_method == "dataset": raise Usage("Please only feed me one dataset specification") elif self.input_method == "listfile": raise Usage("Cannot specify both dataset and input list file") else: assert False, "Unknown input method `%s'" % self.input_method self.input_method = "dataset" self.input_name = value self.logger.info("Input method used: %s" % self.input_method)

End of option_handler_dataset_name.

def option_handler_listfile_name(self, option, opt_str, value, parser): """Specify the input list file containing datasets to be processed. It is checked to make sure that no dataset name or listfile names are given yet. If all is well (i.e. we still have a clean slate) the listfile name is stored for later use, otherwise a Usage exception is raised. """ if not self.input_method is None: if self.input_method == "listfile": raise Usage("Please only feed me one list file") elif self.input_method == "dataset": raise Usage("Cannot specify both dataset and input list file") else: assert False, "Unknown input method `%s'" % self.input_method self.input_method = "listfile" self.input_name = value self.logger.info("Input method used: %s" % self.input_method)

End of option_handler_listfile_name.

Specify where on CASTOR the output should go.

At the moment only output to CERN CASTOR is
supported. Eventually the harvested results should go into the
central place for DQM on CASTOR anyway.

Definition at line 1062 of file cmsHarvester.py.

1062  def option_handler_castor_dir(self, option, opt_str, value, parser):
1063  """Specify where on CASTOR the output should go.
1064 
1065  At the moment only output to CERN CASTOR is
1066  supported. Eventually the harvested results should go into the
1067  central place for DQM on CASTOR anyway.
1068 
1069  """
1070 
1071  # Check format of specified CASTOR area.
1072  castor_dir = value
1073  #castor_dir = castor_dir.lstrip(os.path.sep)
1074  castor_prefix = self.castor_prefix
1075 
1076  # Add a leading slash if necessary and clean up the path.
1077  castor_dir = os.path.join(os.path.sep, castor_dir)
1078  self.castor_base_dir = os.path.normpath(castor_dir)
1079 
1080  self.logger.info("CASTOR (base) area to be used: `%s'" % \
1081  self.castor_base_dir)
1082 
1083  # End of option_handler_castor_dir.
1084 

◆ option_handler_crab_submission()

def cmsHarvester.option_handler_crab_submission (   self,
  option,
  opt_str,
  value,
  parser 
)
Crab jobs are not created and
"submitted automatically",

Definition at line 1132 of file cmsHarvester.py.

1132  def option_handler_crab_submission(self, option, opt_str, value, parser):
1133  """Crab jobs are not created and
1134  "submitted automatically",
1135  """
1136  self.crab_submission = True
1137 
1138  # End of option_handler_crab_submission.
1139 

◆ option_handler_list_types()

def cmsHarvester.option_handler_list_types (   self,
  option,
  opt_str,
  value,
  parser 
)
List all harvesting types and their mappings.

This lists all implemented harvesting types with their
corresponding mappings to sequence names. This had to be
separated out from the help since it depends on the CMSSW
version and was making things a bit of a mess.

NOTE: There is no way (at least not that I could come up with)
to code this in a neat generic way that can be read both by
this method and by setup_harvesting_info(). Please try hard to
keep these two methods in sync!

Definition at line 1154 of file cmsHarvester.py.

1154  def option_handler_list_types(self, option, opt_str, value, parser):
1155  """List all harvesting types and their mappings.
1156 
1157  This lists all implemented harvesting types with their
1158  corresponding mappings to sequence names. This had to be
1159  separated out from the help since it depends on the CMSSW
1160  version and was making things a bit of a mess.
1161 
1162  NOTE: There is no way (at least not that I could come up with)
1163  to code this in a neat generic way that can be read both by
1164  this method and by setup_harvesting_info(). Please try hard to
1165  keep these two methods in sync!
1166 
1167  """
1168 
1169  sep_line = "-" * 50
1170  sep_line_short = "-" * 20
1171 
1172  print(sep_line)
1173  print("The following harvesting types are available:")
1174  print(sep_line)
1175 
1176  print("`RelVal' maps to:")
1177  print(" pre-3_3_0 : HARVESTING:validationHarvesting")
1178  print(" 3_4_0_pre2 and later: HARVESTING:validationHarvesting+dqmHarvesting")
1179  print(" Exceptions:")
1180  print(" 3_3_0_pre1-4 : HARVESTING:validationHarvesting")
1181  print(" 3_3_0_pre6 : HARVESTING:validationHarvesting")
1182  print(" 3_4_0_pre1 : HARVESTING:validationHarvesting")
1183 
1184  print(sep_line_short)
1185 
1186  print("`RelValFS' maps to:")
1187  print(" always : HARVESTING:validationHarvestingFS")
1188 
1189  print(sep_line_short)
1190 
1191  print("`MC' maps to:")
1192  print(" always : HARVESTING:validationprodHarvesting")
1193 
1194  print(sep_line_short)
1195 
1196  print("`DQMOffline' maps to:")
1197  print(" always : HARVESTING:dqmHarvesting")
1198 
1199  print(sep_line)
1200 
1201  # We're done, let's quit. (This is the same thing optparse
1202  # does after printing the help.)
1203  raise SystemExit
1204 
1205  # End of option_handler_list_types.
1206 

References edm.print().

◆ option_handler_no_t1access()

def cmsHarvester.option_handler_no_t1access (   self,
  option,
  opt_str,
  value,
  parser 
)
Set the self.no_t1access flag to try and create jobs that
run without special `t1access' role.

Definition at line 1087 of file cmsHarvester.py.

1087  def option_handler_no_t1access(self, option, opt_str, value, parser):
1088  """Set the self.no_t1access flag to try and create jobs that
1089  run without special `t1access' role.
1090 
1091  """
1092 
1093  self.non_t1access = True
1094 
1095  self.logger.warning("Running in `non-t1access' mode. " \
1096  "Will try to create jobs that run " \
1097  "without special rights but no " \
1098  "further promises...")
1099 
1100  # End of option_handler_no_t1access.
1101 

◆ option_handler_preferred_site()

def cmsHarvester.option_handler_preferred_site (   self,
  option,
  opt_str,
  value,
  parser 
)

Definition at line 1148 of file cmsHarvester.py.

1148  def option_handler_preferred_site(self, option, opt_str, value, parser):
1149 
1150  self.preferred_site = value
1151 

◆ option_handler_saveByLumiSection()

def cmsHarvester.option_handler_saveByLumiSection (   self,
  option,
  opt_str,
  value,
  parser 
)
Set process.dqmSaver.saveByLumiSectiont=1 in cfg harvesting file

Definition at line 1120 of file cmsHarvester.py.

1120  def option_handler_saveByLumiSection(self, option, opt_str, value, parser):
1121  """Set process.dqmSaver.saveByLumiSectiont=1 in cfg harvesting file
1122  """
1123  self.saveByLumiSection = True
1124 
1125  self.logger.warning("waning concerning saveByLumiSection option")
1126 
1127  # End of option_handler_saveByLumiSection.
1128 
1129 

◆ option_handler_sites()

def cmsHarvester.option_handler_sites (   self,
  option,
  opt_str,
  value,
  parser 
)

Definition at line 1142 of file cmsHarvester.py.

1142  def option_handler_sites(self, option, opt_str, value, parser):
1143 
1144  self.nr_max_sites = value
1145 

◆ parse_cmd_line_options()

def cmsHarvester.parse_cmd_line_options (   self)

Definition at line 1871 of file cmsHarvester.py.

1871  def parse_cmd_line_options(self):
1872 
1873  # Set up the command line parser. Note that we fix up the help
1874  # formatter so that we can add some text pointing people to
1875  # the Twiki etc.
1876  parser = optparse.OptionParser(version="%s %s" % \
1877  ("%prog", self.version),
1878  formatter=CMSHarvesterHelpFormatter())
1879 
1880  self.option_parser = parser
1881 
1882  # The debug switch.
1883  parser.add_option("-d", "--debug",
1884  help="Switch on debug mode",
1885  action="callback",
1886  callback=self.option_handler_debug)
1887 
1888  # The quiet switch.
1889  parser.add_option("-q", "--quiet",
1890  help="Be less verbose",
1891  action="callback",
1892  callback=self.option_handler_quiet)
1893 
1894  # The force switch. If this switch is used sanity checks are
1895  # performed but failures do not lead to aborts. Use with care.
1896  parser.add_option("", "--force",
1897  help="Force mode. Do not abort on sanity check "
1898  "failures",
1899  action="callback",
1900  callback=self.option_handler_force)
1901 
1902  # Choose between the different kinds of harvesting.
1903  parser.add_option("", "--harvesting_type",
1904  help="Harvesting type: %s" % \
1905  ", ".join(self.harvesting_types),
1906  action="callback",
1907  callback=self.option_handler_harvesting_type,
1908  type="string",
1909  metavar="HARVESTING_TYPE")
1910 
1911  # Choose between single-step and two-step mode.
1912  parser.add_option("", "--harvesting_mode",
1913  help="Harvesting mode: %s (default = %s)" % \
1914  (", ".join(self.harvesting_modes),
1915  self.harvesting_mode_default),
1916  action="callback",
1917  callback=self.option_handler_harvesting_mode,
1918  type="string",
1919  metavar="HARVESTING_MODE")
1920 
1921  # Override the GlobalTag chosen by the cmsHarvester.
1922  parser.add_option("", "--globaltag",
1923  help="GlobalTag to use. Default is the ones " \
1924  "the dataset was created with for MC, for data" \
1925  "a GlobalTag has to be specified.",
1926  action="callback",
1927  callback=self.option_handler_globaltag,
1928  type="string",
1929  metavar="GLOBALTAG")
1930 
1931  # Allow switching off of reference histograms.
1932  parser.add_option("", "--no-ref-hists",
1933  help="Don't use any reference histograms",
1934  action="callback",
1935  callback=self.option_handler_no_ref_hists)
1936 
1937  # Allow the default (i.e. the one that should be used)
1938  # Frontier connection to be overridden.
1939  parser.add_option("", "--frontier-connection",
1940  help="Use this Frontier connection to find " \
1941  "GlobalTags and LocalTags (for reference " \
1942  "histograms).\nPlease only use this for " \
1943  "testing.",
1944  action="callback",
1945  callback=self.option_handler_frontier_connection,
1946  type="string",
1947  metavar="FRONTIER")
1948 
1949  # Similar to the above but specific to the Frontier connection
1950  # to be used for the GlobalTag.
1951  parser.add_option("", "--frontier-connection-for-globaltag",
1952  help="Use this Frontier connection to find " \
1953  "GlobalTags.\nPlease only use this for " \
1954  "testing.",
1955  action="callback",
1956  callback=self.option_handler_frontier_connection,
1957  type="string",
1958  metavar="FRONTIER")
1959 
1960  # Similar to the above but specific to the Frontier connection
1961  # to be used for the reference histograms.
1962  parser.add_option("", "--frontier-connection-for-refhists",
1963  help="Use this Frontier connection to find " \
1964  "LocalTags (for reference " \
1965  "histograms).\nPlease only use this for " \
1966  "testing.",
1967  action="callback",
1968  callback=self.option_handler_frontier_connection,
1969  type="string",
1970  metavar="FRONTIER")
1971 
1972  # Option to specify the name (or a regexp) of the dataset(s)
1973  # to be used.
1974  parser.add_option("", "--dataset",
1975  help="Name (or regexp) of dataset(s) to process",
1976  action="callback",
1977  #callback=self.option_handler_dataset_name,
1978  callback=self.option_handler_input_spec,
1979  type="string",
1980  #dest="self.input_name",
1981  metavar="DATASET")
1982 
1983  # Option to specify the name (or a regexp) of the dataset(s)
1984  # to be ignored.
1985  parser.add_option("", "--dataset-ignore",
1986  help="Name (or regexp) of dataset(s) to ignore",
1987  action="callback",
1988  callback=self.option_handler_input_spec,
1989  type="string",
1990  metavar="DATASET-IGNORE")
1991 
1992  # Option to specify the name (or a regexp) of the run(s)
1993  # to be used.
1994  parser.add_option("", "--runs",
1995  help="Run number(s) to process",
1996  action="callback",
1997  callback=self.option_handler_input_spec,
1998  type="string",
1999  metavar="RUNS")
2000 
2001  # Option to specify the name (or a regexp) of the run(s)
2002  # to be ignored.
2003  parser.add_option("", "--runs-ignore",
2004  help="Run number(s) to ignore",
2005  action="callback",
2006  callback=self.option_handler_input_spec,
2007  type="string",
2008  metavar="RUNS-IGNORE")
2009 
2010  # Option to specify a file containing a list of dataset names
2011  # (or regexps) to be used.
2012  parser.add_option("", "--datasetfile",
2013  help="File containing list of dataset names " \
2014  "(or regexps) to process",
2015  action="callback",
2016  #callback=self.option_handler_listfile_name,
2017  callback=self.option_handler_input_spec,
2018  type="string",
2019  #dest="self.input_name",
2020  metavar="DATASETFILE")
2021 
2022  # Option to specify a file containing a list of dataset names
2023  # (or regexps) to be ignored.
2024  parser.add_option("", "--datasetfile-ignore",
2025  help="File containing list of dataset names " \
2026  "(or regexps) to ignore",
2027  action="callback",
2028  callback=self.option_handler_input_spec,
2029  type="string",
2030  metavar="DATASETFILE-IGNORE")
2031 
2032  # Option to specify a file containing a list of runs to be
2033  # used.
2034  parser.add_option("", "--runslistfile",
2035  help="File containing list of run numbers " \
2036  "to process",
2037  action="callback",
2038  callback=self.option_handler_input_spec,
2039  type="string",
2040  metavar="RUNSLISTFILE")
2041 
2042  # Option to specify a file containing a list of runs
2043  # to be ignored.
2044  parser.add_option("", "--runslistfile-ignore",
2045  help="File containing list of run numbers " \
2046  "to ignore",
2047  action="callback",
2048  callback=self.option_handler_input_spec,
2049  type="string",
2050  metavar="RUNSLISTFILE-IGNORE")
2051 
2052  # Option to specify a Jsonfile contaning a list of runs
2053  # to be used.
2054  parser.add_option("", "--Jsonrunfile",
2055  help="Jsonfile containing dictionary of run/lumisections pairs. " \
2056  "All lumisections of runs contained in dictionary are processed.",
2057  action="callback",
2058  callback=self.option_handler_input_Jsonrunfile,
2059  type="string",
2060  metavar="JSONRUNFILE")
2061 
2062  # Option to specify a Jsonfile contaning a dictionary of run/lumisections pairs
2063  # to be used.
2064  parser.add_option("", "--Jsonfile",
2065  help="Jsonfile containing dictionary of run/lumisections pairs. " \
2066  "Only specified lumisections of runs contained in dictionary are processed.",
2067  action="callback",
2068  callback=self.option_handler_input_Jsonfile,
2069  type="string",
2070  metavar="JSONFILE")
2071 
2072  # Option to specify a ToDo file contaning a list of runs
2073  # to be used.
2074  parser.add_option("", "--todo-file",
2075  help="Todo file containing a list of runs to process.",
2076  action="callback",
2077  callback=self.option_handler_input_todofile,
2078  type="string",
2079  metavar="TODO-FILE")
2080 
2081  # Option to specify which file to use for the dataset name to
2082  # reference histogram name mappings.
2083  parser.add_option("", "--refhistmappingfile",
2084  help="File to be use for the reference " \
2085  "histogram mappings. Default: `%s'." % \
2086  self.ref_hist_mappings_file_name_default,
2087  action="callback",
2088  callback=self.option_handler_ref_hist_mapping_file,
2089  type="string",
2090  metavar="REFHISTMAPPING-FILE")
2091 
2092  # Specify the place in CASTOR where the output should go.
2093  # NOTE: Only output to CASTOR is supported for the moment,
2094  # since the central DQM results place is on CASTOR anyway.
2095  parser.add_option("", "--castordir",
2096  help="Place on CASTOR to store results. " \
2097  "Default: `%s'." % \
2098  self.castor_base_dir_default,
2099  action="callback",
2100  callback=self.option_handler_castor_dir,
2101  type="string",
2102  metavar="CASTORDIR")
2103 
2104  # Use this to try and create jobs that will run without
2105  # special `t1access' role.
2106  parser.add_option("", "--no-t1access",
2107  help="Try to create jobs that will run " \
2108  "without special `t1access' role",
2109  action="callback",
2110  callback=self.option_handler_no_t1access)
2111 
2112  # Use this to create jobs that may run on CAF
2113  parser.add_option("", "--caf-access",
2114  help="Crab jobs may run " \
2115  "on CAF",
2116  action="callback",
2117  callback=self.option_handler_caf_access)
2118 
2119  # set process.dqmSaver.saveByLumiSection=1 in harvesting cfg file
2120  parser.add_option("", "--saveByLumiSection",
2121  help="set saveByLumiSection=1 in harvesting cfg file",
2122  action="callback",
2123  callback=self.option_handler_saveByLumiSection)
2124 
2125  # Use this to enable automatic creation and submission of crab jobs
2126  parser.add_option("", "--automatic-crab-submission",
2127  help="Crab jobs are created and " \
2128  "submitted automatically",
2129  action="callback",
2130  callback=self.option_handler_crab_submission)
2131 
2132  # Option to set the max number of sites, each
2133  #job is submitted to
2134  parser.add_option("", "--max-sites",
2135  help="Max. number of sites each job is submitted to",
2136  action="callback",
2137  callback=self.option_handler_sites,
2138  type="int")
2139 
2140  # Option to set the preferred site
2141  parser.add_option("", "--site",
2142  help="Crab jobs are submitted to specified site. T1 sites may be shortened by the following (country) codes: \
2143  srm-cms.cern.ch : CH \
2144  ccsrm.in2p3.fr : FR \
2145  cmssrm-fzk.gridka.de : DE \
2146  cmssrm.fnal.gov : GOV \
2147  gridka-dCache.fzk.de : DE2 \
2148  rm-cms.gridpp.rl.ac.uk : UK \
2149  srm.grid.sinica.edu.tw : TW \
2150  srm2.grid.sinica.edu.tw : TW2 \
2151  srmcms.pic.es : ES \
2152  storm-fe-cms.cr.cnaf.infn.it : IT",
2153  action="callback",
2154  callback=self.option_handler_preferred_site,
2155  type="string")
2156 
2157  # This is the command line flag to list all harvesting
2158  # type-to-sequence mappings.
2159  parser.add_option("-l", "--list",
2160  help="List all harvesting types and their" \
2161  "corresponding sequence names",
2162  action="callback",
2163  callback=self.option_handler_list_types)
2164 
2165  # If nothing was specified: tell the user how to do things the
2166  # next time and exit.
2167  # NOTE: We just use the OptParse standard way of doing this by
2168  # acting as if a '--help' was specified.
2169  if len(self.cmd_line_opts) < 1:
2170  self.cmd_line_opts = ["--help"]
2171 
2172  # Some trickery with the options. Why? Well, since these
2173  # options change the output level immediately from the option
2174  # handlers, the results differ depending on where they are on
2175  # the command line. Let's just make sure they are at the
2176  # front.
2177  # NOTE: Not very efficient or sophisticated, but it works and
2178  # it only has to be done once anyway.
2179  for i in ["-d", "--debug",
2180  "-q", "--quiet"]:
2181  if i in self.cmd_line_opts:
2182  self.cmd_line_opts.remove(i)
2183  self.cmd_line_opts.insert(0, i)
2184 
2185  # Everything is set up, now parse what we were given.
2186  parser.set_defaults()
2187  (self.options, self.args) = parser.parse_args(self.cmd_line_opts)
2188 
2189  # End of parse_cmd_line_options.
2190 

◆ pick_a_site()

def cmsHarvester.pick_a_site (   self,
  sites,
  cmssw_version 
)

Definition at line 1707 of file cmsHarvester.py.

1707  def pick_a_site(self, sites, cmssw_version):
1708 
1709  # Create list of forbidden sites
1710  sites_forbidden = []
1711 
1712  if (self.preferred_site == "CAF") or (self.preferred_site == "caf.cern.ch"):
1713  self.caf_access = True
1714 
1715  if self.caf_access == False:
1716  sites_forbidden.append("caf.cern.ch")
1717 
1718  # These are the T1 sites. These are only forbidden if we're
1719  # running in non-T1 mode.
1720  # Source:
1721  # https://cmsweb.cern.ch/sitedb/sitelist/?naming_scheme=ce
1722  # Hard-coded, yes. Not nice, no.
1723 
1724  all_t1 = [
1725  "srm-cms.cern.ch",
1726  "ccsrm.in2p3.fr",
1727  "cmssrm-fzk.gridka.de",
1728  "cmssrm.fnal.gov",
1729  "gridka-dCache.fzk.de",
1730  "srm-cms.gridpp.rl.ac.uk",
1731  "srm.grid.sinica.edu.tw",
1732  "srm2.grid.sinica.edu.tw",
1733  "srmcms.pic.es",
1734  "storm-fe-cms.cr.cnaf.infn.it"
1735  ]
1736 
1737  country_codes = {
1738  "CAF" : "caf.cern.ch",
1739  "CH" : "srm-cms.cern.ch",
1740  "FR" : "ccsrm.in2p3.fr",
1741  "DE" : "cmssrm-fzk.gridka.de",
1742  "GOV" : "cmssrm.fnal.gov",
1743  "DE2" : "gridka-dCache.fzk.de",
1744  "UK" : "srm-cms.gridpp.rl.ac.uk",
1745  "TW" : "srm.grid.sinica.edu.tw",
1746  "TW2" : "srm2.grid.sinica.edu.tw",
1747  "ES" : "srmcms.pic.es",
1748  "IT" : "storm-fe-cms.cr.cnaf.infn.it"
1749  }
1750 
1751  if self.non_t1access:
1752  sites_forbidden.extend(all_t1)
1753 
1754  for site in sites_forbidden:
1755  if site in sites:
1756  sites.remove(site)
1757 
1758  if self.preferred_site in country_codes:
1759  self.preferred_site = country_codes[self.preferred_site]
1760 
1761  if self.preferred_site != "no preference":
1762  if self.preferred_site in sites:
1763  sites = [self.preferred_site]
1764  else:
1765  sites= []
1766 
1767  #print sites
1768 
1769  # Looks like we have to do some caching here, otherwise things
1770  # become waaaay toooo sloooooow. So that's what the
1771  # sites_and_versions_cache does.
1772 
1773  # NOTE: Keep this set to None!
1774  site_name = None
1775  cmd = None
1776  while len(sites) > 0 and \
1777  site_name is None:
1778 
1779  # Create list of t1_sites
1780  t1_sites = []
1781  for site in sites:
1782  if site in all_t1:
1783  t1_sites.append(site)
1784  if site == "caf.cern.ch":
1785  t1_sites.append(site)
1786 
1787  # If avilable pick preferred site
1788  #if self.preferred_site in sites:
1789  # se_name = self.preferred_site
1790  # Else, if available pick t1 site
1791 
1792  if len(t1_sites) > 0:
1793  se_name = choice(t1_sites)
1794  # Else pick any site
1795  else:
1796  se_name = choice(sites)
1797 
1798  # But check that it hosts the CMSSW version we want.
1799 
1800  if se_name in self.sites_and_versions_cache and \
1801  cmssw_version in self.sites_and_versions_cache[se_name]:
1802  if self.sites_and_versions_cache[se_name][cmssw_version]:
1803  site_name = se_name
1804  break
1805  else:
1806  self.logger.debug(" --> rejecting site `%s'" % se_name)
1807  sites.remove(se_name)
1808 
1809  else:
1810  self.logger.info("Checking if site `%s' " \
1811  "has CMSSW version `%s'" % \
1812  (se_name, cmssw_version))
1813  self.sites_and_versions_cache[se_name] = {}
1814 
1815  # TODO TODO TODO
1816  # Test for SCRAM architecture removed as per request
1817  # from Andreas.
1818  # scram_arch = os.getenv("SCRAM_ARCH")
1819  # cmd = "lcg-info --list-ce " \
1820  # "--query '" \
1821  # "Tag=VO-cms-%s," \
1822  # "Tag=VO-cms-%s," \
1823  # "CEStatus=Production," \
1824  # "CloseSE=%s'" % \
1825  # (cmssw_version, scram_arch, se_name)
1826  # TODO TODO TODO end
1827 
1828  cmd = "lcg-info --list-ce " \
1829  "--query '" \
1830  "Tag=VO-cms-%s," \
1831  "CEStatus=Production," \
1832  "CloseSE=%s'" % \
1833  (cmssw_version, se_name)
1834  (status, output) = commands.getstatusoutput(cmd)
1835  if status != 0:
1836  self.logger.error("Could not check site information " \
1837  "for site `%s'" % se_name)
1838  else:
1839  if (len(output) > 0) or (se_name == "caf.cern.ch"):
1840  self.sites_and_versions_cache[se_name][cmssw_version] = True
1841  site_name = se_name
1842  break
1843  else:
1844  self.sites_and_versions_cache[se_name][cmssw_version] = False
1845  self.logger.debug(" --> rejecting site `%s'" % se_name)
1846  sites.remove(se_name)
1847 
1848  if site_name is self.no_matching_site_found_str:
1849  self.logger.error(" --> no matching site found")
1850  self.logger.error(" --> Your release or SCRAM " \
1851  "architecture may not be available" \
1852  "anywhere on the (LCG) grid.")
1853  if not cmd is None:
1854  self.logger.debug(" (command used: `%s')" % cmd)
1855  else:
1856  self.logger.debug(" --> selected site `%s'" % site_name)
1857 
1858  # Return something more descriptive (than `None') in case we
1859  # found nothing.
1860  if site_name is None:
1861  site_name = self.no_matching_site_found_str
1862  # Keep track of our global flag signifying that this
1863  # happened.
1864  self.all_sites_found = False
1865 
1866  # End of pick_a_site.
1867  return site_name
1868 

References debug, relativeConstraints.error, and info().

◆ process_dataset_ignore_list()

def cmsHarvester.process_dataset_ignore_list (   self)
Update the list of datasets taking into account the ones to
ignore.

Both lists have been generated before from DBS and both are
assumed to be unique.

NOTE: The advantage of creating the ignore list from DBS (in
case a regexp is given) and matching that instead of directly
matching the ignore criterion against the list of datasets (to
consider) built from DBS is that in the former case we're sure
that all regexps are treated exactly as DBS would have done
without the cmsHarvester.

NOTE: This only removes complete samples. Exclusion of single
runs is done by the book keeping. So the assumption is that a
user never wants to harvest just part (i.e. n out of N runs)
of a sample.

Definition at line 3566 of file cmsHarvester.py.

3566  def process_dataset_ignore_list(self):
3567  """Update the list of datasets taking into account the ones to
3568  ignore.
3569 
3570  Both lists have been generated before from DBS and both are
3571  assumed to be unique.
3572 
3573  NOTE: The advantage of creating the ignore list from DBS (in
3574  case a regexp is given) and matching that instead of directly
3575  matching the ignore criterion against the list of datasets (to
3576  consider) built from DBS is that in the former case we're sure
3577  that all regexps are treated exactly as DBS would have done
3578  without the cmsHarvester.
3579 
3580  NOTE: This only removes complete samples. Exclusion of single
3581  runs is done by the book keeping. So the assumption is that a
3582  user never wants to harvest just part (i.e. n out of N runs)
3583  of a sample.
3584 
3585  """
3586 
3587  self.logger.info("Processing list of datasets to ignore...")
3588 
3589  self.logger.debug("Before processing ignore list there are %d " \
3590  "datasets in the list to be processed" % \
3591  len(self.datasets_to_use))
3592 
3593  # Simple approach: just loop and search.
3594  dataset_names_filtered = copy.deepcopy(self.datasets_to_use)
3595  for dataset_name in self.datasets_to_use.keys():
3596  if dataset_name in self.datasets_to_ignore.keys():
3597  del dataset_names_filtered[dataset_name]
3598 
3599  self.logger.info(" --> Removed %d dataset(s)" % \
3600  (len(self.datasets_to_use) -
3601  len(dataset_names_filtered)))
3602 
3603  self.datasets_to_use = dataset_names_filtered
3604 
3605  self.logger.debug("After processing ignore list there are %d " \
3606  "datasets in the list to be processed" % \
3607  len(self.datasets_to_use))
3608 

References debug, info(), and relativeConstraints.keys.

◆ process_runs_use_and_ignore_lists()

def cmsHarvester.process_runs_use_and_ignore_lists (   self)

Definition at line 3613 of file cmsHarvester.py.

3614 
3615  self.logger.info("Processing list of runs to use and ignore...")
3616 
3617  # This basically adds all runs in a dataset to be processed,
3618  # except for any runs that are not specified in the `to use'
3619  # list and any runs that are specified in the `to ignore'
3620  # list.
3621 
3622  # NOTE: It is assumed that those lists make sense. The input
3623  # should be checked against e.g. overlapping `use' and
3624  # `ignore' lists.
3625 
3626  runs_to_use = self.runs_to_use
3627  runs_to_ignore = self.runs_to_ignore
3628 
3629  for dataset_name in self.datasets_to_use:
3630  runs_in_dataset = self.datasets_information[dataset_name]["runs"]
3631 
3632  # First some sanity checks.
3633  runs_to_use_tmp = []
3634  for run in runs_to_use:
3635  if not run in runs_in_dataset:
3636  self.logger.warning("Dataset `%s' does not contain " \
3637  "requested run %d " \
3638  "--> ignoring `use' of this run" % \
3639  (dataset_name, run))
3640  else:
3641  runs_to_use_tmp.append(run)
3642 
3643  if len(runs_to_use) > 0:
3644  runs = runs_to_use_tmp
3645  self.logger.info("Using %d out of %d runs " \
3646  "of dataset `%s'" % \
3647  (len(runs), len(runs_in_dataset),
3648  dataset_name))
3649  else:
3650  runs = runs_in_dataset
3651 
3652  if len(runs_to_ignore) > 0:
3653  runs_tmp = []
3654  for run in runs:
3655  if not run in runs_to_ignore:
3656  runs_tmp.append(run)
3657  self.logger.info("Ignoring %d out of %d runs " \
3658  "of dataset `%s'" % \
3659  (len(runs)- len(runs_tmp),
3660  len(runs_in_dataset),
3661  dataset_name))
3662  runs = runs_tmp
3663 
3664  if self.todofile != "YourToDofile.txt":
3665  runs_todo = []
3666  print("Reading runs from file /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/harvesting/%s" %self.todofile)
3667  cmd="grep %s /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/harvesting/%s | cut -f5 -d' '" %(dataset_name,self.todofile)
3668  (status, output)=commands.getstatusoutput(cmd)
3669  for run in runs:
3670  run_str="%s" %run
3671  if run_str in output:
3672  runs_todo.append(run)
3673  self.logger.info("Using %d runs " \
3674  "of dataset `%s'" % \
3675  (len(runs_todo),
3676  dataset_name))
3677  runs=runs_todo
3678 
3679  Json_runs = []
3680  if self.Jsonfilename != "YourJSON.txt":
3681  good_runs = []
3682  self.Jsonlumi = True
3683  # We were passed a Jsonfile containing a dictionary of
3684  # run/lunisection-pairs
3685  self.logger.info("Reading runs and lumisections from file `%s'" % \
3686  self.Jsonfilename)
3687  try:
3688  Jsonfile = open(self.Jsonfilename, "r")
3689  for names in Jsonfile:
3690  dictNames= eval(str(names))
3691  for key in dictNames:
3692  intkey=int(key)
3693  Json_runs.append(intkey)
3694  Jsonfile.close()
3695  except IOError:
3696  msg = "ERROR: Could not open Jsonfile `%s'" % \
3697  input_name
3698  self.logger.fatal(msg)
3699  raise Error(msg)
3700  for run in runs:
3701  if run in Json_runs:
3702  good_runs.append(run)
3703  self.logger.info("Using %d runs " \
3704  "of dataset `%s'" % \
3705  (len(good_runs),
3706  dataset_name))
3707  runs=good_runs
3708  if (self.Jsonrunfilename != "YourJSON.txt") and (self.Jsonfilename == "YourJSON.txt"):
3709  good_runs = []
3710  # We were passed a Jsonfile containing a dictionary of
3711  # run/lunisection-pairs
3712  self.logger.info("Reading runs from file `%s'" % \
3713  self.Jsonrunfilename)
3714  try:
3715  Jsonfile = open(self.Jsonrunfilename, "r")
3716  for names in Jsonfile:
3717  dictNames= eval(str(names))
3718  for key in dictNames:
3719  intkey=int(key)
3720  Json_runs.append(intkey)
3721  Jsonfile.close()
3722  except IOError:
3723  msg = "ERROR: Could not open Jsonfile `%s'" % \
3724  input_name
3725  self.logger.fatal(msg)
3726  raise Error(msg)
3727  for run in runs:
3728  if run in Json_runs:
3729  good_runs.append(run)
3730  self.logger.info("Using %d runs " \
3731  "of dataset `%s'" % \
3732  (len(good_runs),
3733  dataset_name))
3734  runs=good_runs
3735 
3736  self.datasets_to_use[dataset_name] = runs
3737 
3738  # End of process_runs_use_and_ignore_lists().
3739 

References info(), edm.print(), and MessageLogger_cfi.warning.

◆ ref_hist_mappings_needed()

def cmsHarvester.ref_hist_mappings_needed (   self,
  dataset_name = None 
)
Check if we need to load and check the reference mappings.

For data the reference histograms should be taken
automatically from the GlobalTag, so we don't need any
mappings. For RelVals we need to know a mapping to be used in
the es_prefer code snippet (different references for each of
the datasets.)

WARNING: This implementation is a bit convoluted.

Definition at line 5171 of file cmsHarvester.py.

5171  def ref_hist_mappings_needed(self, dataset_name=None):
5172  """Check if we need to load and check the reference mappings.
5173 
5174  For data the reference histograms should be taken
5175  automatically from the GlobalTag, so we don't need any
5176  mappings. For RelVals we need to know a mapping to be used in
5177  the es_prefer code snippet (different references for each of
5178  the datasets.)
5179 
5180  WARNING: This implementation is a bit convoluted.
5181 
5182  """
5183 
5184  # If no dataset name given, do everything, otherwise check
5185  # only this one dataset.
5186  if not dataset_name is None:
5187  data_type = self.datasets_information[dataset_name] \
5188  ["datatype"]
5189  mappings_needed = (data_type == "mc")
5190  # DEBUG DEBUG DEBUG
5191  if not mappings_needed:
5192  assert data_type == "data"
5193  # DEBUG DEBUG DEBUG end
5194  else:
5195  tmp = [self.ref_hist_mappings_needed(dataset_name) \
5196  for dataset_name in \
5197  self.datasets_information.keys()]
5198  mappings_needed = (True in tmp)
5199 
5200  # End of ref_hist_mappings_needed.
5201  return mappings_needed
5202 

References relativeConstraints.keys.

◆ run()

def cmsHarvester.run (   self)

Definition at line 5522 of file cmsHarvester.py.

5522  def run(self):
5523  "Main entry point of the CMS harvester."
5524 
5525  # Start with a positive thought.
5526  exit_code = 0
5527 
5528  try:
5529 
5530  try:
5531 
5532  # Parse all command line options and arguments
5533  self.parse_cmd_line_options()
5534  # and check that they make sense.
5535  self.check_input_status()
5536 
5537  # Check if CMSSW is setup.
5538  self.check_cmssw()
5539 
5540  # Check if DBS is setup,
5541  self.check_dbs()
5542  # and if all is fine setup the Python side.
5543  self.setup_dbs()
5544 
5545  # Fill our dictionary with all the required info we
5546  # need to understand harvesting jobs. This needs to be
5547  # done after the CMSSW version is known.
5548  self.setup_harvesting_info()
5549 
5550  # Obtain list of dataset names to consider
5551  self.build_dataset_use_list()
5552  # and the list of dataset names to ignore.
5553  self.build_dataset_ignore_list()
5554 
5555  # The same for the runs lists (if specified).
5556  self.build_runs_use_list()
5557  self.build_runs_ignore_list()
5558 
5559  # Process the list of datasets to ignore and fold that
5560  # into the list of datasets to consider.
5561  # NOTE: The run-based selection is done later since
5562  # right now we don't know yet which runs a dataset
5563  # contains.
5564  self.process_dataset_ignore_list()
5565 
5566  # Obtain all required information on the datasets,
5567  # like run numbers and GlobalTags.
5568  self.build_datasets_information()
5569 
5570  if self.use_ref_hists and \
5571  self.ref_hist_mappings_needed():
5572  # Load the dataset name to reference histogram
5573  # name mappings from file.
5574  self.load_ref_hist_mappings()
5575  # Now make sure that for all datasets we want to
5576  # process there is a reference defined. Otherwise
5577  # just bomb out before wasting any more time.
5578  self.check_ref_hist_mappings()
5579  else:
5580  self.logger.info("No need to load reference " \
5581  "histogram mappings file")
5582 
5583  # OBSOLETE OBSOLETE OBSOLETE

References info(), relativeConstraints.keys, update, and contentValuesCheck.values.

◆ setup_dbs()

def cmsHarvester.setup_dbs (   self)

Now we try to do a very simple DBS search. If that works

instead of giving us the ‘Unsupported API call’ crap, we

should be good to go.

NOTE: Not ideal, I know, but it reduces the amount of

complaints I get...

cmd = "dbs search --query=\"find dataset where dataset = impossible"" (status, output) = commands.getstatusoutput(cmd) pdb.set_trace() if status != 0 or \ output.lower().find("unsupported api call") > -1: self.logger.fatal("It seems DBS is not setup...") self.logger.fatal(" %s returns crap:" % cmd) for line in output.split("\n"): self.logger.fatal(" %s" % line) raise Error("ERROR: DBS needs to be setup first!")

Setup the Python side of DBS.

For more information see the DBS Python API documentation:
https://twiki.cern.ch/twiki/bin/view/CMS/DBSApiDocumentation

Definition at line 2394 of file cmsHarvester.py.

2394  def setup_dbs(self):
2395  """Setup the Python side of DBS.
2396 
2397  For more information see the DBS Python API documentation:
2398  https://twiki.cern.ch/twiki/bin/view/CMS/DBSApiDocumentation
2399 
2400  """
2401 
2402  try:
2403  args={}
2404  args["url"]= "http://cmsdbsprod.cern.ch/cms_dbs_prod_global/" \
2405  "servlet/DBSServlet"
2406  api = DbsApi(args)
2407  self.dbs_api = api
2408 
2409  except DBSAPI.dbsApiException.DbsApiException as ex:
2410  self.logger.fatal("Caught DBS API exception %s: %s " % \
2411  (ex.getClassName(), ex.getErrorMessage()))
2412  if ex.getErrorCode() not in (None, ""):
2413  logger.debug("DBS exception error code: ", ex.getErrorCode())
2414  raise
2415 
2416  # End of setup_dbs.
2417 

◆ setup_harvesting_info()

def cmsHarvester.setup_harvesting_info (   self)
Fill our dictionary with all info needed to understand
harvesting.

This depends on the CMSSW version since at some point the
names and sequences were modified.

NOTE: There is no way (at least not that I could come up with)
to code this in a neat generic way that can be read both by
this method and by option_handler_list_types(). Please try
hard to keep these two methods in sync!

Definition at line 1209 of file cmsHarvester.py.

1209  def setup_harvesting_info(self):
1210  """Fill our dictionary with all info needed to understand
1211  harvesting.
1212 
1213  This depends on the CMSSW version since at some point the
1214  names and sequences were modified.
1215 
1216  NOTE: There is no way (at least not that I could come up with)
1217  to code this in a neat generic way that can be read both by
1218  this method and by option_handler_list_types(). Please try
1219  hard to keep these two methods in sync!
1220 
1221  """
1222 
1223  assert not self.cmssw_version is None, \
1224  "ERROR setup_harvesting() requires " \
1225  "self.cmssw_version to be set!!!"
1226 
1227  harvesting_info = {}
1228 
1229  # This is the version-independent part.
1230  harvesting_info["DQMOffline"] = {}
1231  harvesting_info["DQMOffline"]["beamspot"] = None
1232  harvesting_info["DQMOffline"]["eventcontent"] = None
1233  harvesting_info["DQMOffline"]["harvesting"] = "AtRunEnd"
1234 
1235  harvesting_info["RelVal"] = {}
1236  harvesting_info["RelVal"]["beamspot"] = None
1237  harvesting_info["RelVal"]["eventcontent"] = None
1238  harvesting_info["RelVal"]["harvesting"] = "AtRunEnd"
1239 
1240  harvesting_info["RelValFS"] = {}
1241  harvesting_info["RelValFS"]["beamspot"] = None
1242  harvesting_info["RelValFS"]["eventcontent"] = None
1243  harvesting_info["RelValFS"]["harvesting"] = "AtRunEnd"
1244 
1245  harvesting_info["MC"] = {}
1246  harvesting_info["MC"]["beamspot"] = None
1247  harvesting_info["MC"]["eventcontent"] = None
1248  harvesting_info["MC"]["harvesting"] = "AtRunEnd"
1249 
1250  # This is the version-dependent part. And I know, strictly
1251  # speaking it's not necessary to fill in all three types since
1252  # in a single run we'll only use one type anyway. This does
1253  # look more readable, however, and required less thought from
1254  # my side when I put this together.
1255 
1256  # DEBUG DEBUG DEBUG
1257  # Check that we understand our own version naming.
1258  assert self.cmssw_version.startswith("CMSSW_")
1259  # DEBUG DEBUG DEBUG end
1260 
1261  version = self.cmssw_version[6:]
1262 
1263  #----------
1264 
1265  # RelVal
1266  step_string = None
1267  if version < "3_3_0":
1268  step_string = "validationHarvesting"
1269  elif version in ["3_3_0_pre1", "3_3_0_pre2",
1270  "3_3_0_pre3", "3_3_0_pre4",
1271  "3_3_0_pre6", "3_4_0_pre1"]:
1272  step_string = "validationHarvesting"
1273  else:
1274  step_string = "validationHarvesting+dqmHarvesting"
1275 
1276  harvesting_info["RelVal"]["step_string"] = step_string
1277 
1278  # DEBUG DEBUG DEBUG
1279  # Let's make sure we found something.
1280  assert not step_string is None, \
1281  "ERROR Could not decide a RelVal harvesting sequence " \
1282  "for CMSSW version %s" % self.cmssw_version
1283  # DEBUG DEBUG DEBUG end
1284 
1285  #----------
1286 
1287  # RelVal
1288  step_string = "validationHarvestingFS"
1289 
1290  harvesting_info["RelValFS"]["step_string"] = step_string
1291 
1292  #----------
1293 
1294  # MC
1295  step_string = "validationprodHarvesting"
1296 
1297  harvesting_info["MC"]["step_string"] = step_string
1298 
1299  # DEBUG DEBUG DEBUG
1300  # Let's make sure we found something.
1301  assert not step_string is None, \
1302  "ERROR Could not decide a MC harvesting " \
1303  "sequence for CMSSW version %s" % self.cmssw_version
1304  # DEBUG DEBUG DEBUG end
1305 
1306  #----------
1307 
1308  # DQMOffline
1309  step_string = "dqmHarvesting"
1310 
1311  harvesting_info["DQMOffline"]["step_string"] = step_string
1312 
1313  #----------
1314 
1315  self.harvesting_info = harvesting_info
1316 
1317  self.logger.info("Based on the CMSSW version (%s) " \
1318  "I decided to use the `HARVESTING:%s' " \
1319  "sequence for %s harvesting" % \
1320  (self.cmssw_version,
1321  self.harvesting_info[self.harvesting_type]["step_string"],
1322  self.harvesting_type))
1323 
1324  # End of setup_harvesting_info.
1325 

◆ show_exit_message()

def cmsHarvester.show_exit_message (   self)
Tell the user what to do now, after this part is done.

This should provide the user with some (preferably
copy-pasteable) instructions on what to do now with the setups
and files that have been created.

Definition at line 5469 of file cmsHarvester.py.

5469  def show_exit_message(self):
5470  """Tell the user what to do now, after this part is done.
5471 
5472  This should provide the user with some (preferably
5473  copy-pasteable) instructions on what to do now with the setups
5474  and files that have been created.
5475 
5476  """
5477 
5478  # TODO TODO TODO
5479  # This could be improved a bit.
5480  # TODO TODO TODO end
5481 
5482  sep_line = "-" * 60
5483 
5484  self.logger.info("")
5485  self.logger.info(sep_line)
5486  self.logger.info(" Configuration files have been created.")
5487  self.logger.info(" From here on please follow the usual CRAB instructions.")
5488  self.logger.info(" Quick copy-paste instructions are shown below.")
5489  self.logger.info(sep_line)
5490 
5491  self.logger.info("")
5492  self.logger.info(" Create all CRAB jobs:")
5493  self.logger.info(" multicrab -create")
5494  self.logger.info("")
5495  self.logger.info(" Submit all CRAB jobs:")
5496  self.logger.info(" multicrab -submit")
5497  self.logger.info("")
5498  self.logger.info(" Check CRAB status:")
5499  self.logger.info(" multicrab -status")
5500  self.logger.info("")
5501 
5502  self.logger.info("")
5503  self.logger.info(" For more information please see the CMS Twiki:")
5504  self.logger.info(" %s" % twiki_url)
5505  self.logger.info(sep_line)
5506 
5507  # If there were any jobs for which we could not find a
5508  # matching site show a warning message about that.
5509  if not self.all_sites_found:
5510  self.logger.warning(" For some of the jobs no matching " \
5511  "site could be found")
5512  self.logger.warning(" --> please scan your multicrab.cfg" \
5513  "for occurrences of `%s'." % \
5514  self.no_matching_site_found_str)
5515  self.logger.warning(" You will have to fix those " \
5516  "by hand, sorry.")
5517 
5518  # End of show_exit_message.
5519 

References info(), and MessageLogger_cfi.warning.

◆ singlify_datasets()

def cmsHarvester.singlify_datasets (   self)
Remove all but the largest part of all datasets.

This allows us to harvest at least part of these datasets
using single-step harvesting until the two-step approach
works.

Definition at line 3742 of file cmsHarvester.py.

3742  def singlify_datasets(self):
3743  """Remove all but the largest part of all datasets.
3744 
3745  This allows us to harvest at least part of these datasets
3746  using single-step harvesting until the two-step approach
3747  works.
3748 
3749  """
3750 
3751  # DEBUG DEBUG DEBUG
3752  assert self.harvesting_mode == "single-step-allow-partial"
3753  # DEBUG DEBUG DEBUG end
3754 
3755  for dataset_name in self.datasets_to_use:
3756  for run_number in self.datasets_information[dataset_name]["runs"]:
3757  max_events = max(self.datasets_information[dataset_name]["sites"][run_number].values())
3758  sites_with_max_events = [i[0] for i in self.datasets_information[dataset_name]["sites"][run_number].items() if i[1] == max_events]
3759  self.logger.warning("Singlifying dataset `%s', " \
3760  "run %d" % \
3761  (dataset_name, run_number))
3762  cmssw_version = self.datasets_information[dataset_name] \
3763  ["cmssw_version"]
3764  selected_site = self.pick_a_site(sites_with_max_events,
3765  cmssw_version)
3766 
3767  # Let's tell the user that we're manhandling this dataset.
3768  nevents_old = self.datasets_information[dataset_name]["num_events"][run_number]
3769  self.logger.warning(" --> " \
3770  "only harvesting partial statistics: " \
3771  "%d out of %d events (5.1%f%%) " \
3772  "at site `%s'" % \
3773  (max_events,
3774  nevents_old,
3775  100. * max_events / nevents_old,
3776  selected_site))
3777  self.logger.warning("!!! Please note that the number of " \
3778  "events in the output path name will " \
3779  "NOT reflect the actual statistics in " \
3780  "the harvested results !!!")
3781 
3782  # We found the site with the highest statistics and
3783  # the corresponding number of events. (CRAB gets upset
3784  # if we ask for more events than there are at a given
3785  # site.) Now update this information in our main
3786  # datasets_information variable.
3787  self.datasets_information[dataset_name]["sites"][run_number] = {selected_site: max_events}
3788  self.datasets_information[dataset_name]["num_events"][run_number] = max_events
3789  #self.datasets_information[dataset_name]["sites"][run_number] = [selected_site]
3790 
3791  # End of singlify_datasets.
3792 

References mps_monitormerge.items, SiStripPI.max, contentValuesCheck.values, and MessageLogger_cfi.warning.

◆ write_crab_config()

def cmsHarvester.write_crab_config (   self)

def create_harvesting_config(self, dataset_name): """Create the Python harvesting configuration for a given job.

NOTE: The reason to have a single harvesting configuration per sample is to be able to specify the GlobalTag corresponding to each sample. Since it has been decided that (apart from the prompt reco) datasets cannot contain runs with different GlobalTags, we don't need a harvesting config per run. NOTE: This is the place where we distinguish between single-step and two-step harvesting modes (at least for the Python job configuration). """

autotoc_md221

if self.harvesting_mode == "single-step": config_contents = self.create_harvesting_config_single_step(dataset_name) elif self.harvesting_mode == "two-step": config_contents = self.create_harvesting_config_two_step(dataset_name) else:

Impossible harvesting mode, we should never get here.

assert False, "ERROR: unknown harvesting mode `%s'" % \ self.harvesting_mode

autotoc_md223

End of create_harvesting_config.

return config_contents

Write a CRAB job configuration Python file.

Definition at line 5047 of file cmsHarvester.py.

5047  def write_crab_config(self):
5048  """Write a CRAB job configuration Python file.
5049 
5050  """
5051 
5052  self.logger.info("Writing CRAB configuration...")
5053 
5054  file_name_base = "crab.cfg"
5055 
5056  # Create CRAB configuration.
5057  crab_contents = self.create_crab_config()
5058 
5059  # Write configuration to file.
5060  crab_file_name = file_name_base
5061  try:
5062  crab_file = file(crab_file_name, "w")
5063  crab_file.write(crab_contents)
5064  crab_file.close()
5065  except IOError:
5066  self.logger.fatal("Could not write " \
5067  "CRAB configuration to file `%s'" % \
5068  crab_file_name)
5069  raise Error("ERROR: Could not write to file `%s'!" % \
5070  crab_file_name)
5071 
5072  # End of write_crab_config.
5073 

References FrontierConditions_GlobalTag_cff.file, and info().

◆ write_harvesting_config()

def cmsHarvester.write_harvesting_config (   self,
  dataset_name 
)
Write a harvesting job configuration Python file.

NOTE: This knows nothing about single-step or two-step
harvesting. That's all taken care of by
create_harvesting_config.

Definition at line 5105 of file cmsHarvester.py.

5105  def write_harvesting_config(self, dataset_name):
5106  """Write a harvesting job configuration Python file.
5107 
5108  NOTE: This knows nothing about single-step or two-step
5109  harvesting. That's all taken care of by
5110  create_harvesting_config.
5111 
5112  """
5113 
5114  self.logger.debug("Writing harvesting configuration for `%s'..." % \
5115  dataset_name)
5116 
5117  # Create Python configuration.
5118  config_contents = self.create_harvesting_config(dataset_name)
5119 
5120  # Write configuration to file.
5121  config_file_name = self. \
5123  try:
5124  config_file = file(config_file_name, "w")
5125  config_file.write(config_contents)
5126  config_file.close()
5127  except IOError:
5128  self.logger.fatal("Could not write " \
5129  "harvesting configuration to file `%s'" % \
5130  config_file_name)
5131  raise Error("ERROR: Could not write to file `%s'!" % \
5132  config_file_name)
5133 
5134  # End of write_harvesting_config.
5135 

References create_harvesting_config_file_name(), debug, and FrontierConditions_GlobalTag_cff.file.

◆ write_me_extraction_config()

def cmsHarvester.write_me_extraction_config (   self,
  dataset_name 
)
Write an ME-extraction configuration Python file.

This `ME-extraction' (ME = Monitoring Element) is the first
step of the two-step harvesting.

Definition at line 5138 of file cmsHarvester.py.

5138  def write_me_extraction_config(self, dataset_name):
5139  """Write an ME-extraction configuration Python file.
5140 
5141  This `ME-extraction' (ME = Monitoring Element) is the first
5142  step of the two-step harvesting.
5143 
5144  """
5145 
5146  self.logger.debug("Writing ME-extraction configuration for `%s'..." % \
5147  dataset_name)
5148 
5149  # Create Python configuration.
5150  config_contents = self.create_me_extraction_config(dataset_name)
5151 
5152  # Write configuration to file.
5153  config_file_name = self. \
5155  try:
5156  config_file = file(config_file_name, "w")
5157  config_file.write(config_contents)
5158  config_file.close()
5159  except IOError:
5160  self.logger.fatal("Could not write " \
5161  "ME-extraction configuration to file `%s'" % \
5162  config_file_name)
5163  raise Error("ERROR: Could not write to file `%s'!" % \
5164  config_file_name)
5165 
5166  # End of write_me_extraction_config.
5167 

References create_me_summary_config_file_name(), debug, and FrontierConditions_GlobalTag_cff.file.

◆ write_multicrab_config()

def cmsHarvester.write_multicrab_config (   self)
Write a multi-CRAB job configuration Python file.

Definition at line 5076 of file cmsHarvester.py.

5076  def write_multicrab_config(self):
5077  """Write a multi-CRAB job configuration Python file.
5078 
5079  """
5080 
5081  self.logger.info("Writing multi-CRAB configuration...")
5082 
5083  file_name_base = "multicrab.cfg"
5084 
5085  # Create multi-CRAB configuration.
5086  multicrab_contents = self.create_multicrab_config()
5087 
5088  # Write configuration to file.
5089  multicrab_file_name = file_name_base
5090  try:
5091  multicrab_file = file(multicrab_file_name, "w")
5092  multicrab_file.write(multicrab_contents)
5093  multicrab_file.close()
5094  except IOError:
5095  self.logger.fatal("Could not write " \
5096  "multi-CRAB configuration to file `%s'" % \
5097  multicrab_file_name)
5098  raise Error("ERROR: Could not write to file `%s'!" % \
5099  multicrab_file_name)
5100 
5101  # End of write_multicrab_config.
5102 

References FrontierConditions_GlobalTag_cff.file, and info().

Variable Documentation

◆ __author__

cmsHarvester.__author__
private

Definition at line 40 of file cmsHarvester.py.

◆ __version__

cmsHarvester.__version__
private

Definition at line 39 of file cmsHarvester.py.

◆ all_file_names

cmsHarvester.all_file_names

Definition at line 3232 of file cmsHarvester.py.

◆ all_sites_found

cmsHarvester.all_sites_found

CAF

Definition at line 1864 of file cmsHarvester.py.

◆ caf_access

cmsHarvester.caf_access

Definition at line 1109 of file cmsHarvester.py.

◆ castor_base_dir

cmsHarvester.castor_base_dir

Definition at line 1078 of file cmsHarvester.py.

◆ castor_path_checks_cache

cmsHarvester.castor_path_checks_cache

self.logger.debug("Path is now `%s'" % \ path)

Definition at line 1604 of file cmsHarvester.py.

◆ castor_path_common

cmsHarvester.castor_path_common

DEBUG DEBUG DEBUG

This is probably only useful to make sure we don't muck

things up, right?

Figure out across how many sites this sample has been spread.

if num_sites == 1: self.logger.info(" sample is contained at a single site") else: self.logger.info(" sample is spread across %d sites" % \ num_sites) if num_sites < 1:

NOTE: This <em>should not</em> happen with any valid dataset.

self.logger.warning(" --> skipping dataset which is not " \ "hosted anywhere")

DEBUG DEBUG DEBUG end

Definition at line 5453 of file cmsHarvester.py.

◆ castor_paths

cmsHarvester.castor_paths

Definition at line 5457 of file cmsHarvester.py.

◆ cmd

cmsHarvester.cmd

Definition at line 1633 of file cmsHarvester.py.

◆ cmd_line_opts

cmsHarvester.cmd_line_opts

Definition at line 2170 of file cmsHarvester.py.

◆ cmssw_version

cmsHarvester.cmssw_version

Definition at line 2348 of file cmsHarvester.py.

◆ complete_sites

cmsHarvester.complete_sites

site_names_ref = set(files_info[run_number].values()[0][1]) for site_names_tmp in files_info[run_number].values()[1:]: if set(site_names_tmp[1]) != site_names_ref: mirrored = False break

Definition at line 3277 of file cmsHarvester.py.

◆ config_contents

cmsHarvester.config_contents

In case this file is the second step (the real harvesting

step) of the two-step harvesting we have to tell it to use

our local files.

if self.harvesting_mode == "two-step": castor_dir = self.datasets_information[dataset_name] \ ["castor_path"][run] customisations.append("") customisations.append("# This is the second step (the real") customisations.append("# harvesting step) of a two-step") customisations.append("# harvesting procedure.")

BUG BUG BUG

To be removed in production version.

customisations.append("import pdb")

BUG BUG BUG end

customisations.append("import commands") customisations.append("import os") customisations.append("castor_dir = \"s"" % castor_dir) customisations.append("cmd = "rfdir s" % castor_dir") customisations.append("(status, output) = commands.getstatusoutput(cmd)") customisations.append("if status != 0:") customisations.append(" print "ERROR"") customisations.append(" raise Exception, "ERROR"") customisations.append("file_names = [os.path.join("rfio:s" % path, i) for i in output.split() if i.startswith("EDM_summary") and i.endswith(".root")]") #customisations.append("pdb.set_trace()") customisations.append("process.source.fileNames = cms.untracked.vstring(*file_names)") customisations.append("")

Definition at line 4926 of file cmsHarvester.py.

◆ config_file_name

cmsHarvester.config_file_name

Only add the alarming piece to the file name if this is

a spread-out dataset.

pdb.set_trace() if self.datasets_information[dataset_name] \ ["mirrored"][run_number] == False: config_file_name = config_file_name.replace(".py", "_partial.py")

Definition at line 4086 of file cmsHarvester.py.

◆ crab_submission

cmsHarvester.crab_submission

Definition at line 1136 of file cmsHarvester.py.

◆ dataset_names_after_checks

cmsHarvester.dataset_names_after_checks

Definition at line 4031 of file cmsHarvester.py.

◆ dataset_names_after_checks_tmp

cmsHarvester.dataset_names_after_checks_tmp

Definition at line 4024 of file cmsHarvester.py.

◆ datasets_information

cmsHarvester.datasets_information

Definition at line 5341 of file cmsHarvester.py.

◆ datasets_to_ignore

cmsHarvester.datasets_to_ignore

Definition at line 3458 of file cmsHarvester.py.

◆ datasets_to_use

cmsHarvester.datasets_to_use

Definition at line 4040 of file cmsHarvester.py.

◆ dbs_api

cmsHarvester.dbs_api

Definition at line 2407 of file cmsHarvester.py.

◆ empty_runs

cmsHarvester.empty_runs

Definition at line 4008 of file cmsHarvester.py.

◆ exit_code

cmsHarvester.exit_code

Definition at line 5690 of file cmsHarvester.py.

◆ file_name

cmsHarvester.file_name

Definition at line 3176 of file cmsHarvester.py.

◆ files_at_site

cmsHarvester.files_at_site

Definition at line 3236 of file cmsHarvester.py.

◆ files_info

cmsHarvester.files_info

Definition at line 3162 of file cmsHarvester.py.

◆ files_without_sites

cmsHarvester.files_without_sites

Definition at line 3202 of file cmsHarvester.py.

◆ globaltag

cmsHarvester.globaltag

Definition at line 2308 of file cmsHarvester.py.

◆ harvesting_info

cmsHarvester.harvesting_info

Definition at line 1315 of file cmsHarvester.py.

◆ harvesting_mode

cmsHarvester.harvesting_mode

Definition at line 2217 of file cmsHarvester.py.

◆ harvesting_type

cmsHarvester.harvesting_type

Definition at line 3859 of file cmsHarvester.py.

◆ Jsonfilename

cmsHarvester.Jsonfilename

Definition at line 3708 of file cmsHarvester.py.

◆ Jsonlumi

cmsHarvester.Jsonlumi

CRAB

CRAB

Definition at line 3682 of file cmsHarvester.py.

◆ mirrored

cmsHarvester.mirrored

Definition at line 3223 of file cmsHarvester.py.

◆ msg

cmsHarvester.msg

class Handler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): if name == "result": site_name = str(attrs["STORAGEELEMENT_SENAME"])

TODO TODO TODO

Ugly hack to get around cases like this:

$ dbs search –query="find dataset, site, file.count where dataset=/RelValQCD_Pt_3000_3500/CMSSW_3_3_0_pre1-STARTUP31X_V4-v1/GEN-SIM-RECO"

Using DBS instance at: http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet

Processing ... @section autotoc_md189 PATH STORAGEELEMENT_SENAME COUNT_FILES

Definition at line 1641 of file cmsHarvester.py.

◆ nevents

cmsHarvester.nevents

◆ non_t1access

cmsHarvester.non_t1access

Definition at line 1093 of file cmsHarvester.py.

◆ nr_max_sites

cmsHarvester.nr_max_sites

Definition at line 1144 of file cmsHarvester.py.

◆ num_events_catalog

cmsHarvester.num_events_catalog

Definition at line 3216 of file cmsHarvester.py.

◆ num_events_dataset

cmsHarvester.num_events_dataset

Definition at line 3986 of file cmsHarvester.py.

◆ num_sites

cmsHarvester.num_sites

if self.datasets_information[dataset_name]["num_events"][run_number] != 0: pdb.set_trace() DEBUG DEBUG DEBUG end

Definition at line 3956 of file cmsHarvester.py.

◆ option_parser

cmsHarvester.option_parser

Definition at line 1880 of file cmsHarvester.py.

◆ output

cmsHarvester.output

Definition at line 1634 of file cmsHarvester.py.

◆ path

cmsHarvester.path

else:

Piece not in the list, fine.

self.logger.debug(" accepting") Add piece to the path we're building. self.logger.debug("!!! Skip path piece `%s'? %s" % \ (piece, str(skip_this_path_piece))) self.logger.debug("Adding piece to path...")

Definition at line 1593 of file cmsHarvester.py.

◆ permissions

cmsHarvester.permissions

Definition at line 1650 of file cmsHarvester.py.

Referenced by cond::CredentialStore.updatePrincipal().

◆ permissions_new

cmsHarvester.permissions_new

Definition at line 1680 of file cmsHarvester.py.

◆ permissions_target

cmsHarvester.permissions_target

Definition at line 1674 of file cmsHarvester.py.

◆ preferred_site

cmsHarvester.preferred_site

Definition at line 1150 of file cmsHarvester.py.

◆ ref_hist_mappings_file_name

cmsHarvester.ref_hist_mappings_file_name

Definition at line 2259 of file cmsHarvester.py.

◆ run_number

cmsHarvester.run_number

Definition at line 3175 of file cmsHarvester.py.

◆ runs_to_ignore

cmsHarvester.runs_to_ignore

Definition at line 3555 of file cmsHarvester.py.

◆ runs_to_use

cmsHarvester.runs_to_use

Definition at line 3531 of file cmsHarvester.py.

◆ saveByLumiSection

cmsHarvester.saveByLumiSection

Definition at line 1123 of file cmsHarvester.py.

◆ site_names

cmsHarvester.site_names

Definition at line 3218 of file cmsHarvester.py.

◆ sites_with_complete_copies

cmsHarvester.sites_with_complete_copies

Definition at line 3234 of file cmsHarvester.py.

◆ skip_this_path_piece

cmsHarvester.skip_this_path_piece

self.logger.debug("Checking CASTOR path piece `%s'" % \ piece)

self.logger.debug("Checking `%s' against `%s'" % \ (castor_path_pieces[piece_index + check_size], castor_paths_dont_touch[check_size])) self.logger.debug(" skipping")

Definition at line 1585 of file cmsHarvester.py.

◆ status

cmsHarvester.status

Definition at line 1634 of file cmsHarvester.py.

◆ tmp

cmsHarvester.tmp

tmp = self.datasets_information[dataset_name] \ ["num_events"]

TODO TODO TODO

Need to think about where this should go, but

somewhere we have to move over the fact that we want

to process all runs for each dataset that we're

considering. This basically means copying over the

information from self.datasets_information[]["runs"]

to self.datasets_to_use[].

for dataset_name in self.datasets_to_use.keys(): self.datasets_to_use[dataset_name] = self.datasets_information[dataset_name]["runs"]

TODO TODO TODO end

OBSOLETE OBSOLETE OBSOLETE end

Definition at line 3983 of file cmsHarvester.py.

◆ traceback_string

cmsHarvester.traceback_string

Definition at line 5715 of file cmsHarvester.py.

◆ twiki_url

cmsHarvester.twiki_url

Definition at line 43 of file cmsHarvester.py.

cmsHarvester.option_handler_saveByLumiSection
def option_handler_saveByLumiSection(self, option, opt_str, value, parser)
Definition: cmsHarvester.py:1120
cmsHarvester.write_me_extraction_config
def write_me_extraction_config(self, dataset_name)
Definition: cmsHarvester.py:5138
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
cmsHarvester.dbs_resolve_runs
def dbs_resolve_runs(self, dataset_name)
def dbs_resolve_dataset_number_of_events(self, dataset_name): """Ask DBS across how many events this ...
Definition: cmsHarvester.py:2570
cmsHarvester.create_es_prefer_snippet
def create_es_prefer_snippet(self, dataset_name)
Definition: cmsHarvester.py:4689
cmsHarvester.run
def run(self)
Definition: cmsHarvester.py:5522
cmsHarvester.option_handler_sites
def option_handler_sites(self, option, opt_str, value, parser)
Definition: cmsHarvester.py:1142
cmsHarvester.escape_dataset_name
def escape_dataset_name(self, dataset_name)
Definition: cmsHarvester.py:4046
cmsHarvester.singlify_datasets
def singlify_datasets(self)
Definition: cmsHarvester.py:3742
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
cmsHarvester.dbs_check_dataset_spread
def dbs_check_dataset_spread(self, dataset_name)
def dbs_resolve_dataset_number_of_sites(self, dataset_name): """Ask DBS across how many sites this da...
Definition: cmsHarvester.py:3077
cmsHarvester.write_harvesting_config
def write_harvesting_config(self, dataset_name)
Definition: cmsHarvester.py:5105
cmsHarvester.create_me_extraction_config
def create_me_extraction_config(self, dataset_name)
def create_harvesting_config_two_step(self, dataset_name): """Create the Python harvesting configurat...
Definition: cmsHarvester.py:4950
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
cmsHarvester.create_multicrab_config
def create_multicrab_config(self)
Definition: cmsHarvester.py:4313
cms::cuda::assert
assert(be >=bs)
cmsHarvester.process_runs_use_and_ignore_lists
def process_runs_use_and_ignore_lists(self)
Definition: cmsHarvester.py:3613
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
cmsHarvester.build_datasets_information
def build_datasets_information(self)
Definition: cmsHarvester.py:5321
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
cmsHarvester.create_output_file_name
def create_output_file_name(self, dataset_name, run_number=None)
Definition: cmsHarvester.py:4125
cmsHarvester.create_castor_path_name_special
def create_castor_path_name_special(self, dataset_name, run_number, castor_path_common)
Definition: cmsHarvester.py:1382
cms::dd::split
std::vector< std::string_view > split(std::string_view, const char *)
cmsHarvester.create_castor_path_name_common
def create_castor_path_name_common(self, dataset_name)
Definition: cmsHarvester.py:1328
cmsHarvester.build_runs_ignore_list
def build_runs_ignore_list(self)
Definition: cmsHarvester.py:3542
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
cmsHarvester.dbs_resolve_dataset_name
def dbs_resolve_dataset_name(self, dataset_name)
Definition: cmsHarvester.py:2420
cmsHarvester.create_config_file_name
def create_config_file_name(self, dataset_name, run_number)
Definition: cmsHarvester.py:4065
relativeConstraints.error
error
Definition: relativeConstraints.py:53
ConfigBuilder
Definition: ConfigBuilder.py:1
MessageLogger_cfi.warning
warning
Definition: MessageLogger_cfi.py:18
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
cmsHarvester.option_handler_crab_submission
def option_handler_crab_submission(self, option, opt_str, value, parser)
Definition: cmsHarvester.py:1132
cmsHarvester.option_handler_preferred_site
def option_handler_preferred_site(self, option, opt_str, value, parser)
Definition: cmsHarvester.py:1148
debug
#define debug
Definition: HDRShower.cc:19
cmsHarvester.build_dataset_list
def build_dataset_list(self, input_method, input_name)
def dbs_check_dataset_num_events(self, dataset_name): """Figure out the number of events in each run ...
Definition: cmsHarvester.py:3358
cmsHarvester.build_dataset_ignore_list
def build_dataset_ignore_list(self)
Definition: cmsHarvester.py:3444
cmsHarvester.write_multicrab_config
def write_multicrab_config(self)
Definition: cmsHarvester.py:5076
cmsHarvester.check_ref_hist_mappings
def check_ref_hist_mappings(self)
Definition: cmsHarvester.py:5281
cmsHarvester.check_cmssw
def check_cmssw(self)
Definition: cmsHarvester.py:2334
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
cmsHarvester.create_multicrab_block_name
def create_multicrab_block_name(self, dataset_name, run_number, index)
Definition: cmsHarvester.py:4216
cmsHarvester.create_harvesting_config_file_name
def create_harvesting_config_file_name(self, dataset_name)
Definition: cmsHarvester.py:4097
str
#define str(s)
Definition: TestProcessor.cc:48
cmsHarvester.check_ref_hist_tag
def check_ref_hist_tag(self, tag_name)
Definition: cmsHarvester.py:4643
cmsHarvester.write_crab_config
def write_crab_config(self)
def create_harvesting_config(self, dataset_name): """Create the Python harvesting configuration for a...
Definition: cmsHarvester.py:5047
cmsHarvester.option_handler_caf_access
def option_handler_caf_access(self, option, opt_str, value, parser)
Definition: cmsHarvester.py:1104
cmsHarvester.check_input_status
def check_input_status(self)
Definition: cmsHarvester.py:2193
cmsHarvester.setup_harvesting_info
def setup_harvesting_info(self)
Definition: cmsHarvester.py:1209
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
cmsHarvester.create_me_summary_config_file_name
def create_me_summary_config_file_name(self, dataset_name)
Definition: cmsHarvester.py:4111
cmsHarvester.build_runs_use_list
def build_runs_use_list(self)
Definition: cmsHarvester.py:3521
mps_setup.append
append
Definition: mps_setup.py:85
cmsHarvester.pick_a_site
def pick_a_site(self, sites, cmssw_version)
Definition: cmsHarvester.py:1707
leef::Error
edm::ErrorSummaryEntry Error
Definition: LogErrorEventFilter.cc:29
cmsHarvester.dbs_resolve_globaltag
def dbs_resolve_globaltag(self, dataset_name)
Definition: cmsHarvester.py:2627
createfilelist.int
int
Definition: createfilelist.py:10
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
cmsHarvester.show_exit_message
def show_exit_message(self)
Definition: cmsHarvester.py:5469
cmsHarvester.build_runs_list
def build_runs_list(self, input_method, input_name)
Definition: cmsHarvester.py:3470
cmsHarvester.process_dataset_ignore_list
def process_dataset_ignore_list(self)
Definition: cmsHarvester.py:3566
cmsHarvester.check_dataset_list
def check_dataset_list(self)
Definition: cmsHarvester.py:3795
cmsHarvester.create_crab_config
def create_crab_config(self)
Definition: cmsHarvester.py:4233
cmsHarvester.ref_hist_mappings_needed
def ref_hist_mappings_needed(self, dataset_name=None)
Definition: cmsHarvester.py:5171
cmsHarvester.check_globaltag
def check_globaltag(self, globaltag=None)
Definition: cmsHarvester.py:4501
cmsHarvester.check_globaltag_contains_ref_hist_key
def check_globaltag_contains_ref_hist_key(self, globaltag, connect_name)
Definition: cmsHarvester.py:4598
cmsHarvester.build_dataset_use_list
def build_dataset_use_list(self)
Definition: cmsHarvester.py:3421
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
ComparisonHelper::zip
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
Definition: L1TStage2CaloLayer1.h:38
cmsHarvester.create_harvesting_output_file_name
def create_harvesting_output_file_name(self, dataset_name, run_number)
Definition: cmsHarvester.py:4169
cmsHarvester.parse_cmd_line_options
def parse_cmd_line_options(self)
Definition: cmsHarvester.py:1871
cmsHarvester.option_handler_no_t1access
def option_handler_no_t1access(self, option, opt_str, value, parser)
Definition: cmsHarvester.py:1087
cmsHarvester.check_globaltag_exists
def check_globaltag_exists(self, globaltag, connect_name)
Definition: cmsHarvester.py:4556
cmsHarvester.dbs_resolve_number_of_events
def dbs_resolve_number_of_events(self, dataset_name, run_number=None)
Definition: cmsHarvester.py:2736
cmsHarvester.dbs_resolve_datatype
def dbs_resolve_datatype(self, dataset_name)
Definition: cmsHarvester.py:2683
MatrixUtil.remove
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:212
edm::eventsetup::heterocontainer::insert
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
cmsHarvester.option_handler_list_types
def option_handler_list_types(self, option, opt_str, value, parser)
Definition: cmsHarvester.py:1154
cmsHarvester.check_dbs
def check_dbs(self)
Definition: cmsHarvester.py:2357
cmsHarvester.create_and_check_castor_dir
def create_and_check_castor_dir(self, castor_dir)
Definition: cmsHarvester.py:1491
cmsHarvester.option_handler_castor_dir
def option_handler_castor_dir(self, option, opt_str, value, parser)
def option_handler_dataset_name(self, option, opt_str, value, parser): """Specify the name(s) of the ...
Definition: cmsHarvester.py:1062
list
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*", "!HLTx*" if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL. It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of "!*" before the partial wildcard feature was incorporated). Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
cmsHarvester.setup_dbs
def setup_dbs(self)
Definition: cmsHarvester.py:2394
cmsHarvester.dbs_resolve_cmssw_version
def dbs_resolve_cmssw_version(self, dataset_name)
Definition: cmsHarvester.py:2476
cmsHarvester.create_and_check_castor_dirs
def create_and_check_castor_dirs(self)
Definition: cmsHarvester.py:1432
cmsHarvester.create_harvesting_config
def create_harvesting_config(self, dataset_name)
Definition: cmsHarvester.py:4724
cmsHarvester.load_ref_hist_mappings
def load_ref_hist_mappings(self)
Definition: cmsHarvester.py:5205
cmsHarvester.create_me_summary_output_file_name
def create_me_summary_output_file_name(self, dataset_name)
Definition: cmsHarvester.py:4201
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444