forked from LMCache/LMCache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
133 lines (133 loc) · 4.17 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
133 lines (133 loc) · 4.17 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
exclude: 'lmcache/integration/vllm/lmcache_mp_connector_.*\.py'
repos:
- repo: local
hooks:
- id: check-spdx-header
name: Check SPDX headers
entry: python tools/check_spdx_header.py
language: python
types: [python]
- id: ban-direct-torch-device
name: Ban direct torch device usage
entry: >-
bash -c '
pattern=$(find lmcache/v1/platform -mindepth 1 -maxdepth 1 -type d \
-exec basename {} \; | grep -v "^__" | grep -v "^base$" | sort | paste -sd "|");
if [ -z "$pattern" ]; then
echo "WARNING: no platform dirs found, skipping check";
exit 0;
fi;
echo "Detected platforms: ${pattern//|/, }";
echo "Ban pattern: torch.($pattern)";
matches=$(grep -rHnE "torch\.($pattern)" "$@");
if [ -n "$matches" ]; then
echo "";
echo "========================================";
echo " BANNED: Direct torch device API usage";
echo " Use lmcache.v1.platform abstractions instead";
echo "========================================";
echo "";
echo "$matches";
exit 1;
fi' --
language: system
types: [python]
files: ^lmcache/
exclude: |
(?x)^(
lmcache/.*/gpu_connector/.*|
lmcache/v1/platform/.*
)$
- id: ban-cuda-host-register
name: Ban cudaHostRegister/Unregister outside platform
entry: >-
bash -c '
matches=$(grep -rHnE "\.cudaHost(Register|Unregister)" "$@");
if [ -n "$matches" ]; then
echo "";
echo "=======================================================================";
echo " BANNED: .cudaHostRegister/Unregister usage found outside platform dir";
echo " Fix 1: They are only allowed in the platform directory";
echo " Fix 2: use current_device_spec.pin_memory/unpin_memory instead";
echo "=======================================================================";
echo "";
echo "$matches";
exit 1;
fi' --
language: system
types: [python]
files: ^lmcache/
exclude: |
(?x)^(
lmcache/.*/gpu_connector/.*|
lmcache/v1/platform/.*
)$
- id: ban-raw-timeout-error
name: Ban raw raise of builtin TimeoutError
entry: >-
bash -c '
matches=$(grep -rHnE "raise[[:space:]]+(asyncio\.)?TimeoutError\b" "$@");
if [ -n "$matches" ]; then
echo "";
echo "========================================";
echo " BANNED: raw raise of builtin TimeoutError";
echo " Fix: raise LMCacheTimeoutError from";
echo " lmcache.v1.mp_observability.errors so the timeout";
echo " is reported to MP observability (OTel).";
echo "========================================";
echo "";
echo "$matches";
exit 1;
fi' --
language: system
types: [python]
files: ^lmcache/
- repo: https://github.com/PyCQA/isort
rev: 6.0.1
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.7
hooks:
- id: ruff
args: [--output-format, github, --fix]
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies: ['tomli']
args: ['--toml', 'pyproject.toml']
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.3
hooks:
- id: clang-format
types_or: [c++, cuda]
args: [--style=file, --verbose]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.17.1'
hooks:
- id: mypy
language_version: python3.12
args: [--config-file=pyproject.toml]
#args: [--ignore-missing-imports]
additional_dependencies:
- tokenize-rt==6.1.0 # For better dynamic analysis performance
- msgspec[mypy]
- types-requests
- types-PyYAML
- types-aiofiles
- repo: local
hooks:
- id: rust-fmt
name: Rust Format Check
entry: bash -c 'cd rust/raw_block && cargo fmt --check'
language: system
types: [text]
files: ^rust/raw_block/.*\.rs$
- id: rust-clippy
name: Rust Clippy Check
entry: bash -c 'cd rust/raw_block && cargo clippy -- -D warnings'
language: system
types: [text]
files: ^rust/raw_block/.*\.rs$