-
Notifications
You must be signed in to change notification settings - Fork 1.1k
127 lines (112 loc) · 4.33 KB
/
Copy pathpython-test.yml
File metadata and controls
127 lines (112 loc) · 4.33 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
name: Tests
on: [push, pull_request]
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run unit tests
env:
OPENAI_API_KEY: test # Mock API key for unit tests
run: |
# Run unit tests (all tests except integration/)
python -m unittest discover -s tests -p "test_*.py" -v
integration-tests:
needs: unit-tests # Only run if unit tests pass
runs-on: ubuntu-latest
timeout-minutes: 90 # Full integration suite (incl. real-LLM tests) can be slow
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
# math-verify is imported by optillm's cepo module but is NOT declared as a
# dependency of the optillm PyPI package, so `pip install optillm` alone
# leaves it missing and the server fails to start.
pip install optillm math-verify
- name: Cache HuggingFace models
uses: actions/cache@v3
with:
path: ~/.cache/huggingface
key: ${{ runner.os }}-hf-codelion-dhara-250m
restore-keys: |
${{ runner.os }}-hf-
- name: Start optillm server
run: |
echo "Starting optillm server for integration tests..."
optillm --model codelion/dhara-250m --port 8000 > optillm_server.log 2>&1 &
echo $! > server.pid
# Poll until healthy. On a cold HuggingFace cache the model download can
# take a few minutes; fail fast if the server process dies (e.g. a missing
# dependency) instead of proceeding to tests with no server.
echo "Waiting for optillm server health..."
for i in $(seq 1 60); do
if curl -sf http://localhost:8000/health >/dev/null 2>&1; then
echo "optillm server healthy after ~$((i*10))s"
break
fi
if ! kill -0 "$(cat server.pid)" 2>/dev/null; then
echo "::error::optillm server process exited before becoming healthy"
cat optillm_server.log
exit 1
fi
sleep 10
done
if ! curl -sf http://localhost:8000/health >/dev/null 2>&1; then
echo "::error::optillm server did not become healthy in time"
tail -100 optillm_server.log
exit 1
fi
env:
OPTILLM_API_KEY: optillm
# Bound generation: dhara-250m does not reliably emit an EOS token and would
# otherwise ramble up to the default 4096 tokens per call (minutes each).
OPTILLM_MAX_TOKENS: "256"
HF_TOKEN: ${{ secrets.HF_TOKEN }}
- name: Run integration tests (full suite, including real-LLM tests)
env:
OPENAI_API_KEY: optillm
OPTILLM_API_KEY: optillm
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
# Run the ENTIRE integration suite against the local dhara model server.
# Slow real-LLM tests are intentionally NOT skipped so contributor PRs are
# exercised end-to-end (evolution loop, checkpoints, migration, library API).
pytest tests/integration -v --tb=short
- name: Stop optillm server
if: always()
run: |
if [ -f server.pid ]; then
kill $(cat server.pid) || true
rm server.pid
fi
pkill -f "optillm.*8000" || true