CMS 3D CMS Logo

CLIHelper.py
Go to the documentation of this file.
1 import os
2 import argparse
4  @classmethod
6  """ Return a parser with common options for each workflow"""
7  common_opts_parser = argparse.ArgumentParser(add_help=False)
8  common_opts_group = common_opts_parser.add_argument_group(
9  description ="General options")
10  common_opts_group.add_argument("-r","--run", type=int,
11  help="set reference run number (typically first or last run in list)")
12  common_opts_group.add_argument("--trial", type=int, default = 1,
13  help="trial number used in the naming of output directories")
14  common_opts_group.add_argument("--label", default="dtCalibration",
15  help="label used in the naming of workflow output default:%(default)s")
16  common_opts_group.add_argument("--datasettype", default = "Data",
17  choices=["Data", "Cosmics", "MC"], help="Type of input dataset default: %(default)s")
18  common_opts_group.add_argument("--config-path",
19  help="Path to alternative workflow config json file, e.g. used to submit the job")
20  common_opts_group.add_argument("--user", default="",
21  help="User used e.g. for submission. Defaults to user HN name")
22  common_opts_group.add_argument("--working-dir",
23  default=os.getcwd(), help="connect string default:%(default)s")
24  common_opts_group.add_argument("--no-exec",
25  action="store_true", help="Do not execute or submit any workflow")
26  return common_opts_parser
27 
28  @classmethod
29  def add_parser_options(cls, parser):
30  # Subparsers are used to choose a calibration workflow
31  workflow_subparsers = parser.add_subparsers( help="workflow option help", dest="workflow" )
32  return workflow_subparsers
33 
34 
36  common_required = []
37  self.required_options_prepare_dict["submit"] = ["globaltag"]
38 
40  common_required = ["run"]
41  self.required_options_dict["submit"] = common_required
42  self.required_options_dict["submit"].append("datasetpath")
43  self.required_options_dict["submit"].append("globaltag")
44 
45  self.required_options_dict["correction"] = common_required
46  self.required_options_dict["correction"].append("globaltag")
47 
48 
49  @classmethod
51  """ Return a parser object with options relevant for input databases"""
52  db_opts_parser = argparse.ArgumentParser(add_help=False)
53  dp_opts_group = db_opts_parser.add_argument_group(
54  description ="Options for Input databases")
55  db_opts_parser.add_argument("--inputDBRcd",
56  help="Record used for PoolDBESSource")
57  db_opts_parser.add_argument("--inputDBTag",
58  help="Tag used for PoolDBESSource")
59  db_opts_parser.add_argument("--connectStrDBTag",
60  default='frontier://FrontierProd/CMS_COND_31X_DT',
61  help="connect string default:%(default)s")
62  return db_opts_parser
63 
64  @classmethod
66  """ Return a parser object with options relevant for input databases"""
67  db_opts_parser = argparse.ArgumentParser(add_help=False)
68  db_opts_group = db_opts_parser.add_argument_group(
69  description ="Options for local input databases")
70  db_opts_group.add_argument("--inputVDriftDB",
71  help="Local alternative VDrift database")
72  db_opts_group.add_argument("--inputCalibDB",
73  help="Local alternative Ttrig database")
74  db_opts_group.add_argument("--inputT0DB",
75  help="Local alternative T0 database")
76  return db_opts_parser
77 
78  @classmethod
80  """ Return a parser object with options relevant to remote submission"""
81  submission_opts_parser = argparse.ArgumentParser(add_help=False)
82  submission_opts_group = submission_opts_parser.add_argument_group(
83  description ="Options for Job submission")
84  submission_opts_group.add_argument("--datasetpath",
85  help="dataset name to process")
86  submission_opts_group.add_argument("--run-on-RAW", action = "store_true",
87  help="Flag if run on RAW dataset")
88  submission_opts_group.add_argument("--fromMuons", action = "store_true",
89  help="Segment selection using muon-segment matching")
90  submission_opts_group.add_argument("--globaltag",
91  help="global tag identifier (with the '::All' string, if necessary)")
92  submission_opts_group.add_argument("--histoRange", default = 0.4,
93  help="Range or residual histogram, default is 0.4cm")
94  submission_opts_group.add_argument("--runselection", default = [], nargs="+",
95  help="run list or range")
96  submission_opts_group.add_argument("--filesPerJob", default = 5,
97  help="Number of files to process for MC grid jobs")
98  submission_opts_group.add_argument("--lumisPerJob", default = 10000,
99  help="Number of lumi sections to process for RAW / Comsics grid jobs")
100  submission_opts_group.add_argument("--preselection", dest="preselection",
101  help="configuration fragment and sequence name, separated by a ':', defining a pre-selection filter")
102  submission_opts_group.add_argument("--raw-data-label", dest="raw_data_label", default="rawDataCollector",
103  help="RAW Data label as in the sample file.")
104  submission_opts_group.add_argument("--output-site", default = "T2_DE_RWTH",
105  help="Site used for stage out of results")
106  submission_opts_group.add_argument("--ce-black-list", default = [], nargs="+",
107  help="add sites to black list when run on Grid")
108  submission_opts_group.add_argument("--ce-white-list", default = [], nargs="+",
109  help="add sites to white list when run on Grid")
110  submission_opts_group.add_argument("--no-log",
111  action="store_true", help="Do not transfer crab logs:%(default)s")
112  return submission_opts_parser
113 
114  @classmethod
116  """ Return a parser object with options relevant to check the status of remote submission"""
117  check_opts_parser = argparse.ArgumentParser(add_help=False)
118  check_opts_group = check_opts_parser.add_argument_group(
119  description ="Options for Job submission")
120  check_opts_group.add_argument("--check-interval", default = 600,type=int,
121  help="Time in seconds between check operations default: %(default)s")
122  check_opts_group.add_argument("--max-checks", default =1000, type=int,
123  help="Maximum number of checks before check is considered failed default: %(default)s")
124  return check_opts_parser
125 
126  @classmethod
128  """ Return a parser object with options relevant to write results to dbs"""
129  check_opts_parser = argparse.ArgumentParser(add_help=False)
130  check_opts_group = check_opts_parser.add_argument_group(
131  description ="Options for write jobs")
132  check_opts_group.add_argument("--skip-stageout", action="store_true",
133  help="Skip stageout to local disk and merging")
134  return check_opts_parser
135 
136  @classmethod
138  dump_opts_parser = argparse.ArgumentParser(add_help=False)
139  dump_opts_group = dump_opts_parser.add_argument_group(
140  description ="Options for dump db file")
141  dump_opts_group.add_argument("--input-dumpDB",
142  help="Input database file to dump."\
143  " Defaults to existing corrected database from correction command"\
144  " if run, label, trial or input config are specified")
145  return dump_opts_group
146 
def get_common_options_parser(cls)
Definition: CLIHelper.py:5
def get_dump_options_parser(cls)
Definition: CLIHelper.py:137
def add_parser_options(cls, parser)
Definition: CLIHelper.py:29
def fill_required_options_dict(self)
Definition: CLIHelper.py:39
def get_input_db_options_parser(cls)
Definition: CLIHelper.py:50
def get_local_input_db_options_parser(cls)
Definition: CLIHelper.py:65
def fill_required_options_prepare_dict(self)
Definition: CLIHelper.py:35
def get_submission_options_parser(cls)
Definition: CLIHelper.py:79
def get_write_options_parser(cls)
Definition: CLIHelper.py:127
def get_check_options_parser(cls)
Definition: CLIHelper.py:115