Skip to content

Commit 60bd927

Browse files
rkuo-danswerRichard Kuo (Danswer)
andauthored
Bugfix/model tests (#4092)
* trying out a fix * add ability to manually run model tests * add log dump * check status code, not text? * just the model server * add port mapping to host * pass through more api keys * add azure tests * fix litellm env vars * fix env vars in github workflow * temp disable litellm test --------- Co-authored-by: Richard Kuo (Danswer) <rkuo@onyx.app>
1 parent 5d58a5e commit 60bd927

File tree

3 files changed

+66
-5
lines changed

3 files changed

+66
-5
lines changed

.github/workflows/pr-python-model-tests.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ env:
1717
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
1818
AWS_REGION_NAME: ${{ secrets.AWS_REGION_NAME }}
1919

20-
# OpenAI
20+
# API keys for testing
21+
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
22+
LITELLM_API_KEY: ${{ secrets.LITELLM_API_KEY }}
23+
LITELLM_API_URL: ${{ secrets.LITELLM_API_URL }}
2124
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
25+
AZURE_API_KEY: ${{ secrets.AZURE_API_KEY }}
26+
AZURE_API_URL: ${{ secrets.AZURE_API_URL }}
2227

2328
jobs:
2429
model-check:
@@ -72,7 +77,7 @@ jobs:
7277
REQUIRE_EMAIL_VERIFICATION=false \
7378
DISABLE_TELEMETRY=true \
7479
IMAGE_TAG=test \
75-
docker compose -f docker-compose.dev.yml -p onyx-stack up -d indexing_model_server
80+
docker compose -f docker-compose.model-server-test.yml -p onyx-stack up -d indexing_model_server
7681
id: start_docker
7782

7883
- name: Wait for service to be ready
@@ -123,9 +128,22 @@ jobs:
123128
--data '{"text":"Scheduled Model Tests failed! Check the run at: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}' \
124129
$SLACK_WEBHOOK
125130
131+
- name: Dump all-container logs (optional)
132+
if: always()
133+
run: |
134+
cd deployment/docker_compose
135+
docker compose -f docker-compose.model-server-test.yml -p onyx-stack logs --no-color > $GITHUB_WORKSPACE/docker-compose.log || true
136+
137+
- name: Upload logs
138+
if: always()
139+
uses: actions/upload-artifact@v4
140+
with:
141+
name: docker-all-logs
142+
path: ${{ github.workspace }}/docker-compose.log
143+
126144
- name: Stop Docker containers
127145
if: always()
128146
run: |
129147
cd deployment/docker_compose
130-
docker compose -f docker-compose.dev.yml -p onyx-stack down -v
148+
docker compose -f docker-compose.model-server-test.yml -p onyx-stack down -v
131149

backend/tests/daily/embedding/test_embeddings.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@ def litellm_embedding_model() -> EmbeddingModel:
7171
normalize=True,
7272
query_prefix=None,
7373
passage_prefix=None,
74-
api_key=os.getenv("LITE_LLM_API_KEY"),
74+
api_key=os.getenv("LITELLM_API_KEY"),
7575
provider_type=EmbeddingProvider.LITELLM,
76-
api_url=os.getenv("LITE_LLM_API_URL"),
76+
api_url=os.getenv("LITELLM_API_URL"),
7777
)
7878

7979

80+
@pytest.mark.skip(reason="re-enable when we can get the correct litellm key and url")
8081
def test_litellm_embedding(litellm_embedding_model: EmbeddingModel) -> None:
8182
_run_embeddings(VALID_SAMPLE, litellm_embedding_model, 1536)
8283
_run_embeddings(TOO_LONG_SAMPLE, litellm_embedding_model, 1536)
@@ -117,6 +118,11 @@ def azure_embedding_model() -> EmbeddingModel:
117118
)
118119

119120

121+
def test_azure_embedding(azure_embedding_model: EmbeddingModel) -> None:
122+
_run_embeddings(VALID_SAMPLE, azure_embedding_model, 1536)
123+
_run_embeddings(TOO_LONG_SAMPLE, azure_embedding_model, 1536)
124+
125+
120126
# NOTE (chris): this test doesn't work, and I do not know why
121127
# def test_azure_embedding_model_rate_limit(azure_embedding_model: EmbeddingModel):
122128
# """NOTE: this test relies on a very low rate limit for the Azure API +
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
services:
2+
indexing_model_server:
3+
image: onyxdotapp/onyx-model-server:${IMAGE_TAG:-latest}
4+
build:
5+
context: ../../backend
6+
dockerfile: Dockerfile.model_server
7+
command: >
8+
/bin/sh -c "if [ \"${DISABLE_MODEL_SERVER:-false}\" = \"True\" ]; then
9+
echo 'Skipping service...';
10+
exit 0;
11+
else
12+
exec uvicorn model_server.main:app --host 0.0.0.0 --port 9000;
13+
fi"
14+
restart: on-failure
15+
environment:
16+
- INDEX_BATCH_SIZE=${INDEX_BATCH_SIZE:-}
17+
- MIN_THREADS_ML_MODELS=${MIN_THREADS_ML_MODELS:-}
18+
- INDEXING_ONLY=True
19+
# Set to debug to get more fine-grained logs
20+
- LOG_LEVEL=${LOG_LEVEL:-info}
21+
- CLIENT_EMBEDDING_TIMEOUT=${CLIENT_EMBEDDING_TIMEOUT:-}
22+
23+
# Analytics Configs
24+
- SENTRY_DSN=${SENTRY_DSN:-}
25+
volumes:
26+
# Not necessary, this is just to reduce download time during startup
27+
- indexing_huggingface_model_cache:/root/.cache/huggingface/
28+
logging:
29+
driver: json-file
30+
options:
31+
max-size: "50m"
32+
max-file: "6"
33+
ports:
34+
- "9000:9000" # <-- Add this line to expose the port to the host
35+
36+
volumes:
37+
indexing_huggingface_model_cache:

0 commit comments

Comments
 (0)