Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:44

0001 import os
0002 import argparse
0003 class CLIHelper(object):
0004     @classmethod
0005     def get_common_options_parser(cls):
0006         """ Return a parser with common options for each workflow"""
0007         common_opts_parser = argparse.ArgumentParser(add_help=False)
0008         common_opts_group = common_opts_parser.add_argument_group(
0009             description ="General options")
0010         common_opts_group.add_argument("-r","--run", type=int,
0011             help="set reference run number (typically first or last run in list)")
0012         common_opts_group.add_argument("--trial", type=int, default = 1,
0013             help="trial number used in the naming of output directories")
0014         common_opts_group.add_argument("--label", default="dtCalibration",
0015             help="label used in the naming of workflow output default:%(default)s")
0016         common_opts_group.add_argument("--datasettype", default = "Data",
0017             choices=["Data", "Cosmics", "MC"], help="Type of input dataset default: %(default)s")
0018         common_opts_group.add_argument("--config-path",
0019             help="Path to alternative workflow config json file, e.g. used to submit the job")
0020         common_opts_group.add_argument("--user", default="",
0021             help="User used e.g. for submission. Defaults to user HN name")
0022         common_opts_group.add_argument("--working-dir",
0023             default=os.getcwd(), help="connect string default:%(default)s")
0024         common_opts_group.add_argument("--no-exec",
0025             action="store_true", help="Do not execute or submit any workflow")
0026         return common_opts_parser
0027 
0028     @classmethod
0029     def add_parser_options(cls, parser):
0030         # Subparsers are used to choose a calibration workflow
0031         workflow_subparsers = parser.add_subparsers( help="workflow option help", dest="workflow" )
0032         return workflow_subparsers
0033 
0034 
0035     def fill_required_options_prepare_dict(self):
0036         common_required = []
0037         self.required_options_prepare_dict["submit"] = ["globaltag"]
0038 
0039     def fill_required_options_dict(self):
0040         common_required = ["run"]
0041         self.required_options_dict["submit"] = common_required
0042         self.required_options_dict["submit"].append("datasetpath")
0043         self.required_options_dict["submit"].append("globaltag")
0044 
0045         self.required_options_dict["correction"] = common_required
0046         self.required_options_dict["correction"].append("globaltag")
0047 
0048 
0049     @classmethod
0050     def get_input_db_options_parser(cls):
0051         """ Return a parser object with options relevant for input databases"""
0052         db_opts_parser = argparse.ArgumentParser(add_help=False)
0053         dp_opts_group = db_opts_parser.add_argument_group(
0054             description ="Options for Input databases")
0055         db_opts_parser.add_argument("--inputDBRcd",
0056             help="Record used for PoolDBESSource")
0057         db_opts_parser.add_argument("--inputDBTag",
0058             help="Tag used for PoolDBESSource")
0059         db_opts_parser.add_argument("--connectStrDBTag",
0060             default='frontier://FrontierProd/CMS_COND_31X_DT',
0061             help="connect string default:%(default)s")
0062         return db_opts_parser
0063 
0064     @classmethod
0065     def get_local_input_db_options_parser(cls):
0066         """ Return a parser object with options relevant for input databases"""
0067         db_opts_parser = argparse.ArgumentParser(add_help=False)
0068         db_opts_group = db_opts_parser.add_argument_group(
0069             description ="Options for local input databases")
0070         db_opts_group.add_argument("--inputVDriftDB",
0071             help="Local alternative VDrift database")
0072         db_opts_group.add_argument("--inputCalibDB",
0073             help="Local alternative Ttrig database")
0074         db_opts_group.add_argument("--inputT0DB",
0075             help="Local alternative T0 database")
0076         return db_opts_parser
0077 
0078     @classmethod
0079     def get_submission_options_parser(cls):
0080         """ Return a parser object with options relevant to remote submission"""
0081         submission_opts_parser = argparse.ArgumentParser(add_help=False)
0082         submission_opts_group = submission_opts_parser.add_argument_group(
0083             description ="Options for Job submission")
0084         submission_opts_group.add_argument("--datasetpath",
0085             help="dataset name to process")
0086         submission_opts_group.add_argument("--run-on-RAW", action = "store_true",
0087             help="Flag if run on RAW dataset")
0088         submission_opts_group.add_argument("--fromMuons", action = "store_true",
0089             help="Segment selection using muon-segment matching")
0090         submission_opts_group.add_argument("--globaltag",
0091             help="global tag identifier (with the '::All' string, if necessary)")
0092         submission_opts_group.add_argument("--histoRange", default = 0.4,
0093             help="Range or residual histogram, default is 0.4cm")
0094         submission_opts_group.add_argument("--runselection", default = [], nargs="+",
0095             help="run list or range")
0096         submission_opts_group.add_argument("--filesPerJob", default = 5,
0097             help="Number of files to process for MC grid jobs")
0098         submission_opts_group.add_argument("--lumisPerJob", default = 10000,
0099             help="Number of lumi sections to process for RAW / Comsics grid jobs")
0100         submission_opts_group.add_argument("--preselection", dest="preselection",
0101             help="configuration fragment and sequence name, separated by a ':', defining a pre-selection filter")
0102         submission_opts_group.add_argument("--output-site", default = "T2_DE_RWTH",
0103             help="Site used for stage out of results")
0104         submission_opts_group.add_argument("--ce-black-list", default = [], nargs="+",
0105             help="add sites to black list when run on Grid")
0106         submission_opts_group.add_argument("--ce-white-list", default = [], nargs="+",
0107             help="add sites to white list when run on Grid")
0108         submission_opts_group.add_argument("--no-log",
0109             action="store_true", help="Do not transfer crab logs:%(default)s")
0110         return submission_opts_parser
0111 
0112     @classmethod
0113     def get_check_options_parser(cls):
0114         """ Return a parser object with options relevant to check the status of remote submission"""
0115         check_opts_parser = argparse.ArgumentParser(add_help=False)
0116         check_opts_group = check_opts_parser.add_argument_group(
0117             description ="Options for Job submission")
0118         check_opts_group.add_argument("--check-interval", default = 600,type=int,
0119             help="Time in seconds between check operations default: %(default)s")
0120         check_opts_group.add_argument("--max-checks", default =1000, type=int,
0121             help="Maximum number of checks before check is considered failed default: %(default)s")
0122         return check_opts_parser
0123 
0124     @classmethod
0125     def get_write_options_parser(cls):
0126         """ Return a parser object with options relevant to write results to dbs"""
0127         check_opts_parser = argparse.ArgumentParser(add_help=False)
0128         check_opts_group = check_opts_parser.add_argument_group(
0129             description ="Options for write jobs")
0130         check_opts_group.add_argument("--skip-stageout", action="store_true",
0131             help="Skip stageout to local disk and merging")
0132         return check_opts_parser
0133 
0134     @classmethod
0135     def get_dump_options_parser(cls):
0136         dump_opts_parser = argparse.ArgumentParser(add_help=False)
0137         dump_opts_group = dump_opts_parser.add_argument_group(
0138             description ="Options for dump db file")
0139         dump_opts_group.add_argument("--input-dumpDB",
0140         help="Input database file to dump."\
0141              " Defaults to existing corrected database from correction command"\
0142              " if run, label, trial or input config are specified")
0143         return dump_opts_group
0144