Option parser returns : Command set to run on each (or all) machines, port to connect to server, List of machines to connect to, File to pickle results to, Dictionary to index which command set to use for which machine.
26 def _isValidPerfCmdsDef(alist):
29 isdict = isinstance(item, type({}))
33 out = out
and key
in validPerfSuitKeys
35 out = out
and isinstance(item[key], type(
""))
37 out = out
and isinstance(item[key], type(
""))
38 elif key ==
"castordir":
39 out = out
and isinstance(item[key], type(
""))
40 elif key ==
"perfsuitedir":
41 out = out
and isinstance(item[key], type(
""))
42 elif key ==
"TimeSizeEvents":
43 out = out
and isinstance(item[key], type(123))
44 elif key ==
"TimeSizeCandles":
45 out = out
and isinstance(item[key], type(
""))
46 elif key ==
"CallgrindEvents":
47 out = out
and isinstance(item[key], type(123))
48 elif key ==
"CallgrindCandles":
49 out = out
and isinstance(item[key], type(
""))
50 elif key ==
"IgProfEvents":
51 out = out
and isinstance(item[key], type(123))
52 elif key ==
"IgProfCandles":
53 out = out
and isinstance(item[key], type(
""))
54 elif key ==
"MemcheckEvents":
55 out = out
and isinstance(item[key], type(123))
56 elif key ==
"MemcheckCandles":
57 out = out
and isinstance(item[key], type(
""))
58 elif key ==
"cmsScimark":
59 out = out
and isinstance(item[key], type(123))
60 elif key ==
"cmsScimarkLarge":
61 out = out
and isinstance(item[key], type(123))
62 elif key ==
"cmsdriverOptions":
63 out = out
and isinstance(item[key], type(
""))
64 elif key ==
"stepOptions":
65 out = out
and isinstance(item[key], type(
""))
66 elif key ==
"quicktest":
67 out = out
and isinstance(item[key], type(
False))
68 elif key ==
"profilers":
69 out = out
and isinstance(item[key], type(
""))
70 elif key ==
"prevrel":
71 out = out
and isinstance(item[key], type(
""))
72 elif key ==
"isAllCandles":
73 out = out
and isinstance(item[key], type(
False))
74 elif key ==
"candles":
75 out = out
and isinstance(item[key], type(
""))
76 elif key ==
"bypasshlt":
77 out = out
and isinstance(item[key], type(
False))
78 elif key ==
"runonspare":
79 out = out
and isinstance(item[key], type(
False))
80 elif key ==
"logfile":
81 out = out
and isinstance(item[key], type(
""))
84 parser = opt.OptionParser(usage=(
"""%s [Options]""" % PROG_NAME))
86 parser.add_option(
'-p',
91 help=
'Connect to server on a particular port',
95 parser.add_option(
'-o',
100 help=
'File to output data to',
104 parser.add_option(
'-m',
110 help=
'Machines to run the benchmarking on, for each machine add another one of these options',
111 metavar=
'<MACHINES>',
114 parser.add_option(
'-f',
120 help=
'A files of cmsPerfSuite.py commands to execute on the machines, if more than one of these options is passed and the number of these options is the same as the number of machines, the x-th machine will use the x-th config file.',
124 (options, args) = parser.parse_args()
129 outfile = options.outfile
130 if not outfile ==
"":
131 outfile = os.path.abspath(options.outfile)
132 outdir = os.path.dirname(outfile)
133 if not os.path.isdir(outdir):
134 parser.error(
"ERROR: %s is not a valid directory to create %s" % (outdir,os.path.basename(outfile)))
137 outfile = os.path.join(os.getcwd(),
"cmsmultiperfdata.pypickle")
139 if os.path.exists(outfile):
140 parser.error(
"ERROR: outfile %s already exists" % outfile)
148 cmscmdfiles = options.cmscmdfile
149 if len(cmscmdfiles) <= 0:
150 parser.error(
"A valid python file defining a list of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program")
153 for cmscmdfile
in cmscmdfiles:
154 cmdfile = os.path.abspath(cmscmdfile)
156 if os.path.isfile(cmdfile):
159 cmsperf_cmds.append(listperfsuitekeywords)
160 except (SyntaxError)
as detail:
161 parser.error(
"ERROR: %s must be a valid python file" % cmdfile)
163 except (NameError)
as detail:
164 parser.error(
"ERROR: %s must contain a list (variable named listperfsuitekeywords) of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program: %s" % (cmdfile,
str(detail)))
168 if not isinstance(cmsperf_cmds[-1], type([])):
169 parser.error(
"ERROR: %s must contain a list (variable named listperfsuitekeywords) of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program 2" % cmdfile)
171 if not _isValidPerfCmdsDef(cmsperf_cmds[-1]):
172 parser.error(
"ERROR: %s must contain a list (variable named listperfsuitekeywords) of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program 3" % cmdfile)
176 parser.error(
"ERROR: %s is not a file" % cmdfile)
183 if options.port == -1:
188 machines = options.machines
193 if len(machines) <= 0:
194 parser.error(
"you must specify at least one machine to benchmark")
196 machines =
map(
lambda x: x.strip(),machines)
198 for machine
in machines:
200 output = socket.getaddrinfo(machine,port)
201 except socket.gaierror:
202 parser.error(
"ERROR: Can not resolve machine address %s (must be ip{4,6} or hostname)" % machine)
209 if len(cmsperf_cmds) == 1:
210 for machine
in machines:
213 cmdindex[machine] = 0
215 if not len(cmsperf_cmds) == len(machines):
216 parser.error(
"if more than one configuration file was specified you must specify a configuration file for each machine.")
219 for i
in range(len(machines)):
222 cmdindex[machine] = i
224 return (cmsperf_cmds, port, machines, outfile, cmdindex)
def optionparse()
Option parser returns : Command set to run on each (or all) machines, port to connect to server...
S & print(S &os, JobReport::InputFile const &f)