6Definitions of exec steps (main job) in Trigger ART tests
12from TrigValTools.TrigValSteering.Step
import Step
13from TrigValTools.TrigValSteering.Input
import is_input_defined, get_input
18 Step executing the main job of a Trigger ART test. This can be either
19 athena or athenaHLT or a transform. There can be several ExecSteps in
64 self.log.
debug(
'Configuring step %s', self.
name)
75 self.log.
debug(
'Configuring type for step %s', self.
name)
78 self.misconfig_abort(
'Cannot configure a step without specified type or executable')
81 known_types = [
'athena',
'athenaHLT',
'athenaEF',
'Reco_tf',
'Trig_reco_tf',
'Derivation_tf']
82 if self.
type in known_types:
84 self.log.warning(
'type=%s was specified, so executable=%s '
85 'will be ignored and deduced automatically '
88 elif self.
type ==
'other' or self.
type is None:
91 self.misconfig_abort(
'Cannot determine type of this step')
95 if varname
in os.environ:
96 del os.environ[varname]
99 os.environ[
'TRF_NOECHO'] =
'1'
104 del_env(
'ATHENA_NPROC_NUM')
105 del_env(
'ATHENA_CORE_NUMBER')
108 if os.path.isfile(path):
110 from ROOT
import TFile
111 with TFile.Open(path,
"READ")
as f:
112 if not f.IsOpen()
or f.IsZombie():
116 self.log.
debug(
'Configuring input for step %s', self.
name)
117 if self.
input is None:
118 self.misconfig_abort(
119 'Input not provided for this step. To configure'
120 'a step without input, use an empty string')
123 if len(self.
input) == 0:
127 if is_input_defined(self.
input):
130 self.misconfig_abort(
'Failed to load input with keyword %s', self.
input)
135 for path
in input_paths:
137 self.misconfig_abort(f
"The provided input does not exist: {path}")
138 self.log.
debug(
'Using explicit input: %s', self.
input)
141 '''Check job options configuration'''
142 self.log.
debug(
'Configuring job options for step %s', self.
name)
143 if self.
type ==
'other':
144 self.log.
debug(
'Skipping job options check for step.type=other')
147 self.log.
debug(
'Skipping job options check for step running from a pickle file')
150 if self.
type.endswith(
'_tf'):
154 self.misconfig_abort(
'Transform %s does not accept job options', self.
type)
156 self.misconfig_abort(
'Job options not provided for this step')
159 '''Add preExec to transform command'''
161 if self.
type in [
'Reco_tf',
'Trig_reco_tf',
'Derivation_tf']:
162 if 'inputBS_RDOFile' in self.
args:
163 precommand =
'BSRDOtoRAW:' + precommand
164 elif 'outputRDO_TRIGFile' in self.
args or 'doRDO_TRIG' in self.
args:
165 precommand =
'RDOtoRDOTrigger:' + precommand
167 self.log.
debug(
'Skip adding precommand %s to step %s because it is a transform which '
168 'does not run Trigger', precommand, self.
name)
172 m = re.search(
r'--preExec\s*=?\s*', self.
args)
174 self.
args += f
' --preExec "{precommand}" '
178 self.
args = self.
args[:m.span()[0]] + f
' --preExec "{precommand}" ' + self.
args[m.span()[1]:]
181 self.log.
debug(
'Configuring args for step %s', self.
name)
182 if self.
args is None:
187 if self.
type ==
'Reco_tf' or self.
type ==
'Derivation_tf':
192 self.log.
debug(
'Disabling perfmon because forks=%d > 1', self.
forks)
197 self.log.
debug(
'Disabling perfmon for the transform step type %s', self.
type)
201 if self.
type !=
'other':
203 athenaopts +=
' --imf'
205 if self.
type ==
'athenaHLT' or self.
type ==
'athenaEF':
206 athenaopts +=
' --perfmon'
207 elif self.
type ==
'athena':
208 athenaopts +=
' --perfmon=fastmonmt'
210 athenaopts +=
" --stdcmalloc "
213 if self.
type !=
'other':
215 self.
flags.append(
'Trigger.CostMonitoring.monitorAllEvents=True')
217 self.
flags.append(
'Exec.FPE=1')
222 if self.
type ==
'athenaHLT' or self.
type ==
'athenaEF' or (self.
type ==
"other" and self.
executable ==
"athenaHLT.py")
or (self.
type ==
"other" and self.
executable ==
"athenaEF.py") :
223 athenaopts +=
' --dump-config-exit'
225 elif self.
type ==
'athena' or self.
type ==
'Reco_tf' or self.
type ==
'Derivation_tf' or (self.
type ==
"other" and self.
executable ==
"athena.py") :
226 athenaopts +=
' --config-only=' + self.
name +
'.pkl'
231 self.misconfig_abort(
'Cannot determine what config-only option is needed. Consider adding the appropriate flag to "args" instead.')
234 if test.package_name ==
'TrigP1Test' and self.
type ==
'athenaHLT':
239 if self.
forks is None:
241 if test.package_name ==
'TrigP1Test' and self.
type ==
'athenaEF':
249 athenaopts +=
' --threads={}'.format(self.
threads)
251 athenaopts +=
' --concurrent-events={}'.format(
253 if self.
forks is not None and self.
type !=
'athenaEF':
254 athenaopts +=
' --nprocs={}'.format(self.
forks)
257 athenaopts = athenaopts.strip()
258 if self.
type.endswith(
'_tf'):
259 self.
args +=
' --athenaopts="{}"'.format(athenaopts)
261 self.
args +=
' '+athenaopts
265 if test.art_type ==
'build':
266 if test.package_name ==
'TrigP1Test':
281 if self.
type ==
'athena':
283 elif self.
type ==
'athenaHLT' or self.
type ==
'athenaEF':
285 elif self.
type.endswith(
'_tf'):
288 if self.
type ==
'athena':
290 elif self.
type ==
'athenaHLT' or self.
type ==
'athenaEF':
292 elif self.
type.endswith(
'_tf'):
296 if len(self.
input) > 0:
298 if self.
type ==
'athenaHLT' or self.
type ==
'athenaEF':
303 input_str = self.
input
304 if self.
type ==
'athena':
305 self.
args +=
' --filesInput={}'.format(input_str)
306 elif self.
type ==
'athenaHLT' or self.
type ==
'athenaEF':
307 self.
args +=
''.join([f
" --file={inputFile}" for inputFile
in input_str.split(
',')])
308 elif self.
type.endswith(
'_tf'):
310 self.misconfig_abort(
311 'Cannot build inputXYZFile string for transform '
312 ' from explicit input path. Use input=\'\' and '
313 'specify the input explicitly in args')
314 if self.
type ==
'Trig_reco_tf' and '--prodSysBSRDO True' in self.
args:
315 self.
args +=
' --inputBS_RDOFile={}'.format(input_str)
317 self.
args +=
' --input{}File={}'.format(
327 if not isinstance(self.
flags, (list, tuple)):
328 self.misconfig_abort(
'Wrong type for flags. Expected list or tuple.')
330 if self.
type.endswith(
'_tf'):
331 if self.
type ==
'Trig_reco_tf':
_is_good_file(self, path)
configure_args(self, test)
configure_job_options(self)
__init__(self, name=None)
add_trf_precommand(self, precommand)
std::vector< std::string > split(const std::string &s, const std::string &t=":")