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 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_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_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_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 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_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 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

More...
 
 caf_access
 
 castor_base_dir
 
 castor_path_checks_cache
 self.logger.debug("Path is now `%s'" % \ path) More...
 
 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.

More...
 
 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
 

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.

More...
 
 config_file_name
 

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

a spread-out dataset.

More...
 
 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
 

CRAB

More...
 
 mirrored
 
 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 ...

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:

Piece not in the list, fine.

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
 

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.

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 3443 of file cmsHarvester.py.

References info().

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

◆ build_dataset_list()

def cmsHarvester.build_dataset_list (   self,
  input_method,
  input_name 
)
Build a list of all datasets to be processed.

Definition at line 3357 of file cmsHarvester.py.

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

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

◆ build_dataset_use_list()

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

Definition at line 3420 of file cmsHarvester.py.

References info(), and reco.zip().

3420  def build_dataset_use_list(self):
3421  """Build a list of datasets to process.
3422 
3423  """
3424 
3425  self.logger.info("Building list of datasets to consider...")
3426 
3427  input_method = self.input_method["datasets"]["use"]
3428  input_name = self.input_name["datasets"]["use"]
3429  dataset_names = self.build_dataset_list(input_method,
3430  input_name)
3431  self.datasets_to_use = dict(list(zip(dataset_names,
3432  [None] * len(dataset_names))))
3433 
3434  self.logger.info(" found %d dataset(s) to process:" % \
3435  len(dataset_names))
3436  for dataset in dataset_names:
3437  self.logger.info(" `%s'" % dataset)
3438 
3439  # End of build_dataset_use_list.
3440 
static const TGPicture * info(bool iBackgroundIsBlack)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float zip(ConstView const &tracks, int32_t i)
Definition: TracksSoA.h:90
def build_dataset_use_list(self)

◆ 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 5285 of file cmsHarvester.py.

5285  def build_datasets_information(self):
5286  """Obtain all information on the datasets that we need to run.
5287 
5288  Use DBS to figure out all required information on our
5289  datasets, like the run numbers and the GlobalTag. All
5290  information is stored in the datasets_information member
5291  variable.
5292 
5293  """
5294 
5295  # Get a list of runs in the dataset.
5296  # NOTE: The harvesting has to be done run-by-run, so we
5297  # split up datasets based on the run numbers. Strictly
5298  # speaking this is not (yet?) necessary for Monte Carlo
5299  # since all those samples use run number 1. Still, this
5300  # general approach should work for all samples.
5301 
5302  # Now loop over all datasets in the list and process them.
5303  # NOTE: This processing has been split into several loops
5304  # to be easier to follow, sacrificing a bit of efficiency.
5305  self.datasets_information = {}
5306  self.logger.info("Collecting information for all datasets to process")
5307  dataset_names = sorted(self.datasets_to_use.keys())
5308  for dataset_name in dataset_names:
5309 
5310  # Tell the user which dataset: nice with many datasets.
5311  sep_line = "-" * 30
5312  self.logger.info(sep_line)
5313  self.logger.info(" `%s'" % dataset_name)
5314  self.logger.info(sep_line)
5315 
5316  runs = self.dbs_resolve_runs(dataset_name)
5317  self.logger.info(" found %d run(s)" % len(runs))
5318  if len(runs) > 0:
5319  self.logger.debug(" run number(s): %s" % \
5320  ", ".join([str(i) for i in runs]))
5321  else:
5322  # DEBUG DEBUG DEBUG
5323  # This should never happen after the DBS checks.
5324  self.logger.warning(" --> skipping dataset "
5325  "without any runs")
5326  assert False, "Panic: found a dataset without runs " \
5327  "after DBS checks!"
5328  # DEBUG DEBUG DEBUG end
5329 
5330  cmssw_version = self.dbs_resolve_cmssw_version(dataset_name)
5331  self.logger.info(" found CMSSW version `%s'" % cmssw_version)
5332 
5333  # Figure out if this is data or MC.
5334  datatype = self.dbs_resolve_datatype(dataset_name)
5335  self.logger.info(" sample is data or MC? --> %s" % \
5336  datatype)
5337 
5338 
5339 
5340  # Try and figure out the GlobalTag to be used.
5341  if self.globaltag is None:
5342  globaltag = self.dbs_resolve_globaltag(dataset_name)
5343  else:
5344  globaltag = self.globaltag
5345 
5346  self.logger.info(" found GlobalTag `%s'" % globaltag)
5347 
5348  # DEBUG DEBUG DEBUG
5349  if globaltag == "":
5350  # Actually we should not even reach this point, after
5351  # our dataset sanity checks.
5352  assert datatype == "data", \
5353  "ERROR Empty GlobalTag for MC dataset!!!"
5354  # DEBUG DEBUG DEBUG end
5355 
5356 
5357 
5358  # DEBUG DEBUG DEBUG
5359  #tmp = self.dbs_check_dataset_spread_old(dataset_name)
5360  # DEBUG DEBUG DEBUG end
5361  sites_catalog = self.dbs_check_dataset_spread(dataset_name)
5362 
5363  # Extract the total event counts.
5364  num_events = {}
5365  for run_number in sites_catalog.keys():
5366  num_events[run_number] = sites_catalog \
5367  [run_number]["all_sites"]
5368  del sites_catalog[run_number]["all_sites"]
5369 
5370  # Extract the information about whether or not datasets
5371  # are mirrored.
5372  mirror_catalog = {}
5373  for run_number in sites_catalog.keys():
5374  mirror_catalog[run_number] = sites_catalog \
5375  [run_number]["mirrored"]
5376  del sites_catalog[run_number]["mirrored"]
5377 
5378  # BUG BUG BUG
5379  # I think I could now get rid of that and just fill the
5380  # "sites" entry with the `inverse' of this
5381  # num_events_catalog(?).
5382  #num_sites = self.dbs_resolve_dataset_number_of_sites(dataset_name)
5383  #sites_catalog = self.dbs_check_dataset_spread(dataset_name)
5384  #sites_catalog = dict(zip(num_events_catalog.keys(),
5385  # [[j for i in num_events_catalog.values() for j in i.keys()]]))
5386  # BUG BUG BUG end
5387 
static const TGPicture * info(bool iBackgroundIsBlack)
def build_datasets_information(self)
#define debug
Definition: HDRShower.cc:19
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
#define str(s)

