A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 17, 06:45 UTC
[Small] Formatter only checks lints in changed files (#1528)
Cade Daniel committed
Oct 31, 2023 at 15:39 UTC
e575df33b1963212f79b2efddd45d53225fa5c45
2 files changed
+35
-1
format.sh
+35
-1
@@ -93,9 +93,43 @@ echo 'vLLM yapf: Done'
93
# echo 'vLLM mypy:'
94
# mypy
95
96
+# Lint specified files
97
+lint() {
98
+ pylint "$@"
99
+}
100
+
101
+# Lint files that differ from main branch. Ignores dirs that are not slated
102
+# for autolint yet.
103
+lint_changed() {
104
+ # The `if` guard ensures that the list of filenames is not empty, which
105
+ # could cause pylint to receive 0 positional arguments, making it hang
106
+ # waiting for STDIN.
107
+ #
108
+ # `diff-filter=ACM` and $MERGEBASE is to ensure we only lint files that
109
+ # exist on both branches.
110
+ MERGEBASE="$(git merge-base origin/main HEAD)"
111
+
112
+ if ! git diff --diff-filter=ACM --quiet --exit-code "$MERGEBASE" -- '*.py' '*.pyi' &>/dev/null; then
113
+ git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.py' '*.pyi' | xargs \
114
+ pylint
115
+ fi
116
+
117
+}
118
+
119
# Run Pylint
120
echo 'vLLM Pylint:'
98
-pylint vllm tests
121
+## This flag lints individual files. --files *must* be the first command line
122
+## arg to use this option.
123
+if [[ "$1" == '--files' ]]; then
124
+ lint "${@:2}"
125
+ # If `--all` is passed, then any further arguments are ignored and the
126
+ # entire python directory is linted.
127
+elif [[ "$1" == '--all' ]]; then
128
+ lint vllm tests
129
+else
130
+ # Format only the files that changed in last commit.
131
+ lint_changed
132
+fi
133
134
if ! git diff --quiet &>/dev/null; then
135
echo 'Reformatted files. Please review and stage the changes.'