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 self.log.
debug(
'Configuring input for step %s', self.
name)
109 if self.
input is None:
110 self.misconfig_abort(
111 'Input not provided for this step. To configure'
112 'a step without input, use an empty string')
115 if len(self.
input) == 0:
119 if is_input_defined(self.
input):
122 self.misconfig_abort(
'Failed to load input with keyword %s', self.
input)
127 for path
in input_paths:
128 if not os.path.isfile(path):
129 self.misconfig_abort(
'The provided input does not exist: %s', self.
input)
130 self.log.
debug(
'Using explicit input: %s', self.
input)
133 '''Check job options configuration'''
134 self.log.
debug(
'Configuring job options for step %s', self.
name)
135 if self.
type ==
'other':
136 self.log.
debug(
'Skipping job options check for step.type=other')
139 self.log.
debug(
'Skipping job options check for step running from a pickle file')
142 if self.
type.endswith(
'_tf'):
146 self.misconfig_abort(
'Transform %s does not accept job options', self.
type)
148 self.misconfig_abort(
'Job options not provided for this step')
151 '''Add preExec to transform command'''
153 if self.
type in [
'Reco_tf',
'Trig_reco_tf',
'Derivation_tf']:
154 if 'inputBS_RDOFile' in self.
args:
155 precommand =
'BSRDOtoRAW:' + precommand
156 elif 'outputRDO_TRIGFile' in self.
args or 'doRDO_TRIG' in self.
args:
157 precommand =
'RDOtoRDOTrigger:' + precommand
159 self.log.
debug(
'Skip adding precommand %s to step %s because it is a transform which '
160 'does not run Trigger', precommand, self.
name)
164 m = re.search(
r'--preExec\s*=?\s*', self.
args)
166 self.
args += f
' --preExec "{precommand}" '
170 self.
args = self.
args[:m.span()[0]] + f
' --preExec "{precommand}" ' + self.
args[m.span()[1]:]
173 self.log.
debug(
'Configuring args for step %s', self.
name)
174 if self.
args is None:
179 if self.
type ==
'Reco_tf' or self.
type ==
'Derivation_tf':
184 self.log.
debug(
'Disabling perfmon because forks=%d > 1', self.
forks)
189 self.log.
debug(
'Disabling perfmon for the transform step type %s', self.
type)
193 if self.
type !=
'other':
195 athenaopts +=
' --imf'
197 if self.
type ==
'athenaHLT' or self.
type ==
'athenaEF':
198 athenaopts +=
' --perfmon'
199 elif self.
type ==
'athena':
200 athenaopts +=
' --perfmon=fastmonmt'
202 athenaopts +=
" --stdcmalloc "
205 if self.
type !=
'other':
207 self.
flags.append(
'Trigger.CostMonitoring.monitorAllEvents=True')
209 self.
flags.append(
'Exec.FPE=1')
214 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") :
215 athenaopts +=
' --dump-config-exit'
217 elif self.
type ==
'athena' or self.
type ==
'Reco_tf' or self.
type ==
'Derivation_tf' or (self.
type ==
"other" and self.
executable ==
"athena.py") :
218 athenaopts +=
' --config-only=' + self.
name +
'.pkl'
223 self.misconfig_abort(
'Cannot determine what config-only option is needed. Consider adding the appropriate flag to "args" instead.')
226 if test.package_name ==
'TrigP1Test' and self.
type ==
'athenaHLT':
231 if self.
forks is None:
233 if test.package_name ==
'TrigP1Test' and self.
type ==
'athenaEF':
241 athenaopts +=
' --threads={}'.format(self.
threads)
243 athenaopts +=
' --concurrent-events={}'.format(
245 if self.
forks is not None and self.
type !=
'athenaEF':
246 athenaopts +=
' --nprocs={}'.format(self.
forks)
249 athenaopts = athenaopts.strip()
250 if self.
type.endswith(
'_tf'):
251 self.
args +=
' --athenaopts="{}"'.format(athenaopts)
253 self.
args +=
' '+athenaopts
257 if test.art_type ==
'build':
258 if test.package_name ==
'TrigP1Test':
273 if self.
type ==
'athena':
275 elif self.
type ==
'athenaHLT' or self.
type ==
'athenaEF':
277 elif self.
type.endswith(
'_tf'):
280 if self.
type ==
'athena':
282 elif self.
type ==
'athenaHLT' or self.
type ==
'athenaEF':
284 elif self.
type.endswith(
'_tf'):
288 if len(self.
input) > 0:
290 if self.
type ==
'athenaHLT' or self.
type ==
'athenaEF':
295 input_str = self.
input
296 if self.
type ==
'athena':
297 self.
args +=
' --filesInput={}'.format(input_str)
298 elif self.
type ==
'athenaHLT' or self.
type ==
'athenaEF':
299 self.
args +=
''.join([f
" --file={inputFile}" for inputFile
in input_str.split(
',')])
300 elif self.
type.endswith(
'_tf'):
302 self.misconfig_abort(
303 'Cannot build inputXYZFile string for transform '
304 ' from explicit input path. Use input=\'\' and '
305 'specify the input explicitly in args')
306 if self.
type ==
'Trig_reco_tf' and '--prodSysBSRDO True' in self.
args:
307 self.
args +=
' --inputBS_RDOFile={}'.format(input_str)
309 self.
args +=
' --input{}File={}'.format(
319 if not isinstance(self.
flags, (list, tuple)):
320 self.misconfig_abort(
'Wrong type for flags. Expected list or tuple.')
322 if self.
type.endswith(
'_tf'):
323 if self.
type ==
'Trig_reco_tf':
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=":")