Skip to content

Commit 45b6b9d

Browse files
authored
Merge pull request #44005 from missirol/devel_hltInteg
add option to restrict single-Path jobs of `hltIntegrationTests` to a subset of triggers
2 parents c1bc0fc + 043b424 commit 45b6b9d

File tree

2 files changed

+71
-50
lines changed

2 files changed

+71
-50
lines changed

HLTrigger/Configuration/scripts/hltIntegrationTests

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function err() {
1919

2020
NAME=$(basename $0)
2121

22-
HELP="Run the integration tests over all paths in a given HLT menu.
22+
HELP="Run the integration tests on a given HLT menu.
2323
2424
Usage:
2525
$NAME -h|--help
@@ -42,6 +42,10 @@ Usage:
4242
--streams STREAMS Run with STREAMS parallel streams (i.e. events) (default 0 means as many streams as threads)
4343
--threads THREADS Run with THREADS threads when running the whole HLT (default 4)
4444
-a | --accelerator ACCELERATOR Keyword to choose allowed accelerators (examples: \"*\", \"cpu\", \"gpu-nvidia\")
45+
-p | --paths PATHS Comma-separated list of Path names (incl. wildcards)
46+
to select which Paths are tested standalone.
47+
If a Path-name pattern starts with the dash character (-),
48+
the Paths whose name matches that pattern will be ignored.
4549
-x | --extra OPTIONS If the HLT menu is a local cmsRun cfg file, OPTIONS is used as
4650
additional arguments to cmsRun (i.e. \"cmsRun hlt.py [OPTIONS]\")
4751
If the HLT menu is the name of a ConfDB configuration, OPTIONS is used as
@@ -95,8 +99,8 @@ Examples:
9599
"
96100

97101
# parse command line argument and options
98-
OPTS=$(getopt -n "$NAME" -o "s:d:i:j:n:k:e:a:x:h" \
99-
-l "setup:,dir:,input:,jobs:,size:,skip:,streams:,threads:,accelerator:,events:,mc,extra:,help,dbproxy,dbproxyhost:,dbproxyport:" -- "$@")
102+
OPTS=$(getopt -n "$NAME" -o "s:d:i:j:n:k:e:p:a:x:h" \
103+
-l "setup:,dir:,input:,jobs:,size:,skip:,streams:,threads:,paths:,accelerator:,events:,mc,extra:,help,dbproxy,dbproxyhost:,dbproxyport:" -- "$@")
100104

101105
# invalid options
102106
if [ $? != 0 ]; then
@@ -118,6 +122,7 @@ EVENTS=""
118122
JOBS=4
119123
THREADS=4
120124
STREAMS=0
125+
PATHS=""
121126
ACCELERATOR="cpu"
122127
WORKDIR="hltintegration"
123128
EXTRA=""
@@ -200,6 +205,10 @@ while true; do
200205
THREADS=$2
201206
shift 2
202207
;;
208+
"-p" | "--paths" )
209+
PATHS="$2"
210+
shift 2
211+
;;
203212
"-a" | "--accelerator" )
204213
ACCELERATOR="$2"
205214
shift 2
@@ -320,10 +329,10 @@ else
320329
# if ${DATA} is empty, set it to "--data"
321330
[ "${DATA}" ] || DATA="--data"
322331
# download HLT menu from ConfDB
323-
HLTGETCMD="hltGetConfiguration ${MENU} \
332+
HLTGETCMD="hltGetConfiguration ${MENU}
324333
--process \"TEST$(date -u +'%Y%m%d%H%M%S')\"
325-
--full --offline ${DATA} --unprescale \
326-
--max-events ${SIZE} ${EXTRA} ${DBPROXYOPTS} --input ${INPUT}"
334+
--max-events ${SIZE} --no-prescale --no-output
335+
${DATA} --input ${INPUT} ${EXTRA} ${DBPROXYOPTS}"
327336
HLTGETCMD=$(echo "${HLTGETCMD}" | xargs)
328337
log "Creating HLT menu from ConfDB configuration:\n> ${HLTGETCMD}"
329338
${HLTGETCMD} > hlt.py
@@ -355,38 +364,41 @@ if [ "${SELECTION}" == "complex" ]; then
355364
process.source.eventsToProcess = cms.untracked.VEventRange( '$(echo $EVENTS | sed -e"s/,/','/g")' )
356365
@EOF
357366

358-
elif (( $SKIP > 0 )); then
367+
elif (( ${SKIP} > 0 )); then
359368
cat >> hlt.py << @EOF
360369
361370
# event selection customised by hltIntegrationTests
362-
process.source.skipEvents = cms.untracked.uint32( $SKIP )
371+
process.source.skipEvents = cms.untracked.uint32( ${SKIP} )
363372
@EOF
364373
fi
365374

366375
# set the number of threads and streams for the whole hlt job
367376
cat >> hlt.py << @EOF
368377
369378
# configure multithreading, and allocate 10 MB of stack space per thread
370-
process.options.numberOfThreads = $THREADS
371-
process.options.numberOfStreams = $STREAMS
379+
process.options.numberOfThreads = ${THREADS}
380+
process.options.numberOfStreams = ${STREAMS}
372381
process.options.sizeOfStackForThreadsInKB = 10*1024
373382
# set allowed accelerators
374383
process.options.accelerators = [ "$ACCELERATOR" ]
375384
376385
process.hltTriggerSummaryAOD.throw = cms.bool( True )
377386
@EOF
378387

379-
# find the list of all trigger paths
380-
TRIGGERS=$(hltListPaths hlt.py -p --no-dep --exclude "^HLTriggerFinalPath$")
388+
# list of trigger Paths to be tested standalone (always exclude HLTriggerFinalPath)
389+
log "Preparing list of trigger Paths to be tested standalone (paths.txt)"
390+
[ "${PATHS}" ] || PATHS="*"
391+
PATHS+=",-HLTriggerFinalPath"
392+
TRIGGERS=$(hltListPaths hlt.py -p --no-dep --select-paths "${PATHS}")
381393
echo "${TRIGGERS[@]}" > paths.txt
382394

383395
# print some info
384-
if [ "$SELECTION" == "complex" ]; then
385-
log "Will run $(echo $TRIGGERS | wc -w) HLT paths over $(echo $EVENTS | tr ',' '\n' | wc -l) events, with $JOBS jobs in parallel"
386-
elif [ "$SIZE" == "-1" ]; then
387-
log "Will run $(echo $TRIGGERS | wc -w) HLT paths over all events, with $JOBS jobs in parallel"
396+
if [ "${SELECTION}" == "complex" ]; then
397+
log "Will run full menu and $(echo $TRIGGERS | wc -w) triggers standalone over $(echo ${EVENTS} | tr ',' '\n' | wc -l) events, with ${JOBS} jobs in parallel"
398+
elif [ "${SIZE}" == "-1" ]; then
399+
log "Will run full menu and $(echo ${TRIGGERS} | wc -w) triggers standalone over all events, with ${JOBS} jobs in parallel"
388400
else
389-
log "Will run $(echo $TRIGGERS | wc -w) HLT paths over $SIZE events, with $JOBS jobs in parallel"
401+
log "Will run full menu and $(echo ${TRIGGERS} | wc -w) triggers standalone over ${SIZE} events, with ${JOBS} jobs in parallel"
390402
fi
391403

392404
# check the prescale modules
@@ -427,15 +439,15 @@ if [ "${SETUP}" ]; then
427439
log "Creating setup_cff from ConfDB configuration: ${SETUP_Vx}/${SETUP_DB}:${SETUP}"
428440
hltConfigFromDB --${SETUP_Vx} --${SETUP_DB} ${DBPROXYOPTS} --cff --configName "$SETUP" \
429441
--nopaths --services -FUShmDQMOutputService,-PrescaleService,-EvFDaqDirector,-FastMonitoringService > setup_cff.py
430-
sed -i -e's/process = cms.Process(.*)/&\nprocess.load("setup_cff")/' hlt.py $(for TRIGGER in $TRIGGERS; do echo "${TRIGGER}".py; done)
442+
sed -i -e's/process = cms.Process(.*)/&\nprocess.load("setup_cff")/' hlt.py $(for TRIGGER in ${TRIGGERS}; do echo "${TRIGGER}".py; done)
431443
else
432444
printf "%s\n" "WARNING -- \"--setup ${SETUP}\" will be ignored (failed to deduce name of HLT menu from hlt.py)"
433445
fi
434446
fi
435447

436448
# run all HLT dumps
437449
cat > .makefile << @EOF
438-
TRIGGERS=$(echo $TRIGGERS)
450+
TRIGGERS=$(echo ${TRIGGERS})
439451
CFGS=\$(TRIGGERS:%=%.py)
440452
LOGS=\$(TRIGGERS:%=%.log)
441453
DONE=\$(TRIGGERS:%=%.done)

HLTrigger/Configuration/scripts/hltListPaths

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@
22
import os
33
import sys
44
import argparse
5-
import re
5+
import fnmatch
6+
67
import FWCore.ParameterSet.Config as cms
78
import HLTrigger.Configuration.Tools.pipe as pipe
89
import HLTrigger.Configuration.Tools.options as options
910
from HLTrigger.Configuration.extend_argparse import *
1011

11-
def getPathList(config):
12+
def getPathList(args):
1213

13-
if isinstance(config.menu, options.ConnectionHLTMenu):
14+
if isinstance(args.menu, options.ConnectionHLTMenu):
1415
# cmd to download HLT configuration
1516
cmdline = 'hltConfigFromDB'
16-
if config.menu.run:
17-
cmdline += f' --runNumber {config.menu.run}'
17+
if args.menu.run:
18+
cmdline += f' --runNumber {args.menu.run}'
1819
else:
19-
cmdline += f' --{config.menu.database} --{config.menu.version} --configName {config.menu.name}'
20+
cmdline += f' --{args.menu.database} --{args.menu.version} --configName {args.menu.name}'
2021
cmdline += ' --noedsources --noes --noservices'
21-
if config.proxy:
22-
cmdline += f' --dbproxy --dbproxyhost {config.proxy_host} --dbproxyport {config.proxy_port}'
22+
if args.proxy:
23+
cmdline += f' --dbproxy --dbproxyhost {args.proxy_host} --dbproxyport {args.proxy_port}'
2324

2425
else:
2526
# use edmConfigDump to ensure the config can be executed
26-
cmdline = f'edmConfigDump {config.menu}'
27+
cmdline = f'edmConfigDump {args.menu}'
2728

2829
# load HLT configuration
2930
try:
@@ -39,24 +40,33 @@ def getPathList(config):
3940
usePaths, useEndPaths, useFinalPaths = False, False, False
4041

4142
# Paths only
42-
if config.selection == 'paths':
43+
if args.selection == 'paths':
4344
usePaths = True
4445

4546
# EndPaths only
46-
elif config.selection == 'endpaths':
47+
elif args.selection == 'endpaths':
4748
useEndPaths = True
4849

4950
# FinalPaths only
50-
elif config.selection == 'finalpaths':
51+
elif args.selection == 'finalpaths':
5152
useFinalPaths = True
5253

5354
# Paths, EndPaths, and FinalPaths ('all')
54-
elif config.selection == 'all':
55+
elif args.selection == 'all':
5556
usePaths, useEndPaths, useFinalPaths = True, True, True
5657

5758
# invalid value
5859
else:
59-
raise RuntimeError(f'ERROR: invalid value for option "--selection" (must be "paths", "endpaths", "finalpaths", or "all"): {config.selection}')
60+
raise RuntimeError(f'ERROR: invalid value for option "--selection" (must be "paths", "endpaths", "finalpaths", or "all"): {args.selection}')
61+
62+
path_keep_rules = []
63+
for path_keep_rule in args.path_keep_rules.split(','):
64+
if not path_keep_rule:
65+
continue
66+
keep_rule = not path_keep_rule.startswith('-')
67+
pattern_idx = 0 if keep_rule else 1
68+
rule_pattern = path_keep_rule[pattern_idx:]
69+
path_keep_rules += [(keep_rule, rule_pattern)]
6070

6171
ret = []
6272
for pathDict in [
@@ -69,17 +79,16 @@ def getPathList(config):
6979

7080
for pathName in pathDict:
7181

72-
# skip if name of the path matches any of
73-
# the regular expressions listed in "--exclude"
74-
skipPath = False
75-
for excludeRegExpr in config.excludeRegExprs:
76-
if bool(re.search(excludeRegExpr, pathName)):
77-
skipPath = True
78-
break
79-
if skipPath:
82+
# keep or drop the Path based on whether or not
83+
# its name complies with the patterns in path_keep_rules (if any)
84+
keepPath = not path_keep_rules
85+
for (keep_rule, rule_pattern) in path_keep_rules:
86+
if fnmatch.fnmatch(pathName, rule_pattern):
87+
keepPath = keep_rule
88+
if not keepPath:
8089
continue
8190

82-
if config.no_dependent_paths:
91+
if args.no_dependent_paths:
8392
# do not include "dependent paths", i.e. paths that depend on the result of other paths in the same job
8493
# the current criterion to identify a path as "dependent" is that
8594
# (1) the path contains a "TriggerResultsFilter" module and
@@ -146,7 +155,7 @@ parser.add_argument('menu',
146155
action = 'store',
147156
type = hltMenu,
148157
metavar = 'MENU',
149-
help = 'HLT menu (can be a local cmsRun configuration file, or the name of a configuration in the ConfDB database). For ConfDB configurations, supported formats are:\n - /path/to/configuration[/Vn]\n - [[{v1|v2|v3}/]{run3|run2|online|adg}:]/path/to/configuration[/Vn]\n - run:runnumber\nThe possible converters are "v1", "v2, and "v3" (default).\nThe possible databases are "run3" (default, used for offline development), "run2" (used for accessing run2 offline development menus), "online" (used to extract online menus within Point 5) and "adg" (used to extract the online menus outside Point 5).\nIf no menu version is specified, the latest one is automatically used.\nIf "run:" is used instead, the HLT menu used for the given run number is looked up and used.\nNote other converters and databases exist as options but they are only for expert/special use.' )
158+
help = 'HLT menu (can be a local cmsRun configuration file, or the name of a configuration in the ConfDB database).\nFor ConfDB configurations, supported formats are:\n- /path/to/configuration[/Vn]\n- [[{v1|v2|v3}/]{run3|run2|online|adg}:]/path/to/configuration[/Vn]\n- run:runnumber\nThe possible converters are "v1", "v2, and "v3" (default).\nThe possible databases are\n"run3" (default, used for offline development in Run 3),\n"run2" (used for accessing Run-2 offline development menus),\n"online" (used to extract online menus from inside Point 5) and\n"adg" (used to extract the online menus from outside Point 5).\nIf no menu version is specified, the latest one is automatically used.\nIf "run:" is used instead, the HLT menu used for the given run number is looked up and used.\nNote: other converters and databases exist, but they are only for expert/special use.' )
150159

151160
# options
152161
parser.add_argument('--dbproxy',
@@ -196,20 +205,20 @@ parser.add_argument('--no-dependent-paths',
196205
default = False,
197206
help = 'Do not list paths which depend on the result of other paths (default: false)' )
198207

199-
parser.add_argument('--exclude',
200-
dest = 'excludeRegExprs',
201-
nargs = '+',
202-
default = [],
203-
help = 'List of regular expressions to select names of paths to be ignored with re.search (default: empty)' )
208+
parser.add_argument('-s', '--select-paths',
209+
dest = 'path_keep_rules',
210+
action = 'store',
211+
default = '',
212+
help = 'Comma-separated list of Path-name patterns (incl. wildcards) to select a subset of Paths using fnmatch.\nIf a Path-name pattern starts with the dash character (-), the Paths whose name matches that pattern are not selected.\nThe patterns are ordered: a given pattern can override previous ones (example: "*,-Foo,*" retains all Paths)\n(default: empty, meaning all Paths are kept)')
204213

205214
# redefine "--help" to be the last option, and use a customized message
206215
parser.add_argument('-h', '--help',
207216
action = 'help',
208217
help = 'Show this help message and exit' )
209218

210219
# parse command line arguments and options
211-
config = parser.parse_args()
220+
args = parser.parse_args()
212221

213-
paths = getPathList(config)
222+
paths = getPathList(args)
214223
for path in paths:
215224
print(path)

0 commit comments

Comments
 (0)