◆ 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 3541 of file cmsHarvester.py.

References info().

3541  def build_runs_ignore_list(self):
3542  """Build a list of runs to ignore.
3543 
3544  NOTE: We should always have a list of runs to process, but
3545  it may be that we don't have a list of runs to ignore.
3546 
3547  """
3548 
3549  self.logger.info("Building list of runs to ignore...")
3550 
3551  input_method = self.input_method["runs"]["ignore"]
3552  input_name = self.input_name["runs"]["ignore"]
3553  runs = self.build_runs_list(input_method, input_name)
3554  self.runs_to_ignore = dict(list(zip(runs, [None] * len(runs))))
3555 
3556  self.logger.info(" found %d run(s) to ignore:" % \
3557  len(runs))
3558  if len(runs) > 0:
3559  self.logger.info(" %s" % ", ".join([str(i) for i in runs]))
3560 
3561  # End of build_runs_ignore_list().
3562 
static const TGPicture * info(bool iBackgroundIsBlack)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float zip(ConstView const &tracks, int32_t i)
Definition: TracksSoA.h:90
def build_runs_ignore_list(self)
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
#define str(s)

◆ build_runs_list()

def cmsHarvester.build_runs_list (   self,
  input_method,
  input_name 
)

Definition at line 3469 of file cmsHarvester.py.

References info(), and createfilelist.int.

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

◆ build_runs_use_list()

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

Definition at line 3520 of file cmsHarvester.py.

References info().

3520  def build_runs_use_list(self):
3521  """Build a list of runs to process.
3522 
3523  """
3524 
3525  self.logger.info("Building list of runs to consider...")
3526 
3527  input_method = self.input_method["runs"]["use"]
3528  input_name = self.input_name["runs"]["use"]
3529  runs = self.build_runs_list(input_method, input_name)
3530  self.runs_to_use = dict(list(zip(runs, [None] * len(runs))))
3531 
3532  self.logger.info(" found %d run(s) to process:" % \
3533  len(runs))
3534  if len(runs) > 0:
3535  self.logger.info(" %s" % ", ".join([str(i) for i in runs]))
3536 
3537  # End of build_runs_list().
3538 
static const TGPicture * info(bool iBackgroundIsBlack)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float zip(ConstView const &tracks, int32_t i)
Definition: TracksSoA.h:90
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
#define str(s)
def build_runs_use_list(self)

◆ check_cmssw()

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

Definition at line 2333 of file cmsHarvester.py.

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

◆ 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 3794 of file cmsHarvester.py.

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

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

◆ check_dbs()

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

Definition at line 2356 of file cmsHarvester.py.

References debug.

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

◆ 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 4500 of file cmsHarvester.py.

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

◆ 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 4597 of file cmsHarvester.py.

References debug, and info().

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

◆ check_globaltag_exists()

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

Definition at line 4555 of file cmsHarvester.py.

References debug, info(), and submitPVValidationJobs.split().

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

◆ 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 2192 of file cmsHarvester.py.

References info(), and join().

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

◆ 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 5245 of file cmsHarvester.py.

References info().

