Commit 405669d
authored
[BugFix][Doc] Avoid polib dependency during CPU UT collection (vllm-project#12352)
### What this PR does / why we need it?
#### Root cause and provenance
The CPU unit-test lane in [run
29653393420](https://github.com/vllm-project/vllm-ascend/actions/runs/29653393420)
fails while collecting `tests/ut/_tools/test_generate_zh_docs.py`:
```text
tests/ut/_tools/test_generate_zh_docs.py:1: in <module>
from tools.generate_zh_docs import apply_translations
tools/generate_zh_docs.py:16: in <module>
from polib import pofile
E ModuleNotFoundError: No module named 'polib'
```
- [PR vllm-project#11252](vllm-project#11252),
merged as `fbbf5167ada3f3b59909bcf947e69036fc4af425`, introduced the
Chinese-doc generator, its top-level `polib` import, and `polib` in
`docs/requirements-docs.txt`.
- [PR vllm-project#12331](vllm-project#12331),
merged as `ff83573c37c0bc84e33111e0558086f2c4d73aea`, added
`test_generate_zh_docs.py`. That test imports only the pure
`apply_translations` helper.
- The selected-test CPU environment installs `requirements-dev.txt`, not
`docs/requirements-docs.txt`, so it correctly does not contain the
docs-only `polib` package. Both the [main CPU
job](https://github.com/vllm-project/vllm-ascend/actions/runs/29653393420/job/88103795623)
and [v0.24.0 CPU
job](https://github.com/vllm-project/vllm-ascend/actions/runs/29653393420/job/88103795682)
fail at the same collection point.
#### Minimal fix
Move `from polib import pofile` into `parse_po_file()`, the only path
that actually reads PO files.
This keeps `polib` in the existing documentation dependency group,
avoids adding a docs-only package to core/runtime or general test
dependencies, and allows pure Markdown translation helpers to be
imported and tested without the optional docs stack. Calling the real PO
parsing path still imports and requires `polib` as intended.
This is an existing `main` issue and is independent of PR vllm-project#12218 and its
main2main changes.
### Does this PR introduce _any_ user-facing change?
No. It only narrows when an existing documentation dependency is
imported.
### How was this patch tested?
From current `upstream/main` `e1bd15041af9d9e1a274ae381da0bc0dd8b50e4d`:
- Reproduced the collection failure in an isolated environment with
`regex` and `pytest`, but no `polib`.
- Verified ordinary `tools.generate_zh_docs` import succeeds when
`polib` is absent.
- `pytest -q --confcutdir=tests/ut/_tools
tests/ut/_tools/test_generate_zh_docs.py` without `polib`: `4 passed`.
- `pytest --collect-only -q --confcutdir=tests/ut/_tools
tests/ut/_tools/test_generate_zh_docs.py` without `polib`: `4 tests
collected`.
- Parsed a temporary PO file through `parse_po_file()` with `polib`
installed and verified the expected `{"Hello": "你好"}` mapping.
- `ruff check tools/generate_zh_docs.py
tests/ut/_tools/test_generate_zh_docs.py`.
- `ruff format --check tools/generate_zh_docs.py
tests/ut/_tools/test_generate_zh_docs.py`.
- `git diff --check`.
- vLLM version: v0.24.0
- vLLM main:
vllm-project/vllm@85c09e9
Signed-off-by: zhao-stack <2020265299@qq.com>1 parent 753d7ba commit 405669d
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
0 commit comments