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("--globaltag",
89  help="global tag identifier (with the '::All' string, if necessary)")
90  submission_opts_group.add_argument("--histoRange", default = 0.4,
91  help="Range or residual histogram, default is 0.4cm")
92  submission_opts_group.add_argument("--runselection", default = [], nargs="+",
93  help="run list or range")
94  submission_opts_group.add_argument("--filesPerJob", default = 5,
95  help="Number of files to process for MC grid jobs")
96  submission_opts_group.add_argument("--lumisPerJob", default = 10000,
97  help="Number of lumi sections to process for RAW / Comsics grid jobs")
98  submission_opts_group.add_argument("--preselection", dest="preselection",
99  help="configuration fragment and sequence name, separated by a ':', defining a pre-selection filter")
100  submission_opts_group.add_argument("--output-site", default = "T2_DE_RWTH",
101  help="Site used for stage out of results")
102  submission_opts_group.add_argument("--ce-black-list", default = [], nargs="+",
103  help="add sites to black list when run on Grid")
104  submission_opts_group.add_argument("--ce-white-list", default = [], nargs="+",
105  help="add sites to white list when run on Grid")
106  submission_opts_group.add_argument("--no-log",
107  action="store_true", help="Do not transfer crab logs:%(default)s")
108  return submission_opts_parser
109 
110  @classmethod
112  """ Return a parser object with options relevant to check the status of remote submission"""
113  check_opts_parser = argparse.ArgumentParser(add_help=False)
114  check_opts_group = check_opts_parser.add_argument_group(
115  description ="Options for Job submission")
116  check_opts_group.add_argument("--check-interval", default = 600,type=int,
117  help="Time in seconds between check operations default: %(default)s")
118  check_opts_group.add_argument("--max-checks", default =1000, type=int,
119  help="Maximum number of checks before check is considered failed default: %(default)s")
120  return check_opts_parser
121 
122  @classmethod
124  """ Return a parser object with options relevant to write results to dbs"""
125  check_opts_parser = argparse.ArgumentParser(add_help=False)
126  check_opts_group = check_opts_parser.add_argument_group(
127  description ="Options for write jobs")
128  check_opts_group.add_argument("--skip-stageout", action="store_true",
129  help="Skip stageout to local disk and merging")
130  return check_opts_parser
131 
132  @classmethod
134  dump_opts_parser = argparse.ArgumentParser(add_help=False)
135  dump_opts_group = dump_opts_parser.add_argument_group(
136  description ="Options for dump db file")
137  dump_opts_group.add_argument("--input-dumpDB",
138  help="Input database file to dump."\
139  " Defaults to existing corrected database from correction command"\
140  " if run, label, trial or input config are specified")
141  return dump_opts_group
142 
def get_common_options_parser(cls)
Definition: CLIHelper.py:5
def get_dump_options_parser(cls)
Definition: CLIHelper.py:133
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:123
def get_check_options_parser(cls)
Definition: CLIHelper.py:111