Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit ccd7207

Browse files
chore: Update check-wheel-size.py to read MAX_SIZE_MB from env (vllm-project#8103)
1 parent 855c262 commit ccd7207

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

.buildkite/check-wheel-size.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
11
import os
2+
import sys
23
import zipfile
34

4-
MAX_SIZE_MB = 250
5+
# Read the VLLM_MAX_SIZE_MB environment variable, defaulting to 250 MB
6+
VLLM_MAX_SIZE_MB = int(os.environ.get('VLLM_MAX_SIZE_MB', 250))
57

68

79
def print_top_10_largest_files(zip_file):
10+
"""Print the top 10 largest files in the given zip file."""
811
with zipfile.ZipFile(zip_file, 'r') as z:
912
file_sizes = [(f, z.getinfo(f).file_size) for f in z.namelist()]
1013
file_sizes.sort(key=lambda x: x[1], reverse=True)
1114
for f, size in file_sizes[:10]:
12-
print(f"{f}: {size/(1024*1024)} MBs uncompressed.")
15+
print(f"{f}: {size / (1024 * 1024):.2f} MBs uncompressed.")
1316

1417

1518
def check_wheel_size(directory):
19+
"""Check the size of .whl files in the given directory."""
1620
for root, _, files in os.walk(directory):
17-
for f in files:
18-
if f.endswith(".whl"):
19-
wheel_path = os.path.join(root, f)
20-
wheel_size = os.path.getsize(wheel_path)
21-
wheel_size_mb = wheel_size / (1024 * 1024)
22-
if wheel_size_mb > MAX_SIZE_MB:
23-
print(
24-
f"Wheel {wheel_path} is too large ({wheel_size_mb} MB) "
25-
f"compare to the allowed size ({MAX_SIZE_MB} MB).")
21+
for file_name in files:
22+
if file_name.endswith(".whl"):
23+
wheel_path = os.path.join(root, file_name)
24+
wheel_size_mb = os.path.getsize(wheel_path) / (1024 * 1024)
25+
if wheel_size_mb > VLLM_MAX_SIZE_MB:
26+
print(f"Not allowed: Wheel {wheel_path} is larger "
27+
f"({wheel_size_mb:.2f} MB) than the limit "
28+
f"({VLLM_MAX_SIZE_MB} MB).")
2629
print_top_10_largest_files(wheel_path)
2730
return 1
2831
else:
2932
print(f"Wheel {wheel_path} is within the allowed size "
30-
f"({wheel_size_mb} MB).")
33+
f"({wheel_size_mb:.2f} MB).")
3134
return 0
3235

3336

3437
if __name__ == "__main__":
35-
import sys
36-
sys.exit(check_wheel_size(sys.argv[1]))
38+
if len(sys.argv) < 2:
39+
print("Usage: python check-wheel-size.py <directory>")
40+
sys.exit(1)
41+
42+
directory = sys.argv[1]
43+
sys.exit(check_wheel_size(directory))

Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,17 @@ RUN --mount=type=cache,target=/root/.cache/ccache \
108108
python3 setup.py bdist_wheel --dist-dir=dist --py-limited-api=cp38; \
109109
fi
110110

111-
# check the size of the wheel, we cannot upload wheels larger than 100MB
111+
# Check the size of the wheel if RUN_WHEEL_CHECK is true
112112
COPY .buildkite/check-wheel-size.py check-wheel-size.py
113-
RUN python3 check-wheel-size.py dist
114-
113+
# Default max size of the wheel is 250MB
114+
ARG VLLM_MAX_SIZE_MB=250
115+
ENV VLLM_MAX_SIZE_MB=$VLLM_MAX_SIZE_MB
116+
ARG RUN_WHEEL_CHECK=true
117+
RUN if [ "$RUN_WHEEL_CHECK" = "true" ]; then \
118+
python3 check-wheel-size.py dist; \
119+
else \
120+
echo "Skipping wheel size check."; \
121+
fi
115122
#################### EXTENSION Build IMAGE ####################
116123

117124
#################### DEV IMAGE ####################

0 commit comments

Comments
 (0)