Skip to content

Commit ac50279

Browse files
committed
feature request: add --restrictPathsTo option to run the integration tests on a subset of HLT paths only
1 parent b55c3d6 commit ac50279

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

HLTrigger/Configuration/python/HLT_75e33/test/hltPhase2UpgradeIntegrationTests.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import fnmatch
23
import os
34
import re
45
import shutil
@@ -52,6 +53,8 @@ def run_command(command, log_file=None, workdir=None):
5253
parser.add_argument("--events", type=int, default=10, help="Number of events to process")
5354
parser.add_argument("--parallelJobs", type=int, default=4, help="Number of parallel cmsRun HLT jobs")
5455
parser.add_argument("--threads", type=int, default=1, help="Number of threads to use")
56+
parser.add_argument("--restrictPathsTo", nargs='+', default=[], help="List of HLT paths to restrict to")
57+
5558

5659
# Step 0: Capture the start time and print the start timestamp
5760
start_time = time.time()
@@ -73,6 +76,7 @@ def run_command(command, log_file=None, workdir=None):
7376
num_events = args.events
7477
num_threads = args.threads
7578
num_parallel_jobs = args.parallelJobs
79+
restrict_paths_to = args.restrictPathsTo
7680

7781
# Print the values in a nice formatted manner
7882
print(f"{'Configuration Summary':^40}")
@@ -83,6 +87,9 @@ def run_command(command, log_file=None, workdir=None):
8387
print(f"Num Events: {num_events}")
8488
print(f"Num Threads: {num_threads}")
8589
print(f"Num Par. Jobs: {num_parallel_jobs}")
90+
# Print restrictPathsTo if provided
91+
if restrict_paths_to:
92+
print(f"Restricting paths to: {', '.join(restrict_paths_to)}")
8693
print("=" * 40)
8794

8895
# Directory where all test configurations will be stored
@@ -137,6 +144,34 @@ def run_command(command, log_file=None, workdir=None):
137144

138145
print(f"Found {len(hlt_paths)} HLT paths.")
139146

147+
# Step 3b: Restrict paths using wildcard patterns if the option is provided
148+
if restrict_paths_to:
149+
valid_paths = set() # Using a set to store matched paths
150+
151+
# Iterate over each provided pattern
152+
for pattern in restrict_paths_to:
153+
# Use fnmatch to match the pattern to hlt_paths
154+
matched = fnmatch.filter(hlt_paths, pattern)
155+
valid_paths.update(matched) # Add matches to the set of valid paths
156+
157+
# If no matches found, emit a warning for that pattern
158+
if not matched:
159+
print(f"Warning: No paths matched the pattern: {pattern}")
160+
161+
# Convert the set to a sorted list
162+
valid_paths = sorted(valid_paths)
163+
164+
# If no valid paths remain after filtering, exit
165+
if not valid_paths:
166+
print("Error: None of the specified patterns matched any paths. Exiting.")
167+
exit(1)
168+
169+
# Update hlt_paths to contain only the valid ones
170+
hlt_paths = valid_paths
171+
172+
# Continue using the restricted hlt_paths further down the script
173+
print(f"Using {len(hlt_paths)} HLT paths after applying restrictions.")
174+
140175
# Step 4: Broadened Regex for Matching process.schedule
141176
schedule_match = re.search(
142177
r"(process\.schedule\s*=\s*cms\.Schedule\(\*?\s*\[)([\s\S]+?)(\]\s*\))",

0 commit comments

Comments
 (0)