From 74f6af8bbe64241e079ac613925071fa6e578505 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Sat, 18 Jan 2025 15:16:05 -0800 Subject: [PATCH] [CICD] add simple test step for docker build workflow, fix prefix bug (#821) # What does this PR do? **Main Thing** - Add a simple test step before publishing docker image in workflow **Side Fix** - Docker push action fails recently due to extra prefix introduced. E.g. see: https://github.com/meta-llama/llama-stack/pull/802#issuecomment-2599507062 cc @terrytangyuan ## Test Plan 1. Release a TestPyPi version on this code: 0.0.63.dev51206766 https://github.com/meta-llama/llama-stack/actions/runs/12841805606/job/35812033317?pr=821 ``` # 1. build docker image TEST_PYPI_VERSION=0.0.63.dev51206766 llama stack build --template fireworks # 2. test the docker image cd distributions/fireworks && docker compose up ``` 4. Test the full build + test docker flow using TestPyPi from (1): https://github.com/meta-llama/llama-stack/actions/runs/12842184947 image ## Sources Please link relevant resources if necessary. ## Before submitting - [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). - [ ] Ran pre-commit to handle lint / formatting issues. - [ ] Read the [contributor guideline](https://github.com/meta-llama/llama-stack/blob/main/CONTRIBUTING.md), Pull Request section? - [ ] Updated relevant documentation. - [ ] Wrote necessary unit or integration tests. --- .github/workflows/publish-to-docker.yml | 41 ++++++++++++++++++++- distributions/fireworks/compose.yaml | 8 ++-- distributions/together/compose.yaml | 8 ++-- llama_stack/distribution/build_container.sh | 3 +- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish-to-docker.yml b/.github/workflows/publish-to-docker.yml index f63f52cbd..1010041b7 100644 --- a/.github/workflows/publish-to-docker.yml +++ b/.github/workflows/publish-to-docker.yml @@ -11,6 +11,10 @@ on: jobs: build-and-push: runs-on: ubuntu-latest + env: + TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }} + FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }} + TAVILY_SEARCH_API_KEY: ${{ secrets.TAVILY_SEARCH_API_KEY }} permissions: contents: read packages: write @@ -32,7 +36,7 @@ jobs: id: version run: | if [ "${{ github.event_name }}" = "push" ]; then - echo "VERSION=0.0.63.dev20250114" >> $GITHUB_OUTPUT + echo "VERSION=0.0.63.dev51206766" >> $GITHUB_OUTPUT else echo "VERSION=${{ inputs.version }}" >> $GITHUB_OUTPUT fi @@ -85,6 +89,41 @@ jobs: run: | docker images + # TODO (xiyan): make the following 2 steps into a matrix and test all templates other than fireworks + - name: Start up built docker image + run: | + cd distributions/fireworks + if [ "$PYPI_SOURCE" = "testpypi" ]; then + sed -i 's|image: llamastack/distribution-fireworks|image: distribution-fireworks:test-${{ steps.version.outputs.version }}|' ./compose.yaml + else + sed -i 's|image: llamastack/distribution-fireworks|image: distribution-fireworks:${{ steps.version.outputs.version }}|' ./compose.yaml + fi + docker compose up -d + cd .. + # Wait for the container to start + timeout=300 + while ! curl -s -f http://localhost:8321/v1/version > /dev/null && [ $timeout -gt 0 ]; do + echo "Waiting for endpoint to be available..." + sleep 5 + timeout=$((timeout - 5)) + done + + if [ $timeout -le 0 ]; then + echo "Timeout waiting for endpoint to become available" + exit 1 + fi + + - name: Run simple models list test on docker server + run: | + curl http://localhost:8321/v1/models + + # TODO (xiyan): figure out why client cannot find server but curl works + # - name: Run pytest on docker server + # run: | + # pip install pytest pytest-md-report + # export LLAMA_STACK_BASE_URL="http://localhost:8321" + # LLAMA_STACK_BASE_URL="http://localhost:8321" pytest -v tests/client-sdk/inference/test_inference.py --md-report --md-report-verbose=1 + - name: Push to dockerhub run: | TEMPLATES=("ollama" "bedrock" "remote-vllm" "fireworks" "together" "tgi" "meta-reference-gpu") diff --git a/distributions/fireworks/compose.yaml b/distributions/fireworks/compose.yaml index 4b53fcf00..84b8491e4 100644 --- a/distributions/fireworks/compose.yaml +++ b/distributions/fireworks/compose.yaml @@ -1,13 +1,11 @@ services: llamastack: image: llamastack/distribution-fireworks - network_mode: "host" - volumes: - - ~/.llama:/root/.llama - - ./run.yaml:/root/llamastack-run-fireworks.yaml ports: - "8321:8321" - entrypoint: bash -c "python -m llama_stack.distribution.server.server --yaml_config /root/llamastack-run-fireworks.yaml" + environment: + - FIREWORKS_API_KEY=${FIREWORKS_API_KEY} + entrypoint: bash -c "python -m llama_stack.distribution.server.server --template fireworks" deploy: restart_policy: condition: on-failure diff --git a/distributions/together/compose.yaml b/distributions/together/compose.yaml index c7251d0a7..f66ee69f9 100644 --- a/distributions/together/compose.yaml +++ b/distributions/together/compose.yaml @@ -1,13 +1,11 @@ services: llamastack: image: llamastack/distribution-together - network_mode: "host" - volumes: - - ~/.llama:/root/.llama - - ./run.yaml:/root/llamastack-run-together.yaml ports: - "8321:8321" - entrypoint: bash -c "python -m llama_stack.distribution.server.server --yaml_config /root/llamastack-run-together.yaml" + environment: + - TOGETHER_API_KEY=${TOGETHER_API_KEY} + entrypoint: bash -c "python -m llama_stack.distribution.server.server --template together" deploy: restart_policy: condition: on-failure diff --git a/llama_stack/distribution/build_container.sh b/llama_stack/distribution/build_container.sh index 4c2425004..c7b6211f7 100755 --- a/llama_stack/distribution/build_container.sh +++ b/llama_stack/distribution/build_container.sh @@ -23,7 +23,6 @@ special_pip_deps="$6" set -euo pipefail build_name="$1" -image_name="distribution-$build_name" container_base=$2 build_file_path=$3 host_build_dir=$4 @@ -184,7 +183,7 @@ else fi # Add version tag to image name -image_tag="$image_name:$version_tag" +image_tag="$build_name:$version_tag" # Detect platform architecture ARCH=$(uname -m)