Skip to content

Commit 10b6ee1

Browse files
committed
fix deprecated terms + update lint checker script
Signed-off-by: Michael Oviedo <[email protected]>
1 parent b8ba4b5 commit 10b6ee1

File tree

5 files changed

+33
-22
lines changed

5 files changed

+33
-22
lines changed

.ci/scripts/check_deprecated_terms.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python3
22
# .ci/scripts/check_deprecated_terms.py
3-
3+
44
import os, re, sys, argparse
5-
5+
66
# ---- Term sets ----
77
# Block these when you're on the *2.x* branch (i.e., forbid legacy 1.x names):
88
TERMS_1X = [
@@ -13,7 +13,7 @@
1313
"load-worker-coordinator-hosts",
1414
"execute-test",
1515
]
16-
16+
1717
# Block these when you're on the *1.x* branch (i.e., forbid 2.x names):
1818
TERMS_2X = [
1919
"cluster-configs",
@@ -22,10 +22,15 @@
2222
"run-test",
2323
"test-run",
2424
]
25-
25+
2626
SKIP_DIRS = {".git", "venv", "__pycache__", ".pytest_cache", ".ci", "tests"}
2727
VALID_EXTENSIONS = (".py", ".yml", ".yaml", ".md", ".sh", ".json", ".txt")
28-
28+
29+
SUPRESS_MARKERS = {
30+
"block-1x": "check-deprecated-terms-disable-1x",
31+
"block-2x": "check-deprecated-terms-disable-2x"
32+
}
33+
2934
def generate_variants(term: str) -> set[str]:
3035
base = term.replace("-", " ").replace("_", " ")
3136
words = base.split()
@@ -35,26 +40,27 @@ def generate_variants(term: str) -> set[str]:
3540
variants.add("_".join(words))
3641
variants.add("".join([w.capitalize() for w in words])) # PascalCase
3742
variants.add(words[0] + "".join([w.capitalize() for w in words[1:]])) # camelCase
38-
43+
3944
# Optional: flip order for 2-word terms, but avoid silly "-ip" flips creating noise
4045
if len(words) == 2 and not words[1].lower() == "ip":
4146
variants.add("-".join(words[::-1]))
4247
variants.add("_".join(words[::-1]))
4348
variants.add(words[1] + words[0].capitalize()) # camelCase reverse
4449
return variants
45-
50+
4651
def build_patterns(terms: list[str]) -> list[re.Pattern]:
4752
pats = []
4853
for t in terms:
4954
for v in generate_variants(t):
5055
pats.append(re.compile(re.escape(v), re.IGNORECASE))
5156
return pats
52-
57+
5358
def should_check_file(path: str) -> bool:
5459
return path.endswith(VALID_EXTENSIONS)
55-
56-
def walk_and_check(patterns: list[re.Pattern]) -> int:
60+
61+
def walk_and_check(patterns: list[re.Pattern], mode: str) -> int:
5762
error_found = 0
63+
suppress_marker = SUPRESS_MARKERS.get(mode)
5864
for root, _, files in os.walk("."):
5965
if any(skip in root.split(os.sep) for skip in SKIP_DIRS):
6066
continue
@@ -64,7 +70,11 @@ def walk_and_check(patterns: list[re.Pattern]) -> int:
6470
continue
6571
try:
6672
with open(full_path, "r", encoding="utf-8") as fh:
73+
previous_line = ""
6774
for i, line in enumerate(fh, 1):
75+
if suppress_marker in previous_line or suppress_marker in line:
76+
previous_line = line
77+
continue
6878
for patt in patterns:
6979
if patt.search(line):
7080
print(f"[Forbidden Term] {full_path}:{i}: {line.strip()}")
@@ -73,31 +83,31 @@ def walk_and_check(patterns: list[re.Pattern]) -> int:
7383
except Exception as e:
7484
print(f"[Warning] Skipped file {full_path}: {e}")
7585
return error_found
76-
86+
7787
def main():
7888
p = argparse.ArgumentParser(description="Check forbidden term set by mode or env.")
7989
p.add_argument("--mode", choices=["block-1x", "block-2x"], default=os.getenv("OSB_TERM_MODE"))
8090
args = p.parse_args()
81-
91+
8292
mode = args.mode
8393
if not mode:
8494
print("No mode provided (use --mode block-1x | block-2x or set OSB_TERM_MODE). Exiting 0.")
8595
sys.exit(0)
86-
96+
8797
if mode == "block-1x":
8898
terms = TERMS_1X
8999
banner = "❌ 1.x terms found in 2.x branch. Replace with 2.x names."
90100
else:
91101
terms = TERMS_2X
92102
banner = "❌ 2.x terms found in 1.x branch. Replace with 1.x names."
93-
103+
94104
patterns = build_patterns(terms)
95-
failed = walk_and_check(patterns)
105+
failed = walk_and_check(patterns, mode)
96106
if failed:
97107
print("\n" + banner)
98108
sys.exit(1)
99109
print("✅ No forbidden terms found for", mode)
100110
sys.exit(0)
101-
111+
102112
if __name__ == "__main__":
103113
main()

RELEASE_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Add backport labels to PRs and commits so that changes can be added to `main` br
7373
3. Run `opensearch-benchmark --version` to ensure that it is the correct version
7474
4. Run `opensearch-benchmark --help`
7575
5. Run `opensearch-benchmark list workloads`
76-
6. Run a basic workload on Linux and MacOS: `opensearch-benchmark execute-test --workload pmc --test-mode`
76+
6. Run a basic workload on Linux and MacOS: `opensearch-benchmark run --workload pmc --test-mode`
7777
7. If you are fastidious, you can check the installed source files at `` `python3 -m site --user-site`/osbenchmark `` to verify that a recent change is indeed present.
7878

7979
8. Verify Docker Hub Staging OSB Image Works:

osbenchmark/benchmark.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,7 @@ def handle_command_suggestions():
12311231
Check for common command mistakes and provide helpful suggestions
12321232
Returns True if suggestion was provided, False otherwise
12331233
"""
1234+
# check-deprecated-terms-disable-1x
12341235
DEPRECATED_SUBCOMMANDS = ["execute-test", "execute"]
12351236
if len(sys.argv) > 1 and sys.argv[1] in DEPRECATED_SUBCOMMANDS:
12361237
console.info("Did you mean 'run'?")

osbenchmark/publisher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Throughput(Enum):
5252
MEDIAN = "median"
5353

5454
def summarize(results, cfg):
55-
SummaryResultsPublisher(results, cfg).publish()
55+
SummaryResultsPublisher(results, cfg).publish() # check-deprecated-terms-disable-1x
5656

5757

5858
def compare(cfg, baseline_id, contender_id):
@@ -115,7 +115,7 @@ def comma_separated_string_to_number_list(string_list):
115115
return results
116116

117117

118-
118+
# check-deprecated-terms-disable-1x
119119
class SummaryResultsPublisher:
120120
def __init__(self, results, config):
121121
self.results = results

osbenchmark/utils/console.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ def println(msg, console_prefix=None, end="\n", flush=False, force=False, logger
168168

169169

170170
def progress(width=90):
171-
return CmdLineProgressResultsPublisher(width, plain_output=PLAIN)
172-
171+
return CmdLineProgressResultsPublisher(width, plain_output=PLAIN) # check-deprecated-terms-disable-1x
173172

173+
# check-deprecated-terms-disable-1x
174174
class CmdLineProgressResultsPublisher:
175175
"""
176-
CmdLineProgressResultsPublisher supports displaying an updating progress indication together with an information message.
176+
This class supports displaying an updating progress indication together with an information message.
177177
178178
:param printer: allow use of a different print method to assist with patching in unittests
179179
"""

0 commit comments

Comments
 (0)