Skip to content

Commit 3d0d1fa

Browse files
YikunPotabk
andcommitted
[Doctest] add installation doctest
Co-authored-by: wangli <wangli858794774@gmail.com> Signed-off-by: Yikun Jiang <yikunkero@gmail.com>
1 parent 3393d53 commit 3d0d1fa

File tree

7 files changed

+88
-12
lines changed

7 files changed

+88
-12
lines changed

.github/workflows/vllm_ascend_doctest.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# Each version should be tested
4747
fail-fast: false
4848
matrix:
49-
vllm_verison: [main, v0.7.3-dev, main-openeuler, v0.7.3-dev-openeuler]
49+
vllm_verison: [0.9.1-dev, 0.9.1-dev-openeuler, main, main-openeuler]
5050
name: vLLM Ascend test
5151
runs-on: linux-arm64-npu-1
5252
container:
@@ -70,13 +70,13 @@ jobs:
7070
run: |
7171
sed -i 's|ports.ubuntu.com|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
7272
apt-get update -y
73-
apt install git curl -y
73+
apt install -y gcc g++ libnuma-dev git curl jq
7474
7575
- name: Config OS mirrors - openEuler
7676
if: ${{ endsWith(matrix.vllm_verison, '-openeuler') }}
7777
run: |
7878
yum update -y
79-
yum install git curl -y
79+
yum install -y gcc g++ numactl-devel git curl jq
8080
8181
- name: Config pip mirrors
8282
run: |
@@ -88,11 +88,12 @@ jobs:
8888
- name: Run vllm-ascend/tests/e2e/run_doctests.sh
8989
run: |
9090
# PWD: /__w/vllm-ascend/vllm-ascend
91-
# Address old branch like v0.7.3:
92-
if [ ! -d /vllm-workspace/vllm-ascend/tests/e2e ]; then
93-
echo "Warning: the doctest path doesn't exists, copy now"
94-
cp -r tests/e2e /vllm-workspace/vllm-ascend/tests/
95-
fi
91+
echo "Replacing /vllm-workspace/vllm-ascend/tests/e2e ..."
92+
rm -rf /vllm-workspace/vllm-ascend/tests/e2e
93+
mkdir -p /vllm-workspace/vllm-ascend/tests
94+
cp -r tests/e2e /vllm-workspace/vllm-ascend/tests/
95+
# Remove this after conf.py merged
96+
cp docs/source/conf.py /vllm-workspace/vllm-ascend/docs/source/
9697
9798
# Simulate container to enter directory
9899
cd /workspace

docs/source/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# add these directories to sys.path here. If the directory is relative to the
2424
# documentation root, use os.path.abspath to make it absolute, like shown here.
2525
#
26+
import json
2627
import os
2728

2829
# import sys
@@ -133,3 +134,7 @@
133134

134135
def setup(app):
135136
pass
137+
138+
139+
if __name__ == "__main__":
140+
print(json.dumps(myst_substitutions))

docs/source/installation.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ for output in outputs:
245245
Then run:
246246

247247
```bash
248-
# export VLLM_USE_MODELSCOPE=true to speed up download if huggingface is not reachable.
248+
# Try `export VLLM_USE_MODELSCOPE=true` and `pip install modelscope`
249+
# to speed up download if huggingface is not reachable.
249250
python example.py
250251
```
251252

tests/e2e/common.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,30 @@ function wait_for_exit() {
4545
_info "===> Wait for ${VLLM_PID} to exit."
4646
sleep 1
4747
done
48-
_info "===> Wait for ${VLLM_PID} to exit."
48+
_info "===> Process ${VLLM_PID} has exited."
49+
}
50+
51+
VENV_PATH=/tmp/vllm_venv
52+
53+
function clean_venv() {
54+
if [[ -n "$VENV_PATH" && -d "$VENV_PATH" ]]; then
55+
_info "Cleaning up default virtual env path: ${VENV_PATH}"
56+
deactivate || true
57+
rm -rf "$VENV_PATH"
58+
fi
59+
}
60+
61+
function create_vllm_venv() {
62+
# make a clean env path
63+
clean_venv
64+
_info "Creating vllm virtual environment at ${VENV_PATH}"
65+
python3 -m venv ${VENV_PATH}
66+
source ${VENV_PATH}/bin/activate
67+
}
68+
69+
function get_version() {
70+
local VERSION_NAME="$1"
71+
python3 "${SCRIPT_DIR}/../../docs/source/conf.py" | jq .${VERSION_NAME} | tr -d '"'
4972
}
5073

5174
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)

tests/e2e/doctests/001-quickstart-test.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ function simple_test() {
2323
}
2424

2525
function quickstart_offline_test() {
26-
export VLLM_USE_MODELSCOPE=true
2726
# Do real script test
2827
python3 "${SCRIPT_DIR}/../../examples/offline_inference_npu.py"
2928
}
3029

3130
function quickstart_online_test() {
32-
export VLLM_USE_MODELSCOPE=true
3331
vllm serve Qwen/Qwen2.5-0.5B-Instruct &
3432
wait_url_ready "vllm serve" "localhost:8000/v1/models"
3533
# Do real curl test
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
# This file is a part of the vllm-ascend project.
18+
#
19+
trap clean_venv EXIT
20+
21+
function install_binary_test() {
22+
23+
create_vllm_venv
24+
25+
PIP_VLLM_VERSION=$(get_version pip_vllm_version)
26+
PIP_VLLM_ASCEND_VERSION=$(get_version pip_vllm_ascend_version)
27+
_info "====> Install vllm==${PIP_VLLM_VERSION} and vllm-ascend ${PIP_VLLM_ASCEND_VERSION}"
28+
29+
pip install vllm=="$(get_version pip_vllm_version)"
30+
pip install vllm-ascend=="$(get_version pip_vllm_ascend_version)"
31+
32+
pip list | grep vllm
33+
34+
# Verify the installation
35+
_info "====> Run offline example test"
36+
pip install modelscope
37+
python3 "${SCRIPT_DIR}/../../examples/offline_inference_npu.py"
38+
39+
}
40+
41+
_info "====> Start install_binary_test"
42+
install_binary_test

tests/e2e/run_doctests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ set -eo errexit
2121

2222
. $(dirname "$0")/common.sh
2323

24+
export VLLM_USE_MODELSCOPE=true
25+
export VLLM_LOGGING_LEVEL=ERROR
26+
2427
_info "====> Start Quickstart test"
2528
. "${SCRIPT_DIR}/doctests/001-quickstart-test.sh"
2629

30+
_info "====> Start pip binary installation test"
31+
. "${SCRIPT_DIR}/doctests/002-pip-binary-installation-test.sh"
32+
2733
_info "Doctest passed."

0 commit comments

Comments
 (0)