Skip to content

Commit 9f814c9

Browse files
afeldman-nmwwl2755-google
authored andcommitted
Disable "Forbid direct 'import triton'" check for vllm/triton_utils/importing.py in an extensible way (vllm-project#19783)
Signed-off-by: Andrew Feldman <afeldman@redhat.com>
1 parent c8cc9e8 commit 9f814c9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/check_triton_import.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
"from vllm.triton_utils import tl, triton",
1515
}
1616

17+
ALLOWED_FILES = {"vllm/triton_utils/importing.py"}
18+
19+
20+
def is_allowed_file(current_file: str) -> bool:
21+
return current_file in ALLOWED_FILES
22+
1723

1824
def is_forbidden_import(line: str) -> bool:
1925
stripped = line.strip()
@@ -25,10 +31,14 @@ def parse_diff(diff: str) -> list[str]:
2531
violations = []
2632
current_file = None
2733
current_lineno = None
34+
skip_allowed_file = False
2835

2936
for line in diff.splitlines():
3037
if line.startswith("+++ b/"):
3138
current_file = line[6:]
39+
skip_allowed_file = is_allowed_file(current_file)
40+
elif skip_allowed_file:
41+
continue
3242
elif line.startswith("@@"):
3343
match = re.search(r"\+(\d+)", line)
3444
if match:

0 commit comments

Comments
 (0)