5245  def check_ref_hist_mappings(self):
5246  """Make sure all necessary reference histograms exist.
5247 
5248  Check that for each of the datasets to be processed a
5249  reference histogram is specified and that that histogram
5250  exists in the database.
5251 
5252  NOTE: There's a little complication here. Since this whole
5253  thing was designed to allow (in principle) harvesting of both
5254  data and MC datasets in one go, we need to be careful to check
5255  the availability fof reference mappings only for those
5256  datasets that need it.
5257 
5258  """
5259 
5260  self.logger.info("Checking reference histogram mappings")
5261 
5262  for dataset_name in self.datasets_to_use:
5263  try:
5264  ref_hist_name = self.ref_hist_mappings[dataset_name]
5265  except KeyError:
5266  msg = "ERROR: No reference histogram mapping found " \
5267  "for dataset `%s'" % \
5268  dataset_name
5269  self.logger.fatal(msg)
5270  raise Error(msg)
5271 
5272  if not self.check_ref_hist_tag(ref_hist_name):
5273  msg = "Reference histogram tag `%s' " \
5274  "(used for dataset `%s') does not exist!" % \
5275  (ref_hist_name, dataset_name)
5276  self.logger.fatal(msg)
5277  raise Usage(msg)
5278 
5279  self.logger.info(" Done checking reference histogram mappings.")
5280 
5281  # End of check_ref_hist_mappings.
5282 
edm::ErrorSummaryEntry Error
static const TGPicture * info(bool iBackgroundIsBlack)
def check_ref_hist_mappings(self)

◆ 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 4642 of file cmsHarvester.py.

References debug, and join().

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

◆ 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 1490 of file cmsHarvester.py.

References debug, and spr.find().

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

◆ 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 1431 of file cmsHarvester.py.

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

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

◆ 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 1327 of file cmsHarvester.py.

References create_castor_path_name_special(), python.rootplot.root2matplotlib.replace(), and nano_mu_digi_cff.strip.

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

◆ 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 1383 of file cmsHarvester.py.

Referenced by create_castor_path_name_common().

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

◆ 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 4064 of file cmsHarvester.py.

Referenced by create_multicrab_config().

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

◆ 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 4232 of file cmsHarvester.py.

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

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

◆ 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 4688 of file cmsHarvester.py.

References join().

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

◆ create_harvesting_config_file_name()

def cmsHarvester.create_harvesting_config_file_name (   self,
  dataset_name 
)

Definition at line 4096 of file cmsHarvester.py.

Referenced by write_harvesting_config().

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

◆ 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 4168 of file cmsHarvester.py.

References spr.find().

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

◆ create_me_extraction_config()

def cmsHarvester.create_me_extraction_config (   self,
  dataset_name 
)
 

Definition at line 4914 of file cmsHarvester.py.

References create_output_file_name(), and join().

4914  def create_me_extraction_config(self, dataset_name):
4915  """
4916 
4917  """
4918 
4919  # Big chunk of hard-coded Python. Not such a big deal since
4920  # this does not do much and is not likely to break.
4921  tmp = []
4922  tmp.append(self.config_file_header())
4923  tmp.append("")
4924  tmp.append("import FWCore.ParameterSet.Config as cms")
4925  tmp.append("")
4926  tmp.append("process = cms.Process(\"ME2EDM\")")
4927  tmp.append("")
4928  tmp.append("# Import of standard configurations")
4929  tmp.append("process.load(\"Configuration/EventContent/EventContent_cff\")")
4930  tmp.append("")
4931  tmp.append("# We don't really process any events, just keep this set to one to")
4932  tmp.append("# make sure things work.")
4933  tmp.append("process.maxEvents = cms.untracked.PSet(")
4934  tmp.append(" input = cms.untracked.int32(1)")
4935  tmp.append(" )")
4936  tmp.append("")
4937  tmp.append("process.options = cms.untracked.PSet(")
4938  tmp.append(" Rethrow = cms.untracked.vstring(\"ProductNotFound\")")
4939  tmp.append(" )")
4940  tmp.append("")
4941  tmp.append("process.source = cms.Source(\"PoolSource\",")
4942  tmp.append(" processingMode = \\")
4943  tmp.append(" cms.untracked.string(\"RunsAndLumis\"),")
4944  tmp.append(" fileNames = \\")
4945  tmp.append(" cms.untracked.vstring(\"no_file_specified\")")
4946  tmp.append(" )")
4947  tmp.append("")
4948  tmp.append("# Output definition: drop everything except for the monitoring.")
4949  tmp.append("process.output = cms.OutputModule(")
4950  tmp.append(" \"PoolOutputModule\",")
4951  tmp.append(" outputCommands = \\")
4952  tmp.append(" cms.untracked.vstring(\"drop *\", \\")
4953  tmp.append(" \"keep *_MEtoEDMConverter_*_*\"),")
4954  output_file_name = self. \
4955  create_output_file_name(dataset_name)
4956  tmp.append(" fileName = \\")
4957  tmp.append(" cms.untracked.string(\"%s\")," % output_file_name)
4958  tmp.append(" dataset = cms.untracked.PSet(")
4959  tmp.append(" dataTier = cms.untracked.string(\"RECO\"),")
4960  tmp.append(" filterName = cms.untracked.string(\"\")")
4961  tmp.append(" )")
4962  tmp.append(" )")
4963  tmp.append("")
4964  tmp.append("# Additional output definition")
4965  tmp.append("process.out_step = cms.EndPath(process.output)")
4966  tmp.append("")
4967  tmp.append("# Schedule definition")
4968  tmp.append("process.schedule = cms.Schedule(process.out_step)")
4969  tmp.append("")
4970 
4971  config_contents = "\n".join(tmp)
4972 
4973  # End of create_me_extraction_config.
4974  return config_contents
4975 
def create_me_extraction_config(self, dataset_name)
def create_output_file_name(self, dataset_name, run_number=None)
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

◆ create_me_summary_config_file_name()

def cmsHarvester.create_me_summary_config_file_name (   self,
  dataset_name 
)

Definition at line 4110 of file cmsHarvester.py.

Referenced by write_me_extraction_config().

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

◆ 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 4200 of file cmsHarvester.py.

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

◆ 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 4215 of file cmsHarvester.py.

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

◆ 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 4312 of file cmsHarvester.py.

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

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

◆ 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 4124 of file cmsHarvester.py.

Referenced by create_me_extraction_config(), and create_multicrab_config().

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

◆ dbs_check_dataset_spread()

def cmsHarvester.dbs_check_dataset_spread (   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.

Definition at line 3076 of file cmsHarvester.py.

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

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

◆ 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 2475 of file cmsHarvester.py.

References cms::cuda.assert().

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

◆ dbs_resolve_dataset_name()

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

Definition at line 2419 of file cmsHarvester.py.

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

Referenced by build_dataset_list().

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

◆ 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 2682 of file cmsHarvester.py.

References cms::cuda.assert().

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

◆ 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 2626 of file cmsHarvester.py.

References cms::cuda.assert().

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

◆ 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 2735 of file cmsHarvester.py.

References cms::cuda.assert().

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

◆ dbs_resolve_runs()

def cmsHarvester.dbs_resolve_runs (   self,
  dataset_name 
)
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 2569 of file cmsHarvester.py.

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

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

◆ 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 4045 of file cmsHarvester.py.

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

◆ 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 5169 of file cmsHarvester.py.

References geometryDiff.file, info(), mps_monitormerge.items, relativeConstraints.keys, SiStripPI.max, and nano_mu_digi_cff.strip.

5169  def load_ref_hist_mappings(self):
5170  """Load the reference histogram mappings from file.
5171 
5172  The dataset name to reference histogram name mappings are read
5173  from a text file specified in self.ref_hist_mappings_file_name.
5174 
5175  """
5176 
5177  # DEBUG DEBUG DEBUG
5178  assert len(self.ref_hist_mappings) < 1, \
5179  "ERROR Should not be RE-loading " \
5180  "reference histogram mappings!"
5181  # DEBUG DEBUG DEBUG end
5182 
5183  self.logger.info("Loading reference histogram mappings " \
5184  "from file `%s'" % \
5185  self.ref_hist_mappings_file_name)
5186 
5187  mappings_lines = None
5188  try:
5189  mappings_file = file(self.ref_hist_mappings_file_name, "r") mappings_lines = mappings_file.readlines()
5190  mappings_file.close()
5191  except IOError:
5192  msg = "ERROR: Could not open reference histogram mapping "\
5193  "file `%s'" % self.ref_hist_mappings_file_name
5194  self.logger.fatal(msg)
5195  raise Error(msg)
5196 
5197 
5198 
5199  # The format we expect is: two white-space separated pieces
5200  # per line. The first the dataset name for which the reference
5201  # should be used, the second one the name of the reference
5202  # histogram in the database.
5203 
5204  for mapping in mappings_lines:
5205  # Skip comment lines.
5206  if not mapping.startswith("#"):
5207  mapping = mapping.strip()
5208  if len(mapping) > 0:
5209  mapping_pieces = mapping.split()
5210  if len(mapping_pieces) != 2:
5211  msg = "ERROR: The reference histogram mapping " \
5212  "file contains a line I don't " \
5213  "understand:\n %s" % mapping
5214  self.logger.fatal(msg)
5215  raise Error(msg)
5216  dataset_name = mapping_pieces[0].strip()
5217  ref_hist_name = mapping_pieces[1].strip()
5218  # We don't want people to accidentally specify
5219  # multiple mappings for the same dataset. Just
5220  # don't accept those cases.
5221  if dataset_name in self.ref_hist_mappings:
5222  msg = "ERROR: The reference histogram mapping " \
5223  "file contains multiple mappings for " \
5224  "dataset `%s'."
5225  self.logger.fatal(msg)
5226  raise Error(msg)
5227 
5228  # All is well that ends well.
5229  self.ref_hist_mappings[dataset_name] = ref_hist_name
5230 
5231 
5232 
5233  self.logger.info(" Successfully loaded %d mapping(s)" % \
5234  len(self.ref_hist_mappings))
5235  max_len = max([len(i) for i in self.ref_hist_mappings.keys()])
5236  for (map_from, map_to) in self.ref_hist_mappings.items():
5237  self.logger.info(" %-*s -> %s" % \
5238  (max_len, map_from, map_to))
5239 
5240  # End of load_ref_hist_mappings.
5241 
5242 
edm::ErrorSummaryEntry Error
static const TGPicture * info(bool iBackgroundIsBlack)
def load_ref_hist_mappings(self)

◆ 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 1103 of file cmsHarvester.py.

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

◆ option_handler_castor_dir()

def cmsHarvester.option_handler_castor_dir (   self,
  option,
  opt_str,
  value,
  parser 
)
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 1061 of file cmsHarvester.py.

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

◆ 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 1131 of file cmsHarvester.py.

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

◆ 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 1153 of file cmsHarvester.py.

References print().

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

◆ 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 1086 of file cmsHarvester.py.

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

◆ option_handler_preferred_site()

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

Definition at line 1147 of file cmsHarvester.py.

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

◆ 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 1119 of file cmsHarvester.py.

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

◆ option_handler_sites()

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

Definition at line 1141 of file cmsHarvester.py.

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

◆ parse_cmd_line_options()

def cmsHarvester.parse_cmd_line_options (   self)

Definition at line 1870 of file cmsHarvester.py.

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

◆ pick_a_site()

def cmsHarvester.pick_a_site (   self,
  sites,
  cmssw_version 
)

Definition at line 1706 of file cmsHarvester.py.

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

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

◆ 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 3565 of file cmsHarvester.py.

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

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

◆ process_runs_use_and_ignore_lists()

def cmsHarvester.process_runs_use_and_ignore_lists (   self)

Definition at line 3612 of file cmsHarvester.py.

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

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

◆ 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 5135 of file cmsHarvester.py.

References relativeConstraints.keys.

5135  def ref_hist_mappings_needed(self, dataset_name=None):
5136  """Check if we need to load and check the reference mappings.
5137 
5138  For data the reference histograms should be taken
5139  automatically from the GlobalTag, so we don't need any
5140  mappings. For RelVals we need to know a mapping to be used in
5141  the es_prefer code snippet (different references for each of
5142  the datasets.)
5143 
5144  WARNING: This implementation is a bit convoluted.
5145 
5146  """
5147 
5148  # If no dataset name given, do everything, otherwise check
5149  # only this one dataset.
5150  if not dataset_name is None:
5151  data_type = self.datasets_information[dataset_name] \
5152  ["datatype"]
5153  mappings_needed = (data_type == "mc")
5154  # DEBUG DEBUG DEBUG
5155  if not mappings_needed:
5156  assert data_type == "data"
5157  # DEBUG DEBUG DEBUG end
5158  else:
5159  tmp = [self.ref_hist_mappings_needed(dataset_name) \
5160  for dataset_name in \
5161  self.datasets_information.keys()]
5162  mappings_needed = (True in tmp)
5163 
5164  # End of ref_hist_mappings_needed.
5165  return mappings_needed
5166 
def ref_hist_mappings_needed(self, dataset_name=None)

◆ run()

def cmsHarvester.run (   self)

Definition at line 5486 of file cmsHarvester.py.

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

5486  def run(self):
5487  "Main entry point of the CMS harvester."
5488 
5489  # Start with a positive thought.
5490  exit_code = 0
5491 
5492  try:
5493 
5494  try:
5495 
5496  # Parse all command line options and arguments
5497  self.parse_cmd_line_options()
5498  # and check that they make sense.
5499  self.check_input_status()
5500 
5501  # Check if CMSSW is setup.
5502  self.check_cmssw()
5503 
5504  # Check if DBS is setup,
5505  self.check_dbs()
5506  # and if all is fine setup the Python side.
5507  self.setup_dbs()
5508 
5509  # Fill our dictionary with all the required info we
5510  # need to understand harvesting jobs. This needs to be
5511  # done after the CMSSW version is known.
5512  self.setup_harvesting_info()
5513 
5514  # Obtain list of dataset names to consider
5515  self.build_dataset_use_list()
5516  # and the list of dataset names to ignore.
5517  self.build_dataset_ignore_list()
5518 
5519  # The same for the runs lists (if specified).
5520  self.build_runs_use_list()
5521  self.build_runs_ignore_list()
5522 
5523  # Process the list of datasets to ignore and fold that
5524  # into the list of datasets to consider.
5525  # NOTE: The run-based selection is done later since
5526  # right now we don't know yet which runs a dataset
5527  # contains.
5528  self.process_dataset_ignore_list()
5529 
5530  # Obtain all required information on the datasets,
5531  # like run numbers and GlobalTags.
5532  self.build_datasets_information()
5533 
5534  if self.use_ref_hists and \
5535  self.ref_hist_mappings_needed():
5536  # Load the dataset name to reference histogram
5537  # name mappings from file.
5538  self.load_ref_hist_mappings()
5539  # Now make sure that for all datasets we want to
5540  # process there is a reference defined. Otherwise
5541  # just bomb out before wasting any more time.
5542  self.check_ref_hist_mappings()
5543  else:
5544  self.logger.info("No need to load reference " \
5545  "histogram mappings file")
5546 
5547  # OBSOLETE OBSOLETE OBSOLETE
static const TGPicture * info(bool iBackgroundIsBlack)
def run(self)

◆ setup_dbs()

def cmsHarvester.setup_dbs (   self)
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 2393 of file cmsHarvester.py.

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

◆ 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 1208 of file cmsHarvester.py.

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

◆ 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 5433 of file cmsHarvester.py.

References info(), and MessageLogger_cfi.warning.

5433  def show_exit_message(self):
5434  """Tell the user what to do now, after this part is done.
5435 
5436  This should provide the user with some (preferably
5437  copy-pasteable) instructions on what to do now with the setups
5438  and files that have been created.
5439 
5440  """
5441 
5442  # TODO TODO TODO
5443  # This could be improved a bit.
5444  # TODO TODO TODO end
5445 
5446  sep_line = "-" * 60
5447 
5448  self.logger.info("")
5449  self.logger.info(sep_line)
5450  self.logger.info(" Configuration files have been created.")
5451  self.logger.info(" From here on please follow the usual CRAB instructions.")
5452  self.logger.info(" Quick copy-paste instructions are shown below.")
5453  self.logger.info(sep_line)
5454 
5455  self.logger.info("")
5456  self.logger.info(" Create all CRAB jobs:")
5457  self.logger.info(" multicrab -create")
5458  self.logger.info("")
5459  self.logger.info(" Submit all CRAB jobs:")
5460  self.logger.info(" multicrab -submit")
5461  self.logger.info("")
5462  self.logger.info(" Check CRAB status:")
5463  self.logger.info(" multicrab -status")
5464  self.logger.info("")
5465 
5466  self.logger.info("")
5467  self.logger.info(" For more information please see the CMS Twiki:")
5468  self.logger.info(" %s" % twiki_url)
5469  self.logger.info(sep_line)
5470 
5471  # If there were any jobs for which we could not find a
5472  # matching site show a warning message about that.
5473  if not self.all_sites_found:
5474  self.logger.warning(" For some of the jobs no matching " \
5475  "site could be found")
5476  self.logger.warning(" --> please scan your multicrab.cfg" \
5477  "for occurrences of `%s'." % \
5478  self.no_matching_site_found_str)
5479  self.logger.warning(" You will have to fix those " \
5480  "by hand, sorry.")
5481 
5482  # End of show_exit_message.
5483 
static const TGPicture * info(bool iBackgroundIsBlack)
def show_exit_message(self)

◆ 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 3741 of file cmsHarvester.py.

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

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

◆ write_crab_config()

def cmsHarvester.write_crab_config (   self)
Write a CRAB job configuration Python file.

Definition at line 5011 of file cmsHarvester.py.

References geometryDiff.file, and info().

5011  def write_crab_config(self):
5012  """Write a CRAB job configuration Python file.
5013 
5014  """
5015 
5016  self.logger.info("Writing CRAB configuration...")
5017 
5018  file_name_base = "crab.cfg"
5019 
5020  # Create CRAB configuration.
5021  crab_contents = self.create_crab_config()
5022 
5023  # Write configuration to file.
5024  crab_file_name = file_name_base
5025  try:
5026  crab_file = file(crab_file_name, "w")
5027  crab_file.write(crab_contents)
5028  crab_file.close()
5029  except IOError:
5030  self.logger.fatal("Could not write " \
5031  "CRAB configuration to file `%s'" % \
5032  crab_file_name)
5033  raise Error("ERROR: Could not write to file `%s'!" % \
5034  crab_file_name)
5035 
5036  # End of write_crab_config.
5037 
edm::ErrorSummaryEntry Error
static const TGPicture * info(bool iBackgroundIsBlack)
def write_crab_config(self)

◆ 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 5069 of file cmsHarvester.py.

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

5069  def write_harvesting_config(self, dataset_name):
5070  """Write a harvesting job configuration Python file.
5071 
5072  NOTE: This knows nothing about single-step or two-step
5073  harvesting. That's all taken care of by
5074  create_harvesting_config.
5075 
5076  """
5077 
5078  self.logger.debug("Writing harvesting configuration for `%s'..." % \
5079  dataset_name)
5080 
5081  # Create Python configuration.
5082  config_contents = self.create_harvesting_config(dataset_name)
5083 
5084  # Write configuration to file.
5085  config_file_name = self. \
5087  try:
5088  config_file = file(config_file_name, "w")
5089  config_file.write(config_contents)
5090  config_file.close()
5091  except IOError:
5092  self.logger.fatal("Could not write " \
5093  "harvesting configuration to file `%s'" % \
5094  config_file_name)
5095  raise Error("ERROR: Could not write to file `%s'!" % \
5096  config_file_name)
5097 
5098  # End of write_harvesting_config.
5099 
edm::ErrorSummaryEntry Error
def write_harvesting_config(self, dataset_name)
#define debug
Definition: HDRShower.cc:19
def create_harvesting_config_file_name(self, dataset_name)

◆ 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 5102 of file cmsHarvester.py.

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

5102  def write_me_extraction_config(self, dataset_name):
5103  """Write an ME-extraction configuration Python file.
5104 
5105  This `ME-extraction' (ME = Monitoring Element) is the first
5106  step of the two-step harvesting.
5107 
5108  """
5109 
5110  self.logger.debug("Writing ME-extraction configuration for `%s'..." % \
5111  dataset_name)
5112 
5113  # Create Python configuration.
5114  config_contents = self.create_me_extraction_config(dataset_name)
5115 
5116  # Write configuration to file.
5117  config_file_name = self. \
5119  try:
5120  config_file = file(config_file_name, "w")
5121  config_file.write(config_contents)
5122  config_file.close()
5123  except IOError:
5124  self.logger.fatal("Could not write " \
5125  "ME-extraction configuration to file `%s'" % \
5126  config_file_name)
5127  raise Error("ERROR: Could not write to file `%s'!" % \
5128  config_file_name)
5129 
5130  # End of write_me_extraction_config.
5131 
edm::ErrorSummaryEntry Error
def write_me_extraction_config(self, dataset_name)
def create_me_summary_config_file_name(self, dataset_name)
#define debug
Definition: HDRShower.cc:19

◆ write_multicrab_config()

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

Definition at line 5040 of file cmsHarvester.py.

References geometryDiff.file, and info().

5040  def write_multicrab_config(self):
5041  """Write a multi-CRAB job configuration Python file.
5042 
5043  """
5044 
5045  self.logger.info("Writing multi-CRAB configuration...")
5046 
5047  file_name_base = "multicrab.cfg"
5048 
5049  # Create multi-CRAB configuration.
5050  multicrab_contents = self.create_multicrab_config()
5051 
5052  # Write configuration to file.
5053  multicrab_file_name = file_name_base
5054  try:
5055  multicrab_file = file(multicrab_file_name, "w")
5056  multicrab_file.write(multicrab_contents)
5057  multicrab_file.close()
5058  except IOError:
5059  self.logger.fatal("Could not write " \
5060  "multi-CRAB configuration to file `%s'" % \
5061  multicrab_file_name)
5062  raise Error("ERROR: Could not write to file `%s'!" % \
5063  multicrab_file_name)
5064 
5065  # End of write_multicrab_config.
5066 
edm::ErrorSummaryEntry Error
static const TGPicture * info(bool iBackgroundIsBlack)
def write_multicrab_config(self)

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 3231 of file cmsHarvester.py.

◆ all_sites_found

cmsHarvester.all_sites_found

CAF

Definition at line 1863 of file cmsHarvester.py.

◆ caf_access

cmsHarvester.caf_access

Definition at line 1108 of file cmsHarvester.py.

◆ castor_base_dir

cmsHarvester.castor_base_dir

Definition at line 1077 of file cmsHarvester.py.

◆ castor_path_checks_cache

cmsHarvester.castor_path_checks_cache

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

Definition at line 1603 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 should not happen with any valid dataset.

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

DEBUG DEBUG DEBUG end

Definition at line 5417 of file cmsHarvester.py.

◆ castor_paths

cmsHarvester.castor_paths

Definition at line 5421 of file cmsHarvester.py.

◆ cmd

cmsHarvester.cmd

Definition at line 1632 of file cmsHarvester.py.

◆ cmd_line_opts

cmsHarvester.cmd_line_opts

Definition at line 2169 of file cmsHarvester.py.

◆ cmssw_version

cmsHarvester.cmssw_version

Definition at line 2347 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 3276 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 subprocess") customisations.append("import os") customisations.append("castor_dir = \"s"" % castor_dir) customisations.append("cmd = "rfdir s" % castor_dir") customisations.append("(status, output) = subprocess.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 4890 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 4085 of file cmsHarvester.py.

◆ crab_submission

cmsHarvester.crab_submission

Definition at line 1135 of file cmsHarvester.py.

◆ dataset_names_after_checks

cmsHarvester.dataset_names_after_checks

Definition at line 4030 of file cmsHarvester.py.

◆ dataset_names_after_checks_tmp

cmsHarvester.dataset_names_after_checks_tmp

Definition at line 4023 of file cmsHarvester.py.

◆ datasets_information

cmsHarvester.datasets_information

Definition at line 5305 of file cmsHarvester.py.

◆ datasets_to_ignore

cmsHarvester.datasets_to_ignore

Definition at line 3457 of file cmsHarvester.py.

◆ datasets_to_use

cmsHarvester.datasets_to_use

Definition at line 4039 of file cmsHarvester.py.

◆ dbs_api

cmsHarvester.dbs_api

Definition at line 2406 of file cmsHarvester.py.

◆ empty_runs

cmsHarvester.empty_runs

Definition at line 4007 of file cmsHarvester.py.

◆ exit_code

cmsHarvester.exit_code

Definition at line 5654 of file cmsHarvester.py.

◆ file_name

cmsHarvester.file_name

Definition at line 3175 of file cmsHarvester.py.

◆ files_at_site

cmsHarvester.files_at_site

Definition at line 3235 of file cmsHarvester.py.

◆ files_info

cmsHarvester.files_info

Definition at line 3161 of file cmsHarvester.py.

◆ files_without_sites

cmsHarvester.files_without_sites

Definition at line 3201 of file cmsHarvester.py.

◆ globaltag

cmsHarvester.globaltag

Definition at line 2307 of file cmsHarvester.py.

◆ harvesting_info

cmsHarvester.harvesting_info

Definition at line 1314 of file cmsHarvester.py.

◆ harvesting_mode

cmsHarvester.harvesting_mode

Definition at line 2216 of file cmsHarvester.py.

◆ harvesting_type

cmsHarvester.harvesting_type

Definition at line 3858 of file cmsHarvester.py.

◆ Jsonfilename

cmsHarvester.Jsonfilename

Definition at line 3707 of file cmsHarvester.py.

◆ Jsonlumi

cmsHarvester.Jsonlumi

CRAB

GRID

USER

CMSSW

Definition at line 3681 of file cmsHarvester.py.

◆ mirrored

cmsHarvester.mirrored

Definition at line 3222 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 ...

\

PATH STORAGEELEMENT_SENAME COUNT_FILES

_________________________________________________________________________________

/RelValQCD_Pt_3000_3500/CMSSW_3_3_0_pre1-STARTUP31X_V4-v1/GEN-SIM-RECO 1

/RelValQCD_Pt_3000_3500/CMSSW_3_3_0_pre1-STARTUP31X_V4-v1/GEN-SIM-RECO cmssrm.fnal.gov 12

/RelValQCD_Pt_3000_3500/CMSSW_3_3_0_pre1-STARTUP31X_V4-v1/GEN-SIM-RECO srm-cms.cern.ch 12

if len(site_name) < 1: return

TODO TODO TODO end

run_number = int(attrs["RUNS_RUNNUMBER"]) file_name = str(attrs["FILES_LOGICALFILENAME"]) nevents = int(attrs["FILES_NUMBEROFEVENTS"])

I know, this is a bit of a kludge.

if not files_info.has_key(run_number):

New run.

files_info[run_number] = {} files_info[run_number][file_name] = (nevents, [site_name]) elif not files_info[run_number].has_key(file_name):

New file for a known run.

files_info[run_number][file_name] = (nevents, [site_name]) else:

New entry for a known file for a known run.

DEBUG DEBUG DEBUG

Each file should have the same number of

events independent of the site it's at.

assert nevents == files_info[run_number][file_name][0]

DEBUG DEBUG DEBUG end

files_info[run_number][file_name][1].append(site_name) OBSOLETE OBSOLETE OBSOLETE end

Definition at line 1640 of file cmsHarvester.py.

◆ nevents

cmsHarvester.nevents

Definition at line 3176 of file cmsHarvester.py.

◆ non_t1access

cmsHarvester.non_t1access

Definition at line 1092 of file cmsHarvester.py.

◆ nr_max_sites

cmsHarvester.nr_max_sites

Definition at line 1143 of file cmsHarvester.py.

◆ num_events_catalog

cmsHarvester.num_events_catalog

Definition at line 3215 of file cmsHarvester.py.

◆ num_events_dataset

cmsHarvester.num_events_dataset

Definition at line 3985 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 3955 of file cmsHarvester.py.

◆ option_parser

cmsHarvester.option_parser

Definition at line 1879 of file cmsHarvester.py.

◆ output

cmsHarvester.output

Definition at line 1633 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 1592 of file cmsHarvester.py.

◆ permissions

cmsHarvester.permissions

Definition at line 1649 of file cmsHarvester.py.

Referenced by cond::CredentialStore.updatePrincipal().

◆ permissions_new

cmsHarvester.permissions_new

Definition at line 1679 of file cmsHarvester.py.

◆ permissions_target

cmsHarvester.permissions_target

Definition at line 1673 of file cmsHarvester.py.

◆ preferred_site

cmsHarvester.preferred_site

Definition at line 1149 of file cmsHarvester.py.

◆ ref_hist_mappings_file_name

cmsHarvester.ref_hist_mappings_file_name

Definition at line 2258 of file cmsHarvester.py.

◆ run_number

cmsHarvester.run_number

Definition at line 3174 of file cmsHarvester.py.

◆ runs_to_ignore

cmsHarvester.runs_to_ignore

Definition at line 3554 of file cmsHarvester.py.

◆ runs_to_use

cmsHarvester.runs_to_use

Definition at line 3530 of file cmsHarvester.py.

◆ saveByLumiSection

cmsHarvester.saveByLumiSection

Definition at line 1122 of file cmsHarvester.py.

◆ site_names

cmsHarvester.site_names

Definition at line 3217 of file cmsHarvester.py.

◆ sites_with_complete_copies

cmsHarvester.sites_with_complete_copies

Definition at line 3233 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 1584 of file cmsHarvester.py.

◆ status

cmsHarvester.status

Definition at line 1633 of file cmsHarvester.py.

◆ tmp

cmsHarvester.tmp

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 tmp = self.datasets_information[dataset_name] \ ["num_events"]

Definition at line 3982 of file cmsHarvester.py.

◆ traceback_string

cmsHarvester.traceback_string

Definition at line 5679 of file cmsHarvester.py.

◆ twiki_url

cmsHarvester.twiki_url

Definition at line 43 of file cmsHarvester.py.