@@ -89,146 +89,6 @@ YAPF_EXCLUDES=(
89
89
' --exclude' ' build/**'
90
90
)
91
91
92
- # Format specified files
93
- format () {
94
- yapf --in-place " ${YAPF_FLAGS[@]} " " $@ "
95
- }
96
-
97
- # Format files that differ from main branch. Ignores dirs that are not slated
98
- # for autoformat yet.
99
- format_changed () {
100
- # The `if` guard ensures that the list of filenames is not empty, which
101
- # could cause yapf to receive 0 positional arguments, making it hang
102
- # waiting for STDIN.
103
- #
104
- # `diff-filter=ACM` and $MERGEBASE is to ensure we only format files that
105
- # exist on both branches.
106
- MERGEBASE=" $( git merge-base origin/main HEAD) "
107
-
108
- if ! git diff --diff-filter=ACM --quiet --exit-code " $MERGEBASE " -- ' *.py' ' *.pyi' & > /dev/null; then
109
- git diff --name-only --diff-filter=ACM " $MERGEBASE " -- ' *.py' ' *.pyi' | xargs -P 5 \
110
- yapf --in-place " ${YAPF_EXCLUDES[@]} " " ${YAPF_FLAGS[@]} "
111
- fi
112
- }
113
-
114
- # Format all files
115
- format_all () {
116
- yapf --in-place " ${YAPF_FLAGS[@]} " " ${YAPF_EXCLUDES[@]} " .
117
- }
118
-
119
- echo ' vllm-ascend yapf:'
120
- # # This flag formats individual files. --files *must* be the first command line
121
- # # arg to use this option.
122
- if [[ " $1 " == ' --files' ]]; then
123
- format " ${@: 2} "
124
- # If `--all` is passed, then any further arguments are ignored and the
125
- # entire python directory is formatted.
126
- elif [[ " $1 " == ' --all' ]]; then
127
- format_all
128
- else
129
- # Format only the files that changed in last commit.
130
- format_changed
131
- fi
132
- echo ' vllm-ascend yapf: Done'
133
-
134
- # Run mypy
135
- echo ' vllm-ascend mypy:'
136
- tools/mypy.sh
137
- echo ' vllm-ascend mypy: Done'
138
-
139
-
140
- # If git diff returns a file that is in the skip list, the file may be checked anyway:
141
- # https://github.com/codespell-project/codespell/issues/1915
142
- # Avoiding the "./" prefix and using "/**" globs for directories appears to solve the problem
143
- CODESPELL_EXCLUDES=(
144
- ' --skip' ' tests/prompts/**,./benchmarks/sonnet.txt,*tests/lora/data/**,build/**,./vllm_ascend.egg-info/**'
145
- )
146
-
147
- CODESPELL_IGNORE_WORDS=(
148
- ' -L' ' CANN,cann,NNAL,nnal,ASCEND,ascend,EnQue,CopyIn,assertIn,rever'
149
- )
150
-
151
- # check spelling of specified files
152
- spell_check () {
153
- codespell " $@ " " ${CODESPELL_IGNORE_WORDS[@]} "
154
- }
155
-
156
- spell_check_all () {
157
- codespell --toml pyproject.toml " ${CODESPELL_EXCLUDES[@]} " " ${CODESPELL_IGNORE_WORDS[@]} "
158
- }
159
-
160
- # Spelling check of files that differ from main branch.
161
- spell_check_changed () {
162
- # The `if` guard ensures that the list of filenames is not empty, which
163
- # could cause ruff to receive 0 positional arguments, making it hang
164
- # waiting for STDIN.
165
- #
166
- # `diff-filter=ACM` and $MERGEBASE is to ensure we only lint files that
167
- # exist on both branches.
168
- MERGEBASE=" $( git merge-base origin/main HEAD) "
169
- if ! git diff --diff-filter=ACM --quiet --exit-code " $MERGEBASE " -- ' *.py' ' *.pyi' & > /dev/null; then
170
- git diff --name-only --diff-filter=ACM " $MERGEBASE " -- ' *.py' ' *.pyi' | xargs \
171
- codespell " ${CODESPELL_EXCLUDES[@]} " " ${CODESPELL_IGNORE_WORDS[@]} "
172
- codespell " ${CODESPELL_EXCLUDES[@]} " " ${CODESPELL_IGNORE_WORDS[@]} "
173
- fi
174
- }
175
-
176
- echo ' vllm-ascend codespell:'
177
- # Run Codespell
178
- # # This flag runs spell check of individual files. --files *must* be the first command line
179
- # # arg to use this option.
180
- if [[ " $1 " == ' --files' ]]; then
181
- spell_check " ${@: 2} "
182
- # If `--all` is passed, then any further arguments are ignored and the
183
- # entire python directory is linted.
184
- elif [[ " $1 " == ' --all' ]]; then
185
- spell_check_all
186
- else
187
- # Check spelling only of the files that changed in last commit.
188
- spell_check_changed
189
- fi
190
- echo ' vllm-ascend codespell: Done'
191
-
192
-
193
- # Lint specified files
194
- lint () {
195
- ruff check " $@ "
196
- }
197
-
198
- # Lint files that differ from main branch. Ignores dirs that are not slated
199
- # for autolint yet.
200
- lint_changed () {
201
- # The `if` guard ensures that the list of filenames is not empty, which
202
- # could cause ruff to receive 0 positional arguments, making it hang
203
- # waiting for STDIN.
204
- #
205
- # `diff-filter=ACM` and $MERGEBASE is to ensure we only lint files that
206
- # exist on both branches.
207
- MERGEBASE=" $( git merge-base origin/main HEAD) "
208
-
209
- if ! git diff --diff-filter=ACM --quiet --exit-code " $MERGEBASE " -- ' *.py' ' *.pyi' & > /dev/null; then
210
- git diff --name-only --diff-filter=ACM " $MERGEBASE " -- ' *.py' ' *.pyi' | xargs \
211
- ruff check
212
- fi
213
-
214
- }
215
-
216
- echo ' vllm-ascend ruff:'
217
- # Run Ruff
218
- # ## This flag lints individual files. --files *must* be the first command line
219
- # ## arg to use this option.
220
- if [[ " $1 " == ' --files' ]]; then
221
- lint " ${@: 2} "
222
- # If `--all` is passed, then any further arguments are ignored and the
223
- # entire python directory is linted.
224
- elif [[ " $1 " == ' --all' ]]; then
225
- lint vllm tests
226
- else
227
- # Format only the files that changed in last commit.
228
- lint_changed
229
- fi
230
- echo ' vllm-ascend ruff: Done'
231
-
232
92
# check spelling of specified files
233
93
isort_check () {
234
94
isort " $@ "
@@ -269,75 +129,3 @@ else
269
129
isort_check_changed
270
130
fi
271
131
echo ' vllm-ascend isort: Done'
272
-
273
- # Clang-format section
274
- # Exclude some files for formatting because they are vendored
275
- CLANG_FORMAT_EXCLUDES=(
276
- ' csrc/kernels/utils.h' ' csrc/kernels/pos_encoding_kernels.cpp' ' csrc/kernels/advance_step.cpp' ' csrc/kernels/get_masked_input_and_mask_kernel.cpp' ' csrc/torch_binding.cpp' ' csrc/ops.h'
277
- )
278
-
279
- # Format specified files with clang-format
280
- clang_format () {
281
- clang-format -i " $@ "
282
- }
283
-
284
- # Format files that differ from main branch with clang-format.
285
- clang_format_changed () {
286
- # The `if` guard ensures that the list of filenames is not empty, which
287
- # could cause clang-format to receive 0 positional arguments, making it hang
288
- # waiting for STDIN.
289
- #
290
- # `diff-filter=ACM` and $MERGEBASE is to ensure we only format files that
291
- # exist on both branches.
292
- MERGEBASE=" $( git merge-base origin/main HEAD) "
293
-
294
- # Get the list of changed files, excluding the specified ones
295
- changed_files=$( git diff --name-only --diff-filter=ACM " $MERGEBASE " -- ' *.h' ' *.cpp' ' *.cu' ' *.cuh' | (grep -vFf <( printf " %s\n" " ${CLANG_FORMAT_EXCLUDES[@]} " ) || echo -e))
296
- if [ -n " $changed_files " ]; then
297
- echo " $changed_files " | xargs -P 5 clang-format -i
298
- fi
299
- }
300
-
301
- # Format all files with clang-format
302
- clang_format_all () {
303
- find csrc/ \( -name ' *.h' -o -name ' *.cpp' -o -name ' *.cu' -o -name ' *.cuh' \) -print \
304
- | grep -vFf <( printf " %s\n" " ${CLANG_FORMAT_EXCLUDES[@]} " ) \
305
- | xargs clang-format -i
306
- }
307
-
308
- # Run clang-format
309
- if [[ " $1 " == ' --files' ]]; then
310
- clang_format " ${@: 2} "
311
- elif [[ " $1 " == ' --all' ]]; then
312
- clang_format_all
313
- else
314
- clang_format_changed
315
- fi
316
- echo ' vllm-ascend clang-format: Done'
317
-
318
- echo ' vllm-ascend actionlint:'
319
- tools/actionlint.sh -color
320
- echo ' vllm-ascend actionlint: Done'
321
-
322
- echo ' vllm-ascend shellcheck:'
323
- tools/shellcheck.sh
324
- echo ' vllm-ascend shellcheck: Done'
325
-
326
- echo ' excalidraw png check:'
327
- tools/png-lint.sh
328
- echo ' excalidraw png check: Done'
329
-
330
- if ! git diff --quiet & > /dev/null; then
331
- echo
332
- echo " 🔍🔍There are files changed by the format checker or by you that are not added and committed:"
333
- git --no-pager diff --name-only
334
- echo " 🔍🔍Format checker passed, but please add, commit and push all the files above to include changes made by the format checker."
335
-
336
- exit 1
337
- else
338
- echo " ✨🎉 Format check passed! Congratulations! 🎉✨"
339
- fi
340
-
341
- # echo 'vLLM sphinx-lint:'
342
- # tools/sphinx-lint.sh
343
- # echo 'vLLM sphinx-lint: Done'
0 commit comments