diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index 5c833269..505ab079 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -69,6 +69,17 @@ jobs: - name: Run Gradio app tests run: | + echo "Installing ollama..." + curl -fsSL https://ollama.com/install.sh | sh + + # Give ollama systemd unit time to start + sleep 5 + + MODEL=smollm2:135m + echo "Pulling model $MODEL..." + ollama pull $MODEL + + echo "Running Gradio test script" ./test-images.sh $(git rev-parse --short ${{ github.sha }}) working-directory: web-apps diff --git a/charts/azimuth-llm/ci/default-values.yaml b/charts/azimuth-llm/ci/default-values.yaml index 40dbbde3..64f51ba2 100644 --- a/charts/azimuth-llm/ci/default-values.yaml +++ b/charts/azimuth-llm/ci/default-values.yaml @@ -10,6 +10,8 @@ api: enabled: false # No GPUs in CI runners gpus: 0 + # Limit context length for efficiency + modelMaxContextLength: 100 ui: service: zenith: diff --git a/web-apps/chat/Dockerfile b/web-apps/chat/Dockerfile index c963b29f..0dd199b4 100644 --- a/web-apps/chat/Dockerfile +++ b/web-apps/chat/Dockerfile @@ -1,10 +1,11 @@ -FROM python:3.11-slim +FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim ARG DIR=chat COPY $DIR/requirements.txt requirements.txt +RUN sed -i s$../utils$./utils$ requirements.txt COPY utils utils -RUN pip install --no-cache-dir -r requirements.txt +RUN uv pip install --system --no-cache-dir -r requirements.txt COPY purge-google-fonts.sh purge-google-fonts.sh RUN bash purge-google-fonts.sh diff --git a/web-apps/chat/defaults.yml b/web-apps/chat/defaults.yml index 8a189767..8b9ebdff 100644 --- a/web-apps/chat/defaults.yml +++ b/web-apps/chat/defaults.yml @@ -1,8 +1,7 @@ # Default target is a local ollama instance -# running inside the same docker network model_name: smollm2:135m -backend_url: http://ollama:11434 +backend_url: http://localhost:11434 host_address: 0.0.0.0 diff --git a/web-apps/chat/requirements.txt b/web-apps/chat/requirements.txt index 635f4a4e..a448a54f 100644 --- a/web-apps/chat/requirements.txt +++ b/web-apps/chat/requirements.txt @@ -1,7 +1,7 @@ gradio<6 gradio_client openai -langchain +langchain<1.0 langchain_openai pydantic structlog diff --git a/web-apps/flux-image-gen/Dockerfile b/web-apps/flux-image-gen/Dockerfile index ba48dbe0..b05b609f 100644 --- a/web-apps/flux-image-gen/Dockerfile +++ b/web-apps/flux-image-gen/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11 +FROM ghcr.io/astral-sh/uv:python3.11-bookworm # https://stackoverflow.com/questions/55313610/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y @@ -7,7 +7,7 @@ RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y ARG DIR=flux-image-gen COPY $DIR/requirements.txt requirements.txt -RUN pip install --no-cache-dir -r requirements.txt +RUN uv pip install --system --no-cache-dir -r requirements.txt COPY purge-google-fonts.sh . RUN bash purge-google-fonts.sh diff --git a/web-apps/image-analysis/Dockerfile b/web-apps/image-analysis/Dockerfile index 5f858f85..50d30ea2 100644 --- a/web-apps/image-analysis/Dockerfile +++ b/web-apps/image-analysis/Dockerfile @@ -1,10 +1,11 @@ -FROM python:3.11-slim +FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim ARG DIR=image-analysis COPY $DIR/requirements.txt requirements.txt +RUN sed -i s$../utils$./utils$ requirements.txt COPY utils utils -RUN pip install --no-cache-dir -r requirements.txt +RUN uv pip install --system --no-cache-dir -r requirements.txt COPY purge-google-fonts.sh purge-google-fonts.sh RUN bash purge-google-fonts.sh diff --git a/web-apps/test-images.sh b/web-apps/test-images.sh index d2a9706d..8909207f 100755 --- a/web-apps/test-images.sh +++ b/web-apps/test-images.sh @@ -1,6 +1,12 @@ #!/bin/bash set -e +# NOTE(sd109): This script relies on docker host networking in order +# to communicate from Gradio to ollama running on localhost. This means +# it does not work on MacOS since docker host networking does not work. +# It is intended to be run on a Linux machine and is primarily used in +# GitHub runners as part of CI testing. + IMAGE_TAG="${1:-latest}" echo Testing image tag $IMAGE_TAG @@ -41,10 +47,12 @@ test() { if [[ -f $1/test.py ]]; then - DOCKER_NET_NAME=azimuth-llm-shared - if [[ ! $(docker network ls | grep $DOCKER_NET_NAME) ]]; then - docker network create $DOCKER_NET_NAME - fi + DOCKER_NET_NAME=host + + # DOCKER_NET_NAME=azimuth-llm-shared + # if [[ ! $(docker network ls | grep $DOCKER_NET_NAME) ]]; then + # docker network create $DOCKER_NET_NAME + # fi # Ensure app image is available IMAGE=$(image_name $1):$IMAGE_TAG @@ -56,33 +64,41 @@ test() { fi # Ensure Ollama instance is available - if [[ $(curl -s localhost:11434) == "Ollama is running" ]]; then - log "Using existing ollama process running on localhost:11434" - else - log "Ollama process not running - starting containerised server" - docker run --rm --network $DOCKER_NET_NAME -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama - sleep 3 - docker exec ollama ollama pull smollm2:135m + if [[ $(curl -s localhost:11434) != "Ollama is running" ]]; then + log "Ollama not running on localhost:11434 - aborting test" + exit 1 + # log "Using existing ollama process running on localhost:11434" + # else + # log "Ollama process not running - starting containerised server" + # docker run --rm --network $DOCKER_NET_NAME -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama + # sleep 3 + # docker exec ollama ollama pull smollm2:135m fi log "Starting Gradio app container" docker run --network $DOCKER_NET_NAME -d --name $1-app $IMAGE # Give the app time to start - sleep 3 + sleep 10 log "Running tests" + # docker run --network $DOCKER_NET_NAME --rm \ + # --name $1-test-suite \ + # -e GRADIO_URL=http://$1-app:7860 --entrypoint python \ + # $IMAGE \ + # test.py docker run --network $DOCKER_NET_NAME --rm \ --name $1-test-suite \ - -e GRADIO_URL=http://$1-app:7860 --entrypoint python \ + --entrypoint python \ $IMAGE \ test.py log "Removing containers:" - docker rm -f ollama $1-app + # docker rm -f ollama $1-app + docker rm -f $1-app - log "Removing docker network:" - docker network rm $DOCKER_NET_NAME + # log "Removing docker network:" + # docker network rm $DOCKER_NET_NAME echo echo "----- Tests succeed -----"