From fe62a5437c3437c0611378b3ed92094dd9a733d4 Mon Sep 17 00:00:00 2001 From: sallyom Date: Thu, 11 Apr 2024 11:46:33 -0400 Subject: [PATCH 1/2] enable testing for sample apps Signed-off-by: sallyom --- ...push.yaml => ailab_build_push_manual.yaml} | 5 +- .github/workflows/build-images.yaml | 172 ------------------ .github/workflows/chatbot.yaml | 12 +- .github/workflows/codegen.yaml | 85 +++++++++ .github/workflows/model_servers.yaml | 22 ++- .github/workflows/rag.yaml | 85 +++++++++ .github/workflows/summarizer.yaml | 85 +++++++++ .github/workflows/testing-framework.yaml | 36 +++- ai-lab-recipes-images.md => ailab-images.md | 12 +- recipes/audio/audio_to_text/ai-lab.yaml | 2 +- recipes/common/Makefile.common | 42 ++++- .../chatbot/Makefile | 37 +--- .../chatbot/bootc/README.md | 2 +- .../codegen/Makefile | 6 + .../codegen/ai-lab.yaml | 2 +- .../codegen/bootc/README.md | 2 +- .../codegen/provision/playbook.yml | 60 ++++++ .../codegen/provision/requirements.yml | 4 + .../codegen/quadlet/codegen.yaml | 6 +- .../natural_language_processing/rag/Makefile | 66 ++++++- .../rag/ai-lab.yaml | 4 +- .../rag/bootc/README.md | 2 +- .../rag/provision/playbook.yml | 72 ++++++++ .../rag/provision/requirements.yml | 4 + .../summarizer/Makefile | 6 + .../summarizer/ai-lab.yaml | 2 +- .../summarizer/provision/playbook.yml | 60 ++++++ .../summarizer/provision/requirements.yml | 4 + .../{chatbot => }/tests/conftest.py | 0 .../tests/functional/__init__.py | 0 .../tests/functional/conftest.py | 0 .../tests/functional/test_app.py | 0 .../tests/integration/__init__.py | 0 .../tests/integration/conftest.py | 0 .../tests/integration/test_app.py | 0 .../{chatbot => }/tests/requirements.txt | 0 36 files changed, 645 insertions(+), 252 deletions(-) rename .github/workflows/{ailab_image_build_push.yaml => ailab_build_push_manual.yaml} (98%) delete mode 100644 .github/workflows/build-images.yaml create mode 100644 .github/workflows/codegen.yaml create mode 100644 .github/workflows/rag.yaml create mode 100644 .github/workflows/summarizer.yaml rename ai-lab-recipes-images.md => ailab-images.md (70%) create mode 100644 recipes/natural_language_processing/codegen/provision/playbook.yml create mode 100644 recipes/natural_language_processing/codegen/provision/requirements.yml create mode 100644 recipes/natural_language_processing/rag/provision/playbook.yml create mode 100644 recipes/natural_language_processing/rag/provision/requirements.yml create mode 100644 recipes/natural_language_processing/summarizer/provision/playbook.yml create mode 100644 recipes/natural_language_processing/summarizer/provision/requirements.yml rename recipes/natural_language_processing/{chatbot => }/tests/conftest.py (100%) rename recipes/natural_language_processing/{chatbot => }/tests/functional/__init__.py (100%) rename recipes/natural_language_processing/{chatbot => }/tests/functional/conftest.py (100%) rename recipes/natural_language_processing/{chatbot => }/tests/functional/test_app.py (100%) rename recipes/natural_language_processing/{chatbot => }/tests/integration/__init__.py (100%) rename recipes/natural_language_processing/{chatbot => }/tests/integration/conftest.py (100%) rename recipes/natural_language_processing/{chatbot => }/tests/integration/test_app.py (100%) rename recipes/natural_language_processing/{chatbot => }/tests/requirements.txt (100%) diff --git a/.github/workflows/ailab_image_build_push.yaml b/.github/workflows/ailab_build_push_manual.yaml similarity index 98% rename from .github/workflows/ailab_image_build_push.yaml rename to .github/workflows/ailab_build_push_manual.yaml index a070256a..8707ec44 100644 --- a/.github/workflows/ailab_image_build_push.yaml +++ b/.github/workflows/ailab_build_push_manual.yaml @@ -1,9 +1,6 @@ -name: Update quay.io/ai-lab images +name: Update quay.io/ai-lab images with manual trigger on: - schedule: # schedule the job to run at 12 AM daily - - cron: '0 0 * * *' - workflow_dispatch: env: diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml deleted file mode 100644 index 4f274c04..00000000 --- a/.github/workflows/build-images.yaml +++ /dev/null @@ -1,172 +0,0 @@ -name: Sample applications build,test,push images - -# Build image once the PR is merged to main branch. -on: - pull_request: - workflow_dispatch: - branches: [ main ] - push: - workflow_dispatch: - branches: [main] - -jobs: - build: - runs-on: ubuntu-latest # windows-latest || macos-latest - env: - REGISTRY: quay.io/ai-lab - #GH_REGISTRY: ghcr.io - # github.repository as / - SUMMARIZER_IMAGE: summarizer - CODEGEN_IMAGE: codegen - RAG_IMAGE: rag - CHROMADB_IMAGE: chromadb - steps: - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - - name: Get changed rag files - id: changed-files-rag - uses: tj-actions/changed-files@v42 - with: - files: | - recipes/natural_language_processing/rag/** - - - name: Get changed summarizer files - id: changed-files-summarizer - uses: tj-actions/changed-files@v42 - with: - files: | - recipes/natural_language_processing/summarizer/** - - - name: Get changed code-generation files - id: changed-files-codegen - uses: tj-actions/changed-files@v42 - with: - files: | - recipes/natural_language_processing/codegen/** - - - name: Get changed chromadb files - id: changed-files-chromadb - uses: tj-actions/changed-files@v42 - with: - files: | - vector_dbs/chromadb/** - - - name: Install qemu dependency - if: steps.changed-files-summarizer.outputs.any_changed == 'true' || steps.changed-files-rag.outputs.any_changed == 'true' || steps.changed-files-codegen.outputs.any_changed == 'true' - run: | - sudo apt-get update - sudo apt-get install -y qemu-user-static - - - name: Login Quay Container registry - if: > - (steps.changed-files-summarizer.outputs.any_changed == 'true' || steps.changed-files-rag.outputs.any_changed == 'true' || steps.changed-files-chromadb.outputs.any_changed == 'true' || steps.changed-files-codegen.outputs.any_changed == 'true') && - (github.event_name == 'push' || github.event_name == 'schedule') && - (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: redhat-actions/podman-login@v1 - with: - registry: quay.io - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - - name: Build codegen - if: steps.changed-files-codegen.outputs.any_changed == 'true' - id: build_codegen_multiplatform - uses: redhat-actions/buildah-build@v2 - with: - image: ${{ env.CODEGEN_IMAGE }} - tags: latest ${{ github.sha }} - platforms: linux/amd64, linux/arm64 - context: recipes/natural_language_processing/codegen/app - containerfiles: | - ./recipes/natural_language_processing/codegen/app/Containerfile - - - name: Push codegen image - id: push_codegen - if: > - (steps.changed-files-codegen.outputs.any_changed == 'true') && - (github.event_name == 'push' || github.event_name == 'schedule') && - (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ steps.build_codegen_multiplatform.outputs.image }} - tags: ${{ steps.build_codegen_multiplatform.outputs.tags }} - registry: ${{ env.REGISTRY }} - - - name: Build summarizer - if: steps.changed-files-summarizer.outputs.any_changed == 'true' - id: build_summarizer_multiplatform - uses: redhat-actions/buildah-build@v2 - with: - image: ${{ env.SUMMARIZER_IMAGE }} - tags: latest ${{ github.sha }} - platforms: linux/amd64, linux/arm64 - context: recipes/natural_language_processing/summarizer/app - containerfiles: | - ./recipes/natural_language_processing/summarizer/app/Containerfile - - - name: Push summarizer image - id: push_summarizer - if: > - (steps.changed-files-summarizer.outputs.any_changed == 'true') && - (github.event_name == 'push' || github.event_name == 'schedule') && - (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ steps.build_summarizer_multiplatform.outputs.image }} - tags: ${{ steps.build_summarizer_multiplatform.outputs.tags }} - registry: ${{ env.REGISTRY }} - - - name: Build RAG - if: steps.changed-files-rag.outputs.any_changed == 'true' - id: build_rag_multiplatform - uses: redhat-actions/buildah-build@v2 - with: - image: ${{ env.RAG_IMAGE }} - tags: latest ${{ github.sha }} - platforms: linux/arm64, linux/amd64 - context: recipes/natural_language_processing/rag/app - containerfiles: | - ./recipes/natural_language_processing/rag/app/Containerfile - - - name: Push rag image - id: push_rag - if: > - (steps.changed-files-rag.outputs.any_changed == 'true') && - (github.event_name == 'push' || github.event_name == 'schedule') && - (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ steps.build_rag_multiplatform.outputs.image }} - tags: ${{ steps.build_rag_multiplatform.outputs.tags }} - registry: ${{ env.REGISTRY }} - - - name: Build chromadb - if: steps.changed-files-chromadb.outputs.any_changed == 'true' - id: build_chromadb_multiplatform - uses: redhat-actions/buildah-build@v2 - with: - image: ${{ env.CHROMADB_IMAGE }} - tags: latest ${{ github.sha }} - platforms: linux/arm64, linux/amd64 - context: vector_dbs/chromadb - containerfiles: | - ./vector_dbs/chromadb/Containerfile - - - name: Push chromadb image - id: push_chromadb - if: > - (steps.changed-files-chromadb.outputs.any_changed == 'true') && - (github.event_name == 'push' || github.event_name == 'schedule') && - (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ steps.build_chromadb_multiplatform.outputs.image }} - tags: ${{ steps.build_chromadb_multiplatform.outputs.tags }} - registry: ${{ env.REGISTRY }} diff --git a/.github/workflows/chatbot.yaml b/.github/workflows/chatbot.yaml index bb11a7fa..25e2a710 100644 --- a/.github/workflows/chatbot.yaml +++ b/.github/workflows/chatbot.yaml @@ -4,15 +4,15 @@ on: pull_request: branches: - main - # paths: - # - ./recipes/natural_language_processing/chatbot/** - # - .github/workflows/chatbot.yaml + paths: + - ./recipes/natural_language_processing/chatbot/** + - .github/workflows/chatbot.yaml push: branches: - main - # paths: - # - ./recipes/natural_language_processing/chatbot/** - # - .github/workflows/chatbot.yaml + paths: + - ./recipes/natural_language_processing/chatbot/** + - .github/workflows/chatbot.yaml workflow_dispatch: diff --git a/.github/workflows/codegen.yaml b/.github/workflows/codegen.yaml new file mode 100644 index 00000000..b3ec2c5c --- /dev/null +++ b/.github/workflows/codegen.yaml @@ -0,0 +1,85 @@ +name: codegen + +on: + pull_request: + branches: + - main + paths: + - ./recipes/natural_language_processing/codegen/** + - .github/workflows/codegen.yaml + push: + branches: + - main + paths: + - ./recipes/natural_language_processing/codegen/** + - .github/workflows/codegen.yaml + + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: codegen + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + services: + registry: + image: registry:2.8.3 + ports: + - 5000:5000 + steps: + - uses: actions/checkout@v4.1.1 + + - name: Install qemu dependency + run: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + + - name: Build Image + id: build_image + uses: redhat-actions/buildah-build@v2.13 + with: + image: ${{ env.REGISTRY }}/containers/${{ env.IMAGE_NAME }} + tags: latest + platforms: linux/amd64, linux/arm64 + containerfiles: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }}/app/Containerfile + context: recipes/natural_language_processing/${{ env.IMAGE_NAME }}/app + + - name: Set up Python + uses: actions/setup-python@v5.0.0 + with: + python-version: '3.11' + + - name: Install Dependencies + working-directory: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }} + run: make install + + - name: Download model + working-directory: ./model_servers/llamacpp_python + run: make mistral + + - name: Run Functional Tests + shell: bash + run: make functional-tests + working-directory: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }} + + - name: Login to Registry + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: redhat-actions/podman-login@v1.7 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push Image + id: push_image + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: redhat-actions/push-to-registry@v2.8 + with: + image: ${{ steps.build_image.outputs.image }} + tags: ${{ steps.build_image.outputs.tags }} + registry: ${{ env.REGISTRY }} diff --git a/.github/workflows/model_servers.yaml b/.github/workflows/model_servers.yaml index 1f1639ce..83d44a23 100644 --- a/.github/workflows/model_servers.yaml +++ b/.github/workflows/model_servers.yaml @@ -4,15 +4,15 @@ on: pull_request: branches: - main - # paths: - # - ./model_servers/ - # - .github/workflows/model_servers.yaml + paths: + - ./model_servers/ + - .github/workflows/model_servers.yaml push: branches: - main - # paths: - # - ./model_servers/ - # - .github/workflows/model_servers.yaml + paths: + - ./model_servers/ + - .github/workflows/model_servers.yaml workflow_dispatch: @@ -26,8 +26,16 @@ jobs: include: - image_name: llamacpp_python model: mistral + flavor: base + - image_name: llamacpp_python_vulkan + model: mistral + flavor: vulkan + - image_name: llamacpp_python_cuda + model: mistral + flavor: cuda - image_name: whispercpp model: whisper-small + flavor: base runs-on: ubuntu-latest permissions: contents: read @@ -52,7 +60,7 @@ jobs: image: ${{ env.REGISTRY }}/${{ github.repository_owner}}/${{ matrix.image_name }} platforms: linux/amd64, linux/arm64 tags: latest - containerfiles: ./model_servers/${{ matrix.image_name }}/base/Containerfile + containerfiles: ./model_servers/${{ matrix.image_name }}/${{ matrix.flavor }}/Containerfile context: model_servers/${{ matrix.image_name }}/ - name: Download model diff --git a/.github/workflows/rag.yaml b/.github/workflows/rag.yaml new file mode 100644 index 00000000..b953a894 --- /dev/null +++ b/.github/workflows/rag.yaml @@ -0,0 +1,85 @@ +name: rag + +on: + pull_request: + branches: + - main + # paths: + # - ./recipes/natural_language_processing/rag/** + # - .github/workflows/rag.yaml + push: + branches: + - main + # paths: + # - ./recipes/natural_language_processing/rag/** + # - .github/workflows/rag.yaml + + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: rag + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + services: + registry: + image: registry:2.8.3 + ports: + - 5000:5000 + steps: + - uses: actions/checkout@v4.1.1 + + - name: Install qemu dependency + run: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + + - name: Build Image + id: build_image + uses: redhat-actions/buildah-build@v2.13 + with: + image: ${{ env.REGISTRY }}/containers/${{ env.IMAGE_NAME }} + tags: latest + platforms: linux/amd64, linux/arm64 + containerfiles: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }}/app/Containerfile + context: recipes/natural_language_processing/${{ env.IMAGE_NAME }}/app + + - name: Set up Python + uses: actions/setup-python@v5.0.0 + with: + python-version: '3.11' + + - name: Install Dependencies + working-directory: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }} + run: make install + + - name: Download model + working-directory: ./model_servers/llamacpp_python + run: make mistral + + - name: Run Functional Tests + shell: bash + run: make functional-tests + working-directory: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }} + + - name: Login to Registry + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: redhat-actions/podman-login@v1.7 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push Image + id: push_image + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: redhat-actions/push-to-registry@v2.8 + with: + image: ${{ steps.build_image.outputs.image }} + tags: ${{ steps.build_image.outputs.tags }} + registry: ${{ env.REGISTRY }} diff --git a/.github/workflows/summarizer.yaml b/.github/workflows/summarizer.yaml new file mode 100644 index 00000000..84bd3a5b --- /dev/null +++ b/.github/workflows/summarizer.yaml @@ -0,0 +1,85 @@ +name: summarizer + +on: + pull_request: + branches: + - main + paths: + - ./recipes/natural_language_processing/summarizer/** + - .github/workflows/summarizer.yaml + push: + branches: + - main + paths: + - ./recipes/natural_language_processing/summarizer/** + - .github/workflows/summarizer.yaml + + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: summarizer + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + services: + registry: + image: registry:2.8.3 + ports: + - 5000:5000 + steps: + - uses: actions/checkout@v4.1.1 + + - name: Install qemu dependency + run: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + + - name: Build Image + id: build_image + uses: redhat-actions/buildah-build@v2.13 + with: + image: ${{ env.REGISTRY }}/containers/${{ env.IMAGE_NAME }} + tags: latest + platforms: linux/amd64, linux/arm64 + containerfiles: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }}/app/Containerfile + context: recipes/natural_language_processing/${{ env.IMAGE_NAME }}/app + + - name: Set up Python + uses: actions/setup-python@v5.0.0 + with: + python-version: '3.11' + + - name: Install Dependencies + working-directory: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }} + run: make install + + - name: Download model + working-directory: ./model_servers/llamacpp_python + run: make mistral + + - name: Run Functional Tests + shell: bash + run: make functional-tests + working-directory: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }} + + - name: Login to Registry + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: redhat-actions/podman-login@v1.7 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push Image + id: push_image + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: redhat-actions/push-to-registry@v2.8 + with: + image: ${{ steps.build_image.outputs.image }} + tags: ${{ steps.build_image.outputs.tags }} + registry: ${{ env.REGISTRY }} diff --git a/.github/workflows/testing-framework.yaml b/.github/workflows/testing-framework.yaml index ca9be417..400d2c9d 100644 --- a/.github/workflows/testing-framework.yaml +++ b/.github/workflows/testing-framework.yaml @@ -2,7 +2,7 @@ name: Testing Framework on: schedule: # schedule the job to run every hour - - cron: '0 * * * *' + - cron: '0 */6 * * *' workflow_dispatch: @@ -42,6 +42,11 @@ jobs: - arch: amd64 # gpu enabled aws_image_type: g4dn.xlarge aws_ami_architecture: x86_64 + - app_path: natural_language_processing/chatbot + - app_path: natural_language_processing/summarizer + - app_path: natural_language_processing/codegen + - app_path: natural_language_processing/rag + - app_path: audio/audio_to_text steps: - name: Checkout uses: actions/checkout@v4.1.1 @@ -84,11 +89,11 @@ jobs: - name: Ansible Collections run: ansible-galaxy install -r ./provision/requirements.yml - working-directory: ./main/recipes/natural_language_processing/chatbot + working-directory: ./main/recipes/${{ matrix.app_path }} - name: Provision run: | - ansible-playbook ./main/recipes/natural_language_processing/chatbot/provision/playbook.yml \ + ansible-playbook ./main/recipes/${{ matrix.app_path }}/provision/playbook.yml \ -i terraform-test-environment-module/hosts.ini \ --private-key=terraform-test-environment-module/${{ steps.terraform-output.outputs.pem_filename }} env: @@ -100,11 +105,11 @@ jobs: python-version: '3.11' - name: Install Dependencies - working-directory: ./main/recipes/natural_language_processing/chatbot + working-directory: ./main/recipes/${{ matrix.app_path }} run: make install - name: Run Integration Tests - working-directory: ./main/recipes/natural_language_processing/chatbot + working-directory: ./main/recipes/${{ matrix.app_path }} run: make integration-tests env: URL: ${{ steps.terraform-output.outputs.url }} @@ -139,8 +144,14 @@ jobs: matrix: include: - image: llamacpp_python + - image: llamacpp_python_vulkan + - image: llamacpp_python_cuda - image: whispercpp - image: chatbot + - image: summarizer + - image: codegen + - image: rag + - image: transcribe steps: - name: Login to registry uses: redhat-actions/podman-login@v1.7 @@ -167,14 +178,23 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - test-make-targets: + test-make-bootc: if: github.repository == 'containers-mirror/ai-lab-recipes' runs-on: ubuntu-22.04-2core + strategy: + fail-fast: false + matrix: + include: + - app_path: natural_language_processing/chatbot + - app_path: natural_language_processing/summarizer + - app_path: natural_language_processing/codegen + - app_path: natural_language_processing/rag + - app_path: audio/audio_to_text steps: - uses: actions/checkout@v4.1.1 - - name: chatbot - working-directory: ./recipes/natural_language_processing/chatbot + - name: + working-directory: ./recipes/${{ matrix.app_path }} run: make bootc - name: Publish Job Results to Slack diff --git a/ai-lab-recipes-images.md b/ailab-images.md similarity index 70% rename from ai-lab-recipes-images.md rename to ailab-images.md index 7b7ce057..cf462e23 100644 --- a/ai-lab-recipes-images.md +++ b/ailab-images.md @@ -1,11 +1,13 @@ ## Images (x86_64, aarch64) currently built from GH Actions in this repository - quay.io/ai-lab/llamacpp-python:latest -- quay.io/redhat-et/locallm-text-summarizer:latest +- quay.io/ai-lab/llamacpp-python-cuda:latest +- quay.io/ai-lab/llamacpp-python-vulkan:latest +- quay.io/ai-lab/summarizer:latest - quay.io/ai-lab/chatbot:latest -- quay.io/redhat-et/locallm-rag:latest -- quay.io/redhat-et/locallm-codegen:latest -- quay.io/redhat-et/locallm-chromadb:latest +- quay.io/ai-lab/rag:latest +- quay.io/ai-lab/codegen:latest +- quay.io/ai-lab/chromadb:latest - quay.io/redhat-et/locallm-object-detection-client:latest - quay.io/redhat-et/locallm-object-detection-server:latest @@ -13,5 +15,5 @@ - quay.io/ai-lab/mistral-7b-instruct:latest - [model download link](https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/resolve/main/mistral-7b-instruct-v0.1.Q4_K_M.gguf) -- quay.io/redhat-et/locallm-codellama-7b-gguf:latest +- quay.io/ai-lab/codellama-7b:latest - [model download link](https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-GGUF/resolve/main/codellama-7b-instruct.Q4_K_M.gguf) diff --git a/recipes/audio/audio_to_text/ai-lab.yaml b/recipes/audio/audio_to_text/ai-lab.yaml index 310ea80e..6a9cbe8b 100644 --- a/recipes/audio/audio_to_text/ai-lab.yaml +++ b/recipes/audio/audio_to_text/ai-lab.yaml @@ -15,7 +15,7 @@ application: - amd64 ports: - 8001 - image: quay.io/redhat-et/locallm-whispercpp-service:latest + image: quay.io/ai-lab/whispercpp:latest - name: whispercpp-app contextdir: app containerfile: Containerfile diff --git a/recipes/common/Makefile.common b/recipes/common/Makefile.common index 6820b05c..4a826ca8 100644 --- a/recipes/common/Makefile.common +++ b/recipes/common/Makefile.common @@ -54,6 +54,24 @@ CHROME_MIRROR := https://www.slimjet.com/chrome/files/$(CHROMEDRIVER_VERSION)/$( LOCAL_CHROMEDRIVER_EXISTS ?= $(shell command -v $(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver) UNZIP_EXISTS ?= $(shell command -v unzip) +RELATIVE_MODELS_PATH := ?= +RELATIVE_TESTS_PATH := ?= + +MISTRAL_MODEL_NAME := mistral-7b-instruct-v0.1.Q4_K_M.gguf +MISTRAL_MODEL_URL := https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/resolve/main/mistral-7b-instruct-v0.1.Q4_K_M.gguf + +MODEL_NAME ?= $(MISTRAL_MODEL_NAME) + +.PHONY: download-model-mistral +download-model-mistral: + curl -H "Cache-Control: no-cache" -s -S -L -f $(MISTRAL_MODEL_URL) -z $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME) -o $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME).tmp && mv -f $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME).tmp $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME) 2>/dev/null || rm -f $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME).tmp $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME) + +.PHONY: install +install: + $(MAKE) install-chromedriver CHROMEDRIVER_INSTALLATION_PATH=${CHROMEDRIVER_INSTALLATION_PATH} + $(MAKE) install-chrome CHROMEDRIVER_INSTALLATION_PATH=${CHROMEDRIVER_INSTALLATION_PATH} + pip install -q -r ${RELATIVE_TESTS_PATH}/requirements.txt + .PHONY: build build: podman build --squash-all $${ARCH:+--arch $${ARCH}} $${FROM:+--from $${FROM}} -t ${APP_IMAGE} app/ @@ -139,14 +157,12 @@ quadlet: sed -e "s|SERVER_IMAGE|${SERVER_IMAGE}|" \ -e "s|APP_IMAGE|${APP_IMAGE}|g" \ -e "s|MODEL_IMAGE|${MODEL_IMAGE}|g" \ - -e "s|CHROMADB_IMAGE|${CHROMADB_IMAGE}|g" \ -e "s|APP|${APP}|g" \ quadlet/${APP}.image \ > build/${APP}.image sed -e "s|SERVER_IMAGE|${SERVER_IMAGE}|" \ -e "s|APP_IMAGE|${APP_IMAGE}|g" \ -e "s|MODEL_IMAGE|${MODEL_IMAGE}|g" \ - -e "s|CHROMADB_IMAGE|${CHROMADB_IMAGE}|g" \ quadlet/${APP}.yaml \ > build/${APP}.yaml cp quadlet/${APP}.kube build/${APP}.kube @@ -171,3 +187,25 @@ check-model-in-path: ln -s ../../../models/$(MODEL_NAME) ./$(MODEL_NAME); \ fi; \ fi; + +.PHONY: functional-tests +functional-tests: + $(MAKE) MODEL_NAME=$(MODEL_NAME) check-model-in-path + @if [[ -n "$(LOCAL_CHROMEDRIVER_EXISTS)" ]]; then \ + IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} MODEL_NAME=${MODEL_NAME} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/functional; \ + else \ + echo "fetching chromedriver"; \ + make install; \ + IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} MODEL_NAME=${MODEL_NAME} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/functional; \ + fi; + +.PHONY: integration-tests +integration-tests: + @if [[ -n "$(LOCAL_CHROMEDRIVER_EXISTS)" ]]; then \ + URL=${URL} IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/integration; \ + else \ + echo "fetching chromedriver"; \ + make install; \ + URL=${URL} IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/integration; \ + fi; + diff --git a/recipes/natural_language_processing/chatbot/Makefile b/recipes/natural_language_processing/chatbot/Makefile index 7ab842df..9cd8adf0 100644 --- a/recipes/natural_language_processing/chatbot/Makefile +++ b/recipes/natural_language_processing/chatbot/Makefile @@ -6,39 +6,4 @@ include ../../common/Makefile.common CHROMEDRIVER_INSTALLATION_PATH := $(shell realpath ../..) RELATIVE_MODELS_PATH := ../../../models - -MISTRAL_MODEL_NAME := mistral-7b-instruct-v0.1.Q4_K_M.gguf -MISTRAL_MODEL_URL := https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/resolve/main/mistral-7b-instruct-v0.1.Q4_K_M.gguf - -MODEL_NAME ?= $(MISTRAL_MODEL_NAME) - -.PHONY: download-model-mistral -download-model-mistral: - curl -H "Cache-Control: no-cache" -s -S -L -f $(MISTRAL_MODEL_URL) -z $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME) -o $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME).tmp && mv -f $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME).tmp $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME) 2>/dev/null || rm -f $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME).tmp $(RELATIVE_MODELS_PATH)/$(MISTRAL_MODEL_NAME) - -.PHONY: install -install: - $(MAKE) install-chromedriver CHROMEDRIVER_INSTALLATION_PATH=${CHROMEDRIVER_INSTALLATION_PATH} - $(MAKE) install-chrome CHROMEDRIVER_INSTALLATION_PATH=${CHROMEDRIVER_INSTALLATION_PATH} - pip install -q -r tests/requirements.txt - -.PHONY: functional-tests -functional-tests: - $(MAKE) MODEL_NAME=$(MODEL_NAME) check-model-in-path - @if [[ -n "$(LOCAL_CHROMEDRIVER_EXISTS)" ]]; then \ - IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} MODEL_NAME=${MODEL_NAME} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver tests/functional; \ - else \ - echo "fetching chromedriver"; \ - make install; \ - IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} MODEL_NAME=${MODEL_NAME} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver tests/functional; \ - fi; - -.PHONY: integration-tests -integration-tests: - @if [[ -n "$(LOCAL_CHROMEDRIVER_EXISTS)" ]]; then \ - URL=${URL} IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver tests/integration; \ - else \ - echo "fetching chromedriver"; \ - make install; \ - URL=${URL} IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver tests/integration; \ - fi; +RELATIVE_TESTS_PATH := ../tests diff --git a/recipes/natural_language_processing/chatbot/bootc/README.md b/recipes/natural_language_processing/chatbot/bootc/README.md index 875602ca..d57e2d8b 100644 --- a/recipes/natural_language_processing/chatbot/bootc/README.md +++ b/recipes/natural_language_processing/chatbot/bootc/README.md @@ -32,7 +32,7 @@ podman build --build-arg "sshpubkey=$(cat ~/.ssh/id_rsa.pub)" \ # for GPU powered sample LLM application with llamacpp cuda model server podman build --build-arg "sshpubkey=$(cat ~/.ssh/id_rsa.pub)" \ - --build-arg "model-server-image="quay.io/redhat-et/locallm-llamacpp-cuda-model-server:latest" \ + --build-arg "model-server-image="quay.io/ai-lab/llamacpp-python-cuda:latest" \ --from \ --cap-add SYS_ADMIN \ --platform linux/amd64 \ diff --git a/recipes/natural_language_processing/codegen/Makefile b/recipes/natural_language_processing/codegen/Makefile index 4013705c..191fe344 100644 --- a/recipes/natural_language_processing/codegen/Makefile +++ b/recipes/natural_language_processing/codegen/Makefile @@ -1,3 +1,9 @@ +SHELL := /bin/bash APP ?= codegen +PORT ?= 8501 include ../../common/Makefile.common + +CHROMEDRIVER_INSTALLATION_PATH := $(shell realpath ../..) +RELATIVE_MODELS_PATH := ../../../models +RELATIVE_TESTS_PATH := ../tests diff --git a/recipes/natural_language_processing/codegen/ai-lab.yaml b/recipes/natural_language_processing/codegen/ai-lab.yaml index 2ef6fd64..9d6c0488 100644 --- a/recipes/natural_language_processing/codegen/ai-lab.yaml +++ b/recipes/natural_language_processing/codegen/ai-lab.yaml @@ -24,4 +24,4 @@ application: - amd64 ports: - 8501 - image: quay.io/redhat-et/locallm-codegen:latest + image: quay.io/ai-lab/codegen:latest diff --git a/recipes/natural_language_processing/codegen/bootc/README.md b/recipes/natural_language_processing/codegen/bootc/README.md index 8104719c..da796d3a 100644 --- a/recipes/natural_language_processing/codegen/bootc/README.md +++ b/recipes/natural_language_processing/codegen/bootc/README.md @@ -32,7 +32,7 @@ podman build --build-arg "sshpubkey=$(cat ~/.ssh/id_rsa.pub)" \ # for GPU powered sample LLM application with llamacpp cuda model server podman build --build-arg "sshpubkey=$(cat ~/.ssh/id_rsa.pub)" \ - --build-arg "model-server-image="quay.io/redhat-et/locallm-llamacpp-cuda-model-server:latest" \ + --build-arg "model-server-image="quay.io/ai-lab/lamacpp-python-cuda:latest" \ --from \ --cap-add SYS_ADMIN \ --platform linux/amd64 \ diff --git a/recipes/natural_language_processing/codegen/provision/playbook.yml b/recipes/natural_language_processing/codegen/provision/playbook.yml new file mode 100644 index 00000000..15e061e5 --- /dev/null +++ b/recipes/natural_language_processing/codegen/provision/playbook.yml @@ -0,0 +1,60 @@ +--- +- name: Test Environment Provisioning + hosts: test_environments + remote_user: fedora + become: true + gather_facts: false + + tasks: + + - name: Wait until the instance is ready + ansible.builtin.wait_for_connection: + delay: 10 + timeout: 60 + + - name: Gather facts for first time + ansible.builtin.setup: + + - name: Required Packages + ansible.builtin.package: + name: podman + state: present + + - name: Models host directory + ansible.builtin.file: + path: locallm/models + state: directory + + - name: Download Model + ansible.builtin.get_url: + url: https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q5_K_S.gguf + dest: locallm/models + + - name: Run Model + containers.podman.podman_container: + name: llamacpp_python + image: ghcr.io/containers/llamacpp_python:latest + state: started + interactive: true + tty: true + detach: true + ports: + - 8001:8001 + volume: + - ./locallm/models:/locallm/models:ro,Z + env: + MODEL_PATH: models/llama-2-7b-chat.Q5_K_S.gguf + HOST: 0.0.0.0 + PORT: 8001 + + - name: Run Application + containers.podman.podman_container: + name: codegen + image: ghcr.io/containers/codegen:latest + state: started + interactive: true + tty: true + ports: + - 8501:8501 + env: + MODEL_SERVICE_ENDPOINT: http://10.88.0.1:8001/v1 diff --git a/recipes/natural_language_processing/codegen/provision/requirements.yml b/recipes/natural_language_processing/codegen/provision/requirements.yml new file mode 100644 index 00000000..79a61a5f --- /dev/null +++ b/recipes/natural_language_processing/codegen/provision/requirements.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: containers.podman + version: 1.12.0 diff --git a/recipes/natural_language_processing/codegen/quadlet/codegen.yaml b/recipes/natural_language_processing/codegen/quadlet/codegen.yaml index fe19f0b9..a53d03e4 100644 --- a/recipes/natural_language_processing/codegen/quadlet/codegen.yaml +++ b/recipes/natural_language_processing/codegen/quadlet/codegen.yaml @@ -7,8 +7,8 @@ metadata: spec: initContainers: - name: model-file - image: quay.io/redhat-et/locallm-codellama-7b-gguf:latest - command: ['/usr/bin/install', "/model/codellama-7b-instruct.Q4_K_M.gguf", "/shared/"] + image: quay.io/ai-lab/codellama-7b:latest + command: ['/usr/bin/install', "/model/model.file", "/shared/"] volumeMounts: - name: model-file mountPath: /shared @@ -29,7 +29,7 @@ spec: - name: PORT value: 8001 - name: MODEL_PATH - value: /model/codellama-7b-instruct.Q4_K_M.gguf + value: /model/model.file image: SERVICE_IMAGE name: codegen-model-service ports: diff --git a/recipes/natural_language_processing/rag/Makefile b/recipes/natural_language_processing/rag/Makefile index 3a8c2c6f..cd943321 100644 --- a/recipes/natural_language_processing/rag/Makefile +++ b/recipes/natural_language_processing/rag/Makefile @@ -1,3 +1,67 @@ -APP=rag +SHELL := /bin/bash +APP ?= rag +PORT ?= 8501 +CHROMADB_PORT ?= 8000 include ../../common/Makefile.common + +CHROMEDRIVER_INSTALLATION_PATH := $(shell realpath ../..) +RELATIVE_MODELS_PATH := ../../../models +RELATIVE_TESTS_PATH := ../tests + +.PHONY: run-chromadb +run: + podman run -it -p $(CHROMADB_PORT):$(CHROMADB_PORT) -e CHROMADB_ENDPOINT=http://10.88.0.1:8000/v1 ${CHROMADB_IMAGE} + +# rag requires custom bootc because it uses an extra build-arg for CHROMADB_IMAGE (other apps use ../../common/Makefile.common target) +.PHONY: bootc +bootc: quadlet + podman build \ + $${ARCH:+--arch $${ARCH}} \ + $${FROM:+--from $${FROM}} \ + $${AUTH_JSON:+-v $${AUTH_JSON}:/run/containers/0/auth.json} \ + --security-opt label=disable \ + --cap-add SYS_ADMIN \ + --build-arg MODEL_IMAGE=$(MODEL_IMAGE) \ + --build-arg APP_IMAGE=$(APP_IMAGE) \ + --build-arg CHROMADB_IMAGE=$(CHROMADB_IMAGE) \ + --build-arg SERVER_IMAGE=$(SERVER_IMAGE) \ + --build-arg "SSHPUBKEY=$(SSH_PUBKEY)" \ + -v /etc/containers/policy.json:/etc/containers/policy.json \ + -f bootc/$(CONTAINERFILE) \ + -t ${BOOTC_IMAGE} . + @echo "" + @echo "Successfully built bootc image '${BOOTC_IMAGE}'." + @echo "You may now convert the image into a disk image via bootc-image-builder" + @echo "or the Podman Desktop Bootc Extension. For more information, please refer to" + @echo " * https://github.com/osbuild/bootc-image-builder" + @echo " * https://github.com/containers/podman-desktop-extension-bootc" + +# rag requires custom quadlet target for CHROMADB_IMAGE substitution +# (other apps use ../../common/Makefile.common target) +.PHONY: quadlet +quadlet: + # Modify quadlet files to match the server, model and app image + mkdir -p build + sed -e "s|SERVER_IMAGE|${SERVER_IMAGE}|" \ + -e "s|APP_IMAGE|${APP_IMAGE}|g" \ + -e "s|MODEL_IMAGE|${MODEL_IMAGE}|g" \ + -e "s|CHROMADB_IMAGE|${CHROMADB_IMAGE}|g" \ + -e "s|APP|${APP}|g" \ + quadlet/${APP}.image \ + > build/${APP}.image + sed -e "s|SERVER_IMAGE|${SERVER_IMAGE}|" \ + -e "s|APP_IMAGE|${APP_IMAGE}|g" \ + -e "s|MODEL_IMAGE|${MODEL_IMAGE}|g" \ + -e "s|CHROMADB_IMAGE|${CHROMADB_IMAGE}|g" \ + quadlet/${APP}.yaml \ + > build/${APP}.yaml + cp quadlet/${APP}.kube build/${APP}.kube + +# rag requires custom bootc-run because it uses an extra port for chromadb +# (other apps use ../../common/Makefile.common target) +.PHONY: bootc-run +bootc-run: + podman run -d --rm --name $(APP)-bootc -p 8080:8501 -p 8090:8000 --privileged \ + $${AUTH_JSON:+-v $${AUTH_JSON}:/run/containers/0/auth.json} \ + $(BOOTC_IMAGE) /sbin/init diff --git a/recipes/natural_language_processing/rag/ai-lab.yaml b/recipes/natural_language_processing/rag/ai-lab.yaml index 80ab3ee0..b50d3cf8 100644 --- a/recipes/natural_language_processing/rag/ai-lab.yaml +++ b/recipes/natural_language_processing/rag/ai-lab.yaml @@ -25,7 +25,7 @@ application: - amd64 ports: - 8000 - image: quay.io/redhat-et/locallm-chromadb:latest + image: quay.io/ai-lab/chromadb:latest - name: rag-inference-app contextdir: app containerfile: Containerfile @@ -34,4 +34,4 @@ application: - amd64 ports: - 8501 - image: quay.io/redhat-et/locallm-rag:latest + image: quay.io/ai-lab/rag:latest diff --git a/recipes/natural_language_processing/rag/bootc/README.md b/recipes/natural_language_processing/rag/bootc/README.md index edd4c16a..2f4531a6 100644 --- a/recipes/natural_language_processing/rag/bootc/README.md +++ b/recipes/natural_language_processing/rag/bootc/README.md @@ -32,7 +32,7 @@ podman build --build-arg "sshpubkey=$(cat ~/.ssh/id_rsa.pub)" \ # for GPU powered sample LLM application with llamacpp cuda model server podman build --build-arg "sshpubkey=$(cat ~/.ssh/id_rsa.pub)" \ - --build-arg "model-server-image="quay.io/redhat-et/locallm-llamacpp-cuda-model-server:latest" \ + --build-arg "model-server-image="quay.io/ai-lab/lamacpp-python-cuda:latest" \ --from \ --cap-add SYS_ADMIN \ --platform linux/amd64 \ diff --git a/recipes/natural_language_processing/rag/provision/playbook.yml b/recipes/natural_language_processing/rag/provision/playbook.yml new file mode 100644 index 00000000..2f127861 --- /dev/null +++ b/recipes/natural_language_processing/rag/provision/playbook.yml @@ -0,0 +1,72 @@ +--- +- name: Test Environment Provisioning + hosts: test_environments + remote_user: fedora + become: true + gather_facts: false + + tasks: + + - name: Wait until the instance is ready + ansible.builtin.wait_for_connection: + delay: 10 + timeout: 60 + + - name: Gather facts for first time + ansible.builtin.setup: + + - name: Required Packages + ansible.builtin.package: + name: podman + state: present + + - name: Models host directory + ansible.builtin.file: + path: locallm/models + state: directory + + - name: Download Model + ansible.builtin.get_url: + url: https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q5_K_S.gguf + dest: locallm/models + + - name: Run Model + containers.podman.podman_container: + name: llamacpp_python + image: ghcr.io/containers/llamacpp_python:latest + state: started + interactive: true + tty: true + detach: true + ports: + - 8001:8001 + volume: + - ./locallm/models:/locallm/models:ro,Z + env: + MODEL_PATH: models/llama-2-7b-chat.Q5_K_S.gguf + HOST: 0.0.0.0 + PORT: 8001 + + - name: Run Application + containers.podman.podman_container: + name: rag + image: ghcr.io/containers/rag:latest + state: started + interactive: true + tty: true + ports: + - 8501:8501 + env: + MODEL_SERVICE_ENDPOINT: http://10.88.0.1:8001/v1 + + - name: Run Vector Database + containers.podman.podman_container: + name: chromadb + image: ghcr.io/containers/chromadb:latest + state: started + interactive: true + tty: true + ports: + - 8000:8000 + env: + CHROMADB_ENDPOINT: http://0.0.0.0:8000/v1 diff --git a/recipes/natural_language_processing/rag/provision/requirements.yml b/recipes/natural_language_processing/rag/provision/requirements.yml new file mode 100644 index 00000000..79a61a5f --- /dev/null +++ b/recipes/natural_language_processing/rag/provision/requirements.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: containers.podman + version: 1.12.0 diff --git a/recipes/natural_language_processing/summarizer/Makefile b/recipes/natural_language_processing/summarizer/Makefile index 8e3ccf6b..b011c230 100644 --- a/recipes/natural_language_processing/summarizer/Makefile +++ b/recipes/natural_language_processing/summarizer/Makefile @@ -1,3 +1,9 @@ +SHELL := /bin/bash APP ?= summarizer +PORT ?= 8501 include ../../common/Makefile.common + +CHROMEDRIVER_INSTALLATION_PATH := $(shell realpath ../..) +RELATIVE_MODELS_PATH := ../../../models +RELATIVE_TESTS_PATH := ../tests diff --git a/recipes/natural_language_processing/summarizer/ai-lab.yaml b/recipes/natural_language_processing/summarizer/ai-lab.yaml index a786b26d..10b902dd 100644 --- a/recipes/natural_language_processing/summarizer/ai-lab.yaml +++ b/recipes/natural_language_processing/summarizer/ai-lab.yaml @@ -24,4 +24,4 @@ application: - amd64 ports: - 8501 - image: quay.io/redhat-et/locallm-text-summarizer:latest + image: quay.io/ai-lab/summarizer:latest diff --git a/recipes/natural_language_processing/summarizer/provision/playbook.yml b/recipes/natural_language_processing/summarizer/provision/playbook.yml new file mode 100644 index 00000000..683d22e8 --- /dev/null +++ b/recipes/natural_language_processing/summarizer/provision/playbook.yml @@ -0,0 +1,60 @@ +--- +- name: Test Environment Provisioning + hosts: test_environments + remote_user: fedora + become: true + gather_facts: false + + tasks: + + - name: Wait until the instance is ready + ansible.builtin.wait_for_connection: + delay: 10 + timeout: 60 + + - name: Gather facts for first time + ansible.builtin.setup: + + - name: Required Packages + ansible.builtin.package: + name: podman + state: present + + - name: Models host directory + ansible.builtin.file: + path: locallm/models + state: directory + + - name: Download Model + ansible.builtin.get_url: + url: https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q5_K_S.gguf + dest: locallm/models + + - name: Run Model + containers.podman.podman_container: + name: llamacpp_python + image: ghcr.io/containers/llamacpp_python:latest + state: started + interactive: true + tty: true + detach: true + ports: + - 8001:8001 + volume: + - ./locallm/models:/locallm/models:ro,Z + env: + MODEL_PATH: models/llama-2-7b-chat.Q5_K_S.gguf + HOST: 0.0.0.0 + PORT: 8001 + + - name: Run Application + containers.podman.podman_container: + name: summarizer + image: ghcr.io/containers/summarizer:latest + state: started + interactive: true + tty: true + ports: + - 8501:8501 + env: + MODEL_SERVICE_ENDPOINT: http://10.88.0.1:8001/v1 diff --git a/recipes/natural_language_processing/summarizer/provision/requirements.yml b/recipes/natural_language_processing/summarizer/provision/requirements.yml new file mode 100644 index 00000000..79a61a5f --- /dev/null +++ b/recipes/natural_language_processing/summarizer/provision/requirements.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: containers.podman + version: 1.12.0 diff --git a/recipes/natural_language_processing/chatbot/tests/conftest.py b/recipes/natural_language_processing/tests/conftest.py similarity index 100% rename from recipes/natural_language_processing/chatbot/tests/conftest.py rename to recipes/natural_language_processing/tests/conftest.py diff --git a/recipes/natural_language_processing/chatbot/tests/functional/__init__.py b/recipes/natural_language_processing/tests/functional/__init__.py similarity index 100% rename from recipes/natural_language_processing/chatbot/tests/functional/__init__.py rename to recipes/natural_language_processing/tests/functional/__init__.py diff --git a/recipes/natural_language_processing/chatbot/tests/functional/conftest.py b/recipes/natural_language_processing/tests/functional/conftest.py similarity index 100% rename from recipes/natural_language_processing/chatbot/tests/functional/conftest.py rename to recipes/natural_language_processing/tests/functional/conftest.py diff --git a/recipes/natural_language_processing/chatbot/tests/functional/test_app.py b/recipes/natural_language_processing/tests/functional/test_app.py similarity index 100% rename from recipes/natural_language_processing/chatbot/tests/functional/test_app.py rename to recipes/natural_language_processing/tests/functional/test_app.py diff --git a/recipes/natural_language_processing/chatbot/tests/integration/__init__.py b/recipes/natural_language_processing/tests/integration/__init__.py similarity index 100% rename from recipes/natural_language_processing/chatbot/tests/integration/__init__.py rename to recipes/natural_language_processing/tests/integration/__init__.py diff --git a/recipes/natural_language_processing/chatbot/tests/integration/conftest.py b/recipes/natural_language_processing/tests/integration/conftest.py similarity index 100% rename from recipes/natural_language_processing/chatbot/tests/integration/conftest.py rename to recipes/natural_language_processing/tests/integration/conftest.py diff --git a/recipes/natural_language_processing/chatbot/tests/integration/test_app.py b/recipes/natural_language_processing/tests/integration/test_app.py similarity index 100% rename from recipes/natural_language_processing/chatbot/tests/integration/test_app.py rename to recipes/natural_language_processing/tests/integration/test_app.py diff --git a/recipes/natural_language_processing/chatbot/tests/requirements.txt b/recipes/natural_language_processing/tests/requirements.txt similarity index 100% rename from recipes/natural_language_processing/chatbot/tests/requirements.txt rename to recipes/natural_language_processing/tests/requirements.txt From 6fbfd23e2541ab19ef7268bedef7f193e2c61ca2 Mon Sep 17 00:00:00 2001 From: sallyom Date: Thu, 11 Apr 2024 14:20:11 -0400 Subject: [PATCH 2/2] fix Signed-off-by: sallyom --- .github/workflows/model_servers.yaml | 45 ++++++++++++++----- .github/workflows/rag.yaml | 17 ++++--- .github/workflows/testing-framework.yaml | 36 ++++----------- model_servers/llamacpp_python/Makefile | 20 +++++++-- .../llamacpp_python/tests/conftest.py | 1 + .../llamacpp_python/tests/test_alive.py | 1 - 6 files changed, 71 insertions(+), 49 deletions(-) diff --git a/.github/workflows/model_servers.yaml b/.github/workflows/model_servers.yaml index 83d44a23..84b1ae8f 100644 --- a/.github/workflows/model_servers.yaml +++ b/.github/workflows/model_servers.yaml @@ -27,15 +27,27 @@ jobs: - image_name: llamacpp_python model: mistral flavor: base - - image_name: llamacpp_python_vulkan - model: mistral - flavor: vulkan + directory: llamacpp_python + platforms: linux/amd64,linux/arm64 + no_gpu: 1 + #- image_name: llamacpp_python_vulkan + # model: mistral + # flavor: vulkan + # directory: llamacpp_python + # platforms: linux/arm64 + # vulkan: 1 - image_name: llamacpp_python_cuda model: mistral flavor: cuda + directory: llamacpp_python + platforms: linux/amd64 + cuda: 1 - image_name: whispercpp model: whisper-small flavor: base + directory: whispercpp + platforms: linux/amd64,linux/arm64 + no_gpu: 1 runs-on: ubuntu-latest permissions: contents: read @@ -46,6 +58,11 @@ jobs: ports: - 5000:5000 steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - uses: actions/checkout@v4.1.1 - name: Install qemu dependency @@ -58,13 +75,13 @@ jobs: uses: redhat-actions/buildah-build@v2.13 with: image: ${{ env.REGISTRY }}/${{ github.repository_owner}}/${{ matrix.image_name }} - platforms: linux/amd64, linux/arm64 + platforms: ${{ matrix.platforms }} tags: latest - containerfiles: ./model_servers/${{ matrix.image_name }}/${{ matrix.flavor }}/Containerfile - context: model_servers/${{ matrix.image_name }}/ + containerfiles: ./model_servers/${{ matrix.directory }}/${{ matrix.flavor }}/Containerfile + context: model_servers/${{ matrix.directory }}/ - name: Download model - working-directory: ./model_servers/${{ matrix.image_name }}/ + working-directory: ./model_servers/${{ matrix.directory }}/ run: make ${{ matrix.model }} - name: Set up Python @@ -73,15 +90,23 @@ jobs: python-version: '3.11' - name: Install python dependencies - working-directory: ./model_servers/${{ matrix.image_name }}/ + working-directory: ./model_servers/${{ matrix.directory }}/ run: make install - - name: Run tests - working-directory: ./model_servers/${{ matrix.image_name }}/ + - name: Run non-gpu tests + working-directory: ./model_servers/${{ matrix.directory }}/ + if: ${{ matrix.no_gpu }} run: make test env: IMAGE_NAME: ${{ matrix.image_name }} + - name: Run cuda test + working-directory: ./model_servers/${{ matrix.directory }}/ + if: ${{ matrix.cuda }} + run: make test-cuda + env: + IMAGE_NAME: ${{ matrix.image_name }} + - name: Login to Container Registry if: github.event_name == 'push' && github.ref == 'refs/heads/main' uses: redhat-actions/podman-login@v1.7 diff --git a/.github/workflows/rag.yaml b/.github/workflows/rag.yaml index b953a894..3fbe96ef 100644 --- a/.github/workflows/rag.yaml +++ b/.github/workflows/rag.yaml @@ -4,15 +4,15 @@ on: pull_request: branches: - main - # paths: - # - ./recipes/natural_language_processing/rag/** - # - .github/workflows/rag.yaml + paths: + - ./recipes/natural_language_processing/rag/** + - .github/workflows/rag.yaml push: branches: - main - # paths: - # - ./recipes/natural_language_processing/rag/** - # - .github/workflows/rag.yaml + paths: + - ./recipes/natural_language_processing/rag/** + - .github/workflows/rag.yaml workflow_dispatch: @@ -32,6 +32,11 @@ jobs: ports: - 5000:5000 steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - uses: actions/checkout@v4.1.1 - name: Install qemu dependency diff --git a/.github/workflows/testing-framework.yaml b/.github/workflows/testing-framework.yaml index 400d2c9d..ca9be417 100644 --- a/.github/workflows/testing-framework.yaml +++ b/.github/workflows/testing-framework.yaml @@ -2,7 +2,7 @@ name: Testing Framework on: schedule: # schedule the job to run every hour - - cron: '0 */6 * * *' + - cron: '0 * * * *' workflow_dispatch: @@ -42,11 +42,6 @@ jobs: - arch: amd64 # gpu enabled aws_image_type: g4dn.xlarge aws_ami_architecture: x86_64 - - app_path: natural_language_processing/chatbot - - app_path: natural_language_processing/summarizer - - app_path: natural_language_processing/codegen - - app_path: natural_language_processing/rag - - app_path: audio/audio_to_text steps: - name: Checkout uses: actions/checkout@v4.1.1 @@ -89,11 +84,11 @@ jobs: - name: Ansible Collections run: ansible-galaxy install -r ./provision/requirements.yml - working-directory: ./main/recipes/${{ matrix.app_path }} + working-directory: ./main/recipes/natural_language_processing/chatbot - name: Provision run: | - ansible-playbook ./main/recipes/${{ matrix.app_path }}/provision/playbook.yml \ + ansible-playbook ./main/recipes/natural_language_processing/chatbot/provision/playbook.yml \ -i terraform-test-environment-module/hosts.ini \ --private-key=terraform-test-environment-module/${{ steps.terraform-output.outputs.pem_filename }} env: @@ -105,11 +100,11 @@ jobs: python-version: '3.11' - name: Install Dependencies - working-directory: ./main/recipes/${{ matrix.app_path }} + working-directory: ./main/recipes/natural_language_processing/chatbot run: make install - name: Run Integration Tests - working-directory: ./main/recipes/${{ matrix.app_path }} + working-directory: ./main/recipes/natural_language_processing/chatbot run: make integration-tests env: URL: ${{ steps.terraform-output.outputs.url }} @@ -144,14 +139,8 @@ jobs: matrix: include: - image: llamacpp_python - - image: llamacpp_python_vulkan - - image: llamacpp_python_cuda - image: whispercpp - image: chatbot - - image: summarizer - - image: codegen - - image: rag - - image: transcribe steps: - name: Login to registry uses: redhat-actions/podman-login@v1.7 @@ -178,23 +167,14 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - test-make-bootc: + test-make-targets: if: github.repository == 'containers-mirror/ai-lab-recipes' runs-on: ubuntu-22.04-2core - strategy: - fail-fast: false - matrix: - include: - - app_path: natural_language_processing/chatbot - - app_path: natural_language_processing/summarizer - - app_path: natural_language_processing/codegen - - app_path: natural_language_processing/rag - - app_path: audio/audio_to_text steps: - uses: actions/checkout@v4.1.1 - - name: - working-directory: ./recipes/${{ matrix.app_path }} + - name: chatbot + working-directory: ./recipes/natural_language_processing/chatbot run: make bootc - name: Publish Job Results to Slack diff --git a/model_servers/llamacpp_python/Makefile b/model_servers/llamacpp_python/Makefile index 09ab49b6..05fc58db 100644 --- a/model_servers/llamacpp_python/Makefile +++ b/model_servers/llamacpp_python/Makefile @@ -1,9 +1,10 @@ APP := llamacpp_python +IMAGE_BASE := llamacpp-python PORT := 8001 -IMAGE := quay.io/ai-lab/$(APP):latest -CUDA_IMAGE := quay.io/ai-lab/$(APP)_cuda:latest -VULKAN_IMAGE := quay.io/ai-lab/$(APP)_vulkan:latest +IMAGE := quay.io/ai-lab/$(IMAGE_BASE):latest +CUDA_IMAGE := quay.io/ai-lab/$(IMAGE_BASE)-cuda:latest +VULKAN_IMAGE := quay.io/ai-lab/$(IMAGE_BASE)-vulkan:latest # ----- MODEL OPTIONS ----- @@ -43,7 +44,7 @@ build-cuda: .PHONY: build-vulkan build-vulkan: - podman build --squash-all -t $(VULKAN_IMAGE) . -f cuda/Containerfile + podman build --squash-all -t $(VULKAN_IMAGE) . -f vulkan/Containerfile .PHONY: download-model-tiny-llama download-model-tiny-llama: @@ -67,6 +68,17 @@ run: cd ../../models && \ podman run -it -d -p $(PORT):$(PORT) -v ./$(SELECTED_MODEL_NAME):$(MODELS_PATH)/model.gguf:$(BIND_MOUNT_OPTIONS) -e MODEL_PATH=$(MODELS_PATH)/model.gguf -e HOST=0.0.0.0 -e PORT=$(PORT) $(IMAGE) +# TODO: Add tests for llamacpp-cuda +# This never fails, placeholder for future test +.PHONY: run-cuda +run-cuda: + cd ../../models && \ + podman run -it -d -p $(PORT):$(PORT) -v ./$(SELECTED_MODEL_NAME):$(MODELS_PATH)/model.gguf:$(BIND_MOUNT_OPTIONS) -e MODEL_PATH=$(MODELS_PATH)/model.gguf -e HOST=0.0.0.0 -e PORT=$(PORT) --net=host --device nvidia.com/gpu=all $(IMAGE) || true + +# TODO: Add tests for llamacpp-cuda +.PHONY: test-cuda +test-cuda: run-cuda + .PHONY: test test: curl -H "Cache-Control: no-cache" -s -S -L -f $(SELECTED_MODEL_URL) -z ./model.gguf -o ./model.gguf.tmp && mv -f ./model.gguf.tmp ./model.gguf 2>/dev/null || rm -f ./model.gguf.tmp ./model.gguf diff --git a/model_servers/llamacpp_python/tests/conftest.py b/model_servers/llamacpp_python/tests/conftest.py index 380262b1..55ee11a8 100644 --- a/model_servers/llamacpp_python/tests/conftest.py +++ b/model_servers/llamacpp_python/tests/conftest.py @@ -1,6 +1,7 @@ import pytest_container import os +# For cuda, will add this to below Container: extra_launch_args=["--device", "nvidia.com/gpu=all"], MS = pytest_container.Container( url=f"containers-storage:{os.environ['REGISTRY']}/containers/{os.environ['IMAGE_NAME']}", volume_mounts=[ diff --git a/model_servers/llamacpp_python/tests/test_alive.py b/model_servers/llamacpp_python/tests/test_alive.py index fcad510a..226aac1c 100644 --- a/model_servers/llamacpp_python/tests/test_alive.py +++ b/model_servers/llamacpp_python/tests/test_alive.py @@ -4,7 +4,6 @@ CONTAINER_IMAGES = [MS] - def test_etc_os_release_present(auto_container: pytest_container.container.ContainerData): assert auto_container.connection.file("/etc/os-release").exists