Skip to content

Commit 8db80c4

Browse files
committed
add precommit hook to remove redundant tab and white space
Signed-off-by: Xin He (SW-GPU) <[email protected]>
1 parent 40a9c61 commit 8db80c4

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ repos:
8484
files: ".*/auto_deploy/.*"
8585
- repo: local
8686
hooks:
87+
- id: test lists format
88+
name: Check for tabs and multiple spaces in test_lists txt files
89+
entry: ./scripts/format_test_list.py
90+
language: script
91+
files: tests/integration/test_lists/.*\.txt$
8792
- id: DCO check
8893
name: Checks the commit message for a developer certificate of origin signature
8994
entry: ./scripts/dco_check.py

scripts/format_test_list.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python3
2+
"""Normalize tabs and multiple spaces to single spaces in files."""
3+
import argparse
4+
import re
5+
import sys
6+
7+
8+
def normalize_whitespace(content: str) -> str:
9+
"""Remove leading whitespace, replace tabs and multiple spaces with single spaces."""
10+
lines = content.splitlines(keepends=True)
11+
normalized_lines = []
12+
13+
for line in lines:
14+
# Remove leading whitespace and tabs
15+
line = line.lstrip(' \t')
16+
# Replace tabs with single space
17+
line = line.replace('\t', ' ')
18+
# Replace multiple spaces with single space
19+
line = re.sub(r' +', ' ', line)
20+
normalized_lines.append(line)
21+
22+
return ''.join(normalized_lines)
23+
24+
25+
def main():
26+
parser = argparse.ArgumentParser(
27+
description='Normalize tabs and multiple spaces to single spaces')
28+
parser.add_argument('filenames', nargs='*', help='Filenames to fix')
29+
args = parser.parse_args()
30+
31+
retval = 0
32+
for filename in args.filenames:
33+
with open(filename, 'r', encoding='utf-8') as f:
34+
original_contents = f.read()
35+
36+
normalized_contents = normalize_whitespace(original_contents)
37+
38+
if original_contents != normalized_contents:
39+
print(f'Fixing {filename}')
40+
with open(filename, 'w', encoding='utf-8') as f:
41+
f.write(normalized_contents)
42+
retval = 1
43+
44+
return retval
45+
46+
47+
if __name__ == '__main__':
48+
sys.exit(main())

tests/integration/test_lists/waives.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ full:B200_PCIe/unittest/test_model_runner_cpp.py SKIP (Disable for Blackwell)
5555
full:B200_PCIe/unittest/llmapi/test_llm_models.py -m "part0" SKIP (Disable for Blackwell for context fmha doesn't support when headsize is 80/96)
5656
full:B200_PCIe/examples/test_nemotron.py::test_llm_nemotron_3_8b_1gpu[bfloat16-fp8] SKIP (megatron-core 0.8 is not supported in python 3.12)
5757
full:B200_PCIe/accuracy/test_cli_flow.py::TestMixtral8x7B::test_fp4_plugin SKIP (Disable for Blackwell OOM)
58-
full:B200_PCIe/unittest/llmapi/test_llm_models.py -m "not (part0 or part1)" SKIP (Disable for Blackwell OOM)
58+
full:B200_PCIe/unittest/llmapi/test_llm_models.py -m "not (part0 or part1)" SKIP (Disable for Blackwell OOM)
5959
full:B200/unittest/trt/functional SKIP (Disable for Blackwell)
6060
full:B200/unittest/trt/quantization SKIP (Disable for Blackwell)
6161
full:B200/unittest/trt/attention/test_bert_attention.py SKIP (Disable for Blackwell)
@@ -70,7 +70,7 @@ full:B200/unittest/llmapi/test_llm_models.py -m "part0" SKIP (Disable for Blackw
7070
full:B200/examples/test_multimodal.py::test_llm_multimodal_general[video-neva-pp:1-tp:1-bfloat16-bs:1-cpp_e2e:False-nb:1] SKIP (megatron-core 0.8 is not supported in python 3.12)
7171
full:B200/examples/test_nemotron.py::test_llm_nemotron_3_8b_1gpu[bfloat16-fp8] SKIP (megatron-core 0.8 is not supported in python 3.12)
7272
full:B200/accuracy/test_cli_flow.py::TestMixtral8x7B::test_fp4_plugin SKIP (Disable for Blackwell OOM)
73-
full:B200/unittest/llmapi/test_llm_models.py -m "not (part0 or part1)" SKIP (Disable for Blackwell OOM)
73+
full:B200/unittest/llmapi/test_llm_models.py -m "not (part0 or part1)" SKIP (Disable for Blackwell OOM)
7474
full:B200/examples/test_mixtral.py::test_llm_mixtral_moe_plugin_fp8_lora_4gpus[Mixtral-8x7B-v0.1-chinese-mixtral-lora] SKIP (https://nvbugs/5064768)
7575
examples/test_qwen.py::test_llm_qwen_moe_multi_gpu_summary[qwen2_57b_a14b-tp4pp1-context_fmha] SKIP (https://nvbugs/5063469)
7676
examples/test_qwen.py::test_llm_qwen_moe_multi_gpu_summary[qwen2_57b_a14b-tp2pp2-context_fmha_fp32_acc] SKIP (https://nvbugs/5063469)

0 commit comments

Comments
 (0)