-
Notifications
You must be signed in to change notification settings - Fork 2
203 lines (171 loc) · 7.67 KB
/
test_lemonade_eval.yml
File metadata and controls
203 lines (171 loc) · 7.67 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
191
192
193
194
195
196
197
198
199
200
201
202
203
# This workflow tests lemonade-eval CLI tools with lemonade-server
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Test Lemonade Eval
on:
push:
branches: ["main"]
paths:
- '.github/workflows/test_lemonade_eval.yml'
- 'setup.py'
- 'src/lemonade/**'
pull_request:
paths:
- '.github/workflows/test_lemonade_eval.yml'
- 'setup.py'
- 'src/lemonade/**'
merge_group:
permissions:
contents: read
jobs:
test-lemonade-eval:
env:
LEMONADE_CI_MODE: "True"
LEMONADE_SERVER_URL: "http://localhost:8000"
runs-on: windows-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Create virtual environment and install dependencies
shell: bash
run: |
python -m venv .venv
venvPython=".venv/Scripts/python"
venvPip=".venv/Scripts/pip"
$venvPython -m pip install --upgrade pip
$venvPip install pylint
$venvPython -m pip check
$venvPip install -e .[oga-cpu]
- name: Lint with Black
uses: psf/black@stable
with:
options: "--check --verbose"
src: "./src/lemonade"
- name: Lint with PyLint
shell: bash
run: |
venvPylint=".venv/Scripts/pylint"
$venvPylint src/lemonade --rcfile .pylintrc --disable E0401
- name: Download latest Lemonade Server MSI
shell: PowerShell
run: |
Write-Host "Downloading latest lemonade-server-minimal.msi from releases..." -ForegroundColor Cyan
# Use GitHub CLI to download the latest release asset
gh release download --repo lemonade-sdk/lemonade --pattern "lemonade-server-minimal.msi" --output lemonade-server-minimal.msi
if (-not (Test-Path "lemonade-server-minimal.msi")) {
Write-Host "ERROR: Failed to download lemonade-server-minimal.msi" -ForegroundColor Red
exit 1
}
Write-Host "Downloaded lemonade-server-minimal.msi successfully" -ForegroundColor Green
Get-ChildItem lemonade-server-minimal.msi
env:
GH_TOKEN: ${{ github.token }}
- name: Install Lemonade Server
shell: PowerShell
run: |
$installPath = "${{ github.workspace }}\lemonade-server"
$logPath = "${{ github.workspace }}\lemonade-msi-install.log"
Write-Host "Installing Lemonade Server to: $installPath" -ForegroundColor Cyan
# Run installer silently with verbose logging
$args = "/i lemonade-server-minimal.msi /qn INSTALLDIR=`"$installPath`" /L*V `"$logPath`""
$p = Start-Process -FilePath "msiexec.exe" -ArgumentList $args -Wait -PassThru
if ($p.ExitCode -ne 0) {
Write-Host "ERROR: Installation failed with exit code $($p.ExitCode)" -ForegroundColor Red
if (Test-Path $logPath) {
Get-Content $logPath | Select-Object -Last 100
}
exit $p.ExitCode
}
# Add to PATH for subsequent steps
echo "$installPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Write-Host "Installation complete. Verifying..." -ForegroundColor Green
& "$installPath\bin\lemonade-server.exe" --version
- name: Test OGA-Load (CPU ONNX model)
shell: bash
run: |
venvPython=".venv/Scripts/python"
venvLemonade=".venv/Scripts/lemonade-eval"
echo "Testing OGA-Load with CPU ONNX model..."
$venvLemonade -i amd/Qwen2.5-0.5B-Instruct-quantized_int4-float16-cpu-onnx oga-load --device cpu --dtype int4 llm-prompt -p "tell me a story" --max-new-tokens 5
echo "Running OGA CPU API tests..."
$venvPython test/oga_cpu_api.py
- name: Test Server Integration (GGUF model)
shell: PowerShell
run: |
$installPath = "${{ github.workspace }}\lemonade-server"
$serverExe = "$installPath\bin\lemonade-server.exe"
$logFile = "${{ github.workspace }}\lemonade-server.log"
$venvPython = ".venv\Scripts\python.exe"
$venvLemonade = ".venv\Scripts\lemonade-eval"
Write-Host "Starting Lemonade Server..." -ForegroundColor Cyan
# Start server in background
$serverProcess = Start-Process -FilePath $serverExe -ArgumentList "serve" -RedirectStandardOutput $logFile -RedirectStandardError "$logFile.err" -PassThru
# Wait for server to be ready
$maxAttempts = 30
$attempt = 0
$serverReady = $false
while ($attempt -lt $maxAttempts -and -not $serverReady) {
Start-Sleep -Seconds 2
$attempt++
Write-Host "Checking server health (attempt $attempt/$maxAttempts)..."
try {
$response = Invoke-WebRequest -Uri "http://localhost:8000/api/v1/health" -UseBasicParsing -TimeoutSec 5
if ($response.StatusCode -eq 200) {
$serverReady = $true
Write-Host "Server is ready!" -ForegroundColor Green
}
} catch {
Write-Host "Server not ready yet..."
}
}
if (-not $serverReady) {
Write-Host "ERROR: Server failed to start within timeout" -ForegroundColor Red
if (Test-Path $logFile) {
Write-Host "=== Server Log ===" -ForegroundColor Yellow
Get-Content $logFile
}
if (Test-Path "$logFile.err") {
Write-Host "=== Server Error Log ===" -ForegroundColor Yellow
Get-Content "$logFile.err"
}
exit 1
}
# Test CLI
Write-Host "Testing lemonade-eval CLI..."
& $venvLemonade -m -i Llama-3.2-1B-Instruct-GGUF load bench -w 0 -i 5
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
try {
Write-Host "Running server integration tests with Qwen3-4B-Instruct-2507-GGUF..." -ForegroundColor Cyan
& $venvPython test/llm_api.py
if ($LASTEXITCODE -ne 0) {
throw "Tests failed with exit code $LASTEXITCODE"
}
} finally {
Write-Host "Stopping server..." -ForegroundColor Cyan
Stop-Process -Id $serverProcess.Id -Force -ErrorAction SilentlyContinue
# Show logs if tests failed
if ($LASTEXITCODE -ne 0) {
if (Test-Path $logFile) {
Write-Host "=== Server Log ===" -ForegroundColor Yellow
Get-Content $logFile | Select-Object -Last 50
}
if (Test-Path "$logFile.err") {
Write-Host "=== Server Error Log ===" -ForegroundColor Yellow
Get-Content "$logFile.err" | Select-Object -Last 50
}
}
}
- name: Stop Lemonade Server
if: always()
shell: PowerShell
run: |
Write-Host "Stopping Lemonade Server..." -ForegroundColor Cyan
Get-Process -Name "lemonade-server", "lemonade-router", "llama-server" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Write-Host "Server stopped." -ForegroundColor Green
# This file was originally licensed under Apache 2.0. It has been modified.
# Modifications Copyright (c) 2025 AMD