{{ message }}
Repository navigation
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
190 lines (189 loc) · 8.85 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
190 lines (189 loc) · 8.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
default_stages: [pre-commit, pre-push, manual]
exclude: ^(python/sglang/multimodal_gen/csrc|python/sglang/kernels/ops/diffusion/render|python/sglang/kernels/ops/attention/flash_attn/cute|python/sglang/kernels/jit/csrc/diffusion/vsa_block_sparse_sm100)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-symlinks
- id: destroyed-symlinks
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: [--allow-multiple-documents]
- id: check-toml
- id: check-ast
- id: check-added-large-files
args: ['--maxkb=1500']
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: detect-private-key
exclude: ^sgl-model-gateway/tests/.*_test\.rs$
- id: debug-statements
- id: no-commit-to-branch
- repo: https://github.com/PyCQA/isort
rev: 7.0.0
hooks:
- id: isort
exclude: '^python/sglang/srt/grpc/.*_pb2\.py$|^python/sglang/srt/grpc/.*_pb2_grpc\.py$|^python/sglang/srt/grpc/.*_pb2\.pyi$|^python/sglang/srt/grpc/.*_pb2_grpc\.pyi$|^python/sglang/(api|json)/v1/.*\.py$'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.1
hooks:
- id: ruff
args:
- --select=F401,F821,F823,UP037
- --fix
files: ^(benchmark/|docs/|examples/|python/sglang/|sgl-model-gateway/py_*|test/)
exclude: |
(?x)^(
.*/__init__\.py$|
.*\.ipynb$|
python/sglang/kernels/aot/.*|
python/sglang/srt/grpc/.*_pb2\.py$|
python/sglang/srt/grpc/.*_pb2_grpc\.py$|
python/sglang/srt/grpc/.*_pb2\.pyi$|
python/sglang/srt/grpc/.*_pb2_grpc\.pyi$|
python/sglang/(api|json)/v1/.*\.py$|
)$
- id: ruff-format
exclude: '^python/sglang/srt/grpc/.*_pb2\.py$|^python/sglang/srt/grpc/.*_pb2_grpc\.py$|^python/sglang/srt/grpc/.*_pb2\.pyi$|^python/sglang/srt/grpc/.*_pb2_grpc\.pyi$|^python/sglang/(api|json)/v1/.*\.py$'
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
args: ['--config', '.codespellrc']
# Vendored ROCm/aiter#5882 kernel, kept byte-for-byte (`padd` is a helper name).
# TODO(aiter#5882): remove once ROCm/aiter#5882 is in the aiter pin
exclude: ^python/sglang/kernels/ops/attention/dsv4/flydsl_v4nm/
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.7
hooks:
- id: clang-format
types_or: [c++, cuda]
args: [--style=file, --verbose]
- repo: https://github.com/kynan/nbstripout
rev: 0.9.0
hooks:
- id: nbstripout
args:
- '--keep-output'
- '--extra-keys=metadata.kernelspec metadata.language_info.version'
- repo: local
hooks:
- id: forbid-test-srt-path
name: forbid test/srt/ (use test/registered/ or test/manual/)
entry: >-
test/srt/ is retired. Move these tests under test/registered/ or test/manual/ instead.
language: fail
files: ^test/srt/
- id: forbid-docs-new-path
name: forbid docs_new/ (renamed to docs/)
# docs_new/ was renamed to docs/ in #32123. `language: fail` fires only
# when a staged path matches `files:` below, then prints the offending
# paths — no shell/merge-base logic, so none of the shallow-checkout or
# silent-diff pitfalls of the old legacy-docs/ gate apply here.
entry: >-
docs_new/ was renamed to docs/. Move these changes under docs/ instead.
language: fail
files: ^docs_new/
- id: check-chinese-characters
name: check chinese characters in multimodal_gen
entry: >-
python3 -c 'import sys, re; p=re.compile(r"[\u4e00-\u9fff]"); ec=0; [ ([(print(f"{f}:{i+1}: {l.strip()}") or (ec:=1)) for i,l in enumerate(open(f, "r", encoding="utf-8", errors="ignore")) if p.search(l)]) for f in sys.argv[1:] ]; sys.exit(ec)'
language: system
files: ^python/sglang/multimodal_gen/.*
exclude: ^(python/sglang/multimodal_gen/configs/sample|python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/workflows|python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages)(/|$)
types_or: [python, markdown, json, text]
- id: sort-ci-permissions
name: sort CI_PERMISSIONS.json
entry: python3 .github/update_ci_permission.py --sort-only
language: system
files: ^\.github/CI_PERMISSIONS\.json$
pass_filenames: false
- id: check-workflow-job-names
name: check for duplicate workflow job names
entry: python3 scripts/lint/check_workflow_job_names.py
language: system
files: ^\.github/workflows/.*\.yml$
pass_filenames: false
- id: check-opt-in-ci-tiers
name: check opt-in CI tiers match the workflows that gate on them
entry: python3 scripts/lint/check_opt_in_ci_tiers.py
language: system
files: ^(\.github/workflows/.*\.yml|scripts/ci/opt_in_ci_tiers\.json|scripts/lint/check_opt_in_ci_tiers\.py)$
pass_filenames: false
- id: check-rust-ext-cache-prefix
name: check rust-ext cache key prefix defaults match
entry: python3 scripts/lint/check_rust_ext_cache_prefix.py
language: system
files: ^(\.github/actions/download-rust-ext/action\.yml|\.github/workflows/_pr-test-rust-ext-build\.yml)$
pass_filenames: false
- id: check-dockerfile-wheel-pins
name: check Dockerfile sgl-deep-gemm/sgl-deep-ep versions match python/pyproject.toml
entry: python3 scripts/lint/check_dockerfile_wheel_pins.py
language: system
files: ^(python/pyproject\.toml|docker/.*Dockerfile.*|scripts/lint/check_dockerfile_wheel_pins\.py)$
pass_filenames: false
- id: check-no-bare-pytest-main
name: reject bare pytest.main calls in __main__ blocks
entry: python3 scripts/lint/check_no_bare_pytest_main.py
language: system
files: ^(python|test)/.*\.py$
- id: check-registered-tests
name: validate registered test CI registries
entry: python3 scripts/lint/check_registered_tests.py
language: system
files: ^test/registered/.*\.py$
pass_filenames: false
- id: check-no-registered-tests-in-package
name: reject CI-registered tests inside the sglang package
entry: python3 scripts/lint/check_no_registered_tests_in_package.py
language: system
files: ^python/sglang/.*\.py$
pass_filenames: false
- id: rustfmt-sgl-model-gateway
name: rustfmt sgl-model-gateway (nightly)
entry: bash -c 'rustup component add --toolchain nightly rustfmt >/dev/null && cd sgl-model-gateway && cargo +nightly fmt -- --check'
language: system
files: ^sgl-model-gateway/.*\.rs$
pass_filenames: false
- id: rustfmt-sgl-router
name: rustfmt sgl-router
entry: bash -c 'cd sgl-router && cargo fmt --all -- --check'
language: system
files: ^sgl-router/.*\.rs$
pass_filenames: false
- id: clippy-rust-workspace
name: clippy rust/ workspace (auto-fix)
# Three steps: apply machine-applicable fixes, then fail on anything
# left (combining --fix with -D warnings can abort the fix phase), then
# cover sglang-mm's PyO3 bindings + rayon fan-out — both sit behind
# non-default features, so `--workspace` alone never compiles them. protoc
# is not required: the shared protocol crate falls back to a vendored binary.
entry: bash -c 'cd rust && cargo clippy --workspace --fix --allow-dirty --allow-staged && cargo clippy --workspace -- -D warnings && cargo clippy -p sglang-mm --features python,parallel --lib -- -D warnings && cargo clippy --manifest-path sglang-radix-tree/Cargo.toml --all-targets --no-default-features --features tch/doc-only -- -D warnings'
language: system
files: ^(rust/.*\.(rs|toml)|proto/.*\.(rs|proto|toml))$
pass_filenames: false
- id: rustfmt-rust-workspace
name: rustfmt rust/ workspace
entry: bash -c 'cd rust && cargo fmt && cargo fmt --manifest-path sglang-radix-tree/Cargo.toml'
language: system
files: ^(rust/.*\.(rs|toml)|proto/.*\.(rs|proto|toml))$
pass_filenames: false
- id: mint-broken-links
name: check docs links (Mintlify; opt-in, requires `mint` on PATH)
entry: bash -c 'cd docs && mint broken-links --check-anchors --check-redirects'
language: system
pass_filenames: false
always_run: true
stages: [manual]
- repo: https://github.com/lycheeverse/lychee.git
rev: lychee-v0.22.0
hooks:
- id: lychee
name: check doc links (offline)
args: ["--config", ".github/linters/lychee.toml"]
stages: [manual]
files: |
(?x)^(
README\.md
)$
You can’t perform that action at this time.
