From e81174ea705fe125e8d79539bb5ba434faeed756 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 8 Apr 2024 08:11:51 -0400 Subject: [PATCH] Add common Makefile to share between recipes Signed-off-by: Daniel J Walsh --- recipes/common/Makefile.common | 57 +++++++++++++++++++ .../chatbot/Makefile | 54 +----------------- .../natural_language_processing/rag/Makefile | 49 +--------------- .../summarizer/Makefile | 50 +--------------- 4 files changed, 60 insertions(+), 150 deletions(-) create mode 100644 recipes/common/Makefile.common diff --git a/recipes/common/Makefile.common b/recipes/common/Makefile.common new file mode 100644 index 000000000..c184c1ec4 --- /dev/null +++ b/recipes/common/Makefile.common @@ -0,0 +1,57 @@ +CHROMADBIMAGE ?= quay.io/ai-lab/chromadb:latest +MODELIMAGE ?= quay.io/ai-lab/mistral-7b-instruct:latest +APPIMAGE ?= quay.io/ai-lab/${APP}:latest +SERVERIMAGE ?= quay.io/ai-lab/llamacpp-python:latest +SSHPUBKEY ?= $(shell cat ${HOME}/.ssh/id_rsa.pub;) +BOOTCIMAGE ?= quay.io/ai-lab/${APP}-bootc:latest +FROM ?= + +.PHONY: build +build: + podman build -f builds/Containerfile -t ${APPIMAGE} . + +.PHONY: bootc +bootc: quadlet + podman build $${FROM:+--from $${FROM}} --cap-add SYS_ADMIN --build-arg "SSHPUBKEY=$(SSHPUBKEY)" -f bootc/Containerfile -t ${BOOTCIMAGE} . + +.PHONY: quadlet +quadlet: + # Modify quadlet files to match the server, model and app image + mkdir -p build + sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \ + -e "s|APPIMAGE|${APPIMAGE}|g" \ + -e "s|MODELIMAGE|${MODELIMAGE}|g" \ + -e "s|CHROMADBIMAGE|${CHROMADBIMAGE}|g" \ + quadlet/${APP}.image \ + > build/${APP}.image + sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \ + -e "s|APPIMAGE|${APPIMAGE}|g" \ + -e "s|MODELIMAGE|${MODELIMAGE}|g" \ + -e "s|CHROMADBIMAGE|${CHROMADBIMAGE}|g" \ + quadlet/${APP}.yaml \ + > build/${APP}.yaml + cp quadlet/${APP}.kube build/${APP}.kube + +.PHONY: install +install: + wget https://www.slimjetbrowser.com/chrome/files/103.0.5060.53/google-chrome-stable_current_amd64.deb + sudo dpkg -i google-chrome-stable_current_amd64.deb + wget https://chromedriver.storage.googleapis.com/103.0.5060.53/chromedriver_linux64.zip + unzip chromedriver_linux64.zip + pip install -r tests/requirements.txt + +.PHONY: run +run: + podman run -it -p 8501:8501 -e MODEL_SERVICE_ENDPOINT=http://10.88.0.1:8001/v1 ${APPIMAGE} + +.PHONY: functional_tests +functional_tests: + python3 -m pytest -vvv --driver=Chrome --driver-path=./chromedriver tests/functional + +.PHONY: integration_test +integration_tests: + URL=${URL} python3 -m pytest -vvv --driver=Chrome --driver-path=./chromedriver tests/integration + +.PHONY: clean +clean: + rm -rf build diff --git a/recipes/natural_language_processing/chatbot/Makefile b/recipes/natural_language_processing/chatbot/Makefile index 44926b822..d25e95f55 100644 --- a/recipes/natural_language_processing/chatbot/Makefile +++ b/recipes/natural_language_processing/chatbot/Makefile @@ -1,55 +1,3 @@ APP ?= chatbot -MODELIMAGE ?= quay.io/ai-lab/mistral-7b-instruct:latest -APPIMAGE ?= quay.io/ai-lab/${APP}:latest -SERVERIMAGE ?= quay.io/ai-lab/llamacpp-python:latest -SSHPUBKEY ?= $(shell cat ${HOME}/.ssh/id_rsa.pub;) -BOOTCIMAGE ?= quay.io/ai-lab/${APP}-bootc:latest -FROM ?= -.PHONY: build -build: - podman build -f builds/Containerfile -t ${APPIMAGE} . - -.PHONY: bootc -bootc: quadlet - podman build $${FROM:+--from $${FROM}} --cap-add SYS_ADMIN --build-arg "SSHPUBKEY=$(SSHPUBKEY)" -f bootc/Containerfile -t ${BOOTCIMAGE} . - -.PHONY: quadlet -quadlet: - # Modify quadlet files to match the server, model and app image - mkdir -p build - sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \ - -e "s|APPIMAGE|${APPIMAGE}|g" \ - -e "s|MODELIMAGE|${MODELIMAGE}|g" \ - quadlet/${APP}.image \ - > build/${APP}.image - sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \ - -e "s|APPIMAGE|${APPIMAGE}|g" \ - -e "s|MODELIMAGE|${MODELIMAGE}|g" \ - quadlet/${APP}.yaml \ - > build/${APP}.yaml - cp quadlet/${APP}.kube build/${APP}.kube - -.PHONY: install -install: - wget https://www.slimjetbrowser.com/chrome/files/103.0.5060.53/google-chrome-stable_current_amd64.deb - sudo dpkg -i google-chrome-stable_current_amd64.deb - wget https://chromedriver.storage.googleapis.com/103.0.5060.53/chromedriver_linux64.zip - unzip chromedriver_linux64.zip - pip install -r tests/requirements.txt - -.PHONY: run -run: - podman run -it -p 8501:8501 -e MODEL_SERVICE_ENDPOINT=http://10.88.0.1:8001/v1 ghcr.io/ai-lab-recipes/${APP} - -.PHONY: functional_tests -functional_tests: - python3 -m pytest -vvv --driver=Chrome --driver-path=./chromedriver tests/functional - -.PHONY: integration_test -integration_tests: - URL=${URL} python3 -m pytest -vvv --driver=Chrome --driver-path=./chromedriver tests/integration - -.PHONY: clean -clean: - rm -rf build +include ../../common/Makefile.common diff --git a/recipes/natural_language_processing/rag/Makefile b/recipes/natural_language_processing/rag/Makefile index 3faa4cff5..3a8c2c6fb 100644 --- a/recipes/natural_language_processing/rag/Makefile +++ b/recipes/natural_language_processing/rag/Makefile @@ -1,50 +1,3 @@ APP=rag -CHROMADBIMAGE ?= quay.io/ai-lab/chromadb:latest -MODELIMAGE ?= quay.io/ai-lab/mistral-7b-instruct:latest -APPIMAGE ?= quay.io/ai-lab/${APP}:latest -SERVERIMAGE ?= quay.io/ai-lab/llamacpp-python:latest -SSHPUBKEY ?= $(shell cat ${HOME}/.ssh/id_rsa.pub;) -BOOTCIMAGE ?= quay.io/ai-lab/${APP}-bootc:latest -FROM ?= -.PHONY: build -build: - podman build -f builds/Containerfile -t ${APPIMAGE} . - -.PHONY: bootc -bootc: quadlet - podman build $${FROM:+--from $${FROM}} --cap-add SYS_ADMIN --build-arg "SSHPUBKEY=$(SSHPUBKEY)" -f bootc/Containerfile -t ${BOOTCIMAGE} . - -.PHONY: quadlet -quadlet: - # Modify quadlet files to match the server, model and app image - mkdir -p build - sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \ - -e "s|APPIMAGE|${APPIMAGE}|g" \ - -e "s|MODELIMAGE|${MODELIMAGE}|g" \ - -e "s|CHROMADBIMAGE|${CHROMADBIMAGE}|g" \ - quadlet/${APP}.image \ - > build/${APP}.image - sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \ - -e "s|APPIMAGE|${APPIMAGE}|g" \ - -e "s|MODELIMAGE|${MODELIMAGE}|g" \ - -e "s|CHROMADBIMAGE|${CHROMADBIMAGE}|g" \ - quadlet/${APP}.yaml \ - > build/${APP}.yaml - cp quadlet/${APP}.kube build/${APP}.kube - -.PHONY: install -install: - pip install -r tests/requirements.txt - -.PHONY: run -run: - podman run -it -p 8501:8501 -e MODEL_SERVICE_ENDPOINT=http://10.88.0.1:8001/v1 ghcr.io/ai-lab-recipes/${APP} - -.PHONY: test -test: - pytest --log-cli-level NOTSET - -.PHONY: clean -clean: - rm -rf build +include ../../common/Makefile.common diff --git a/recipes/natural_language_processing/summarizer/Makefile b/recipes/natural_language_processing/summarizer/Makefile index 76f254e76..8e3ccf6b0 100644 --- a/recipes/natural_language_processing/summarizer/Makefile +++ b/recipes/natural_language_processing/summarizer/Makefile @@ -1,51 +1,3 @@ APP ?= summarizer -MODELIMAGE ?= quay.io/ai-lab/mistral-7b-instruct:latest -APPIMAGE ?= quay.io/ai-lab/${APP}:latest -SERVERIMAGE ?= quay.io/ai-lab/llamacpp-python:latest -SSHPUBKEY ?= $(shell cat ${HOME}/.ssh/id_rsa.pub;) -BOOTCIMAGE ?= quay.io/ai-lab/${APP}-bootc:latest -FROM ?= -.PHONY: build -build: - podman build -f builds/Containerfile -t ${APPIMAGE} . - -.PHONY: bootc -bootc: quadlet - podman build $${FROM:+--from $${FROM}} --cap-add SYS_ADMIN --build-arg "SSHPUBKEY=$(SSHPUBKEY)" -f bootc/Containerfile -t ${BOOTCIMAGE} . - -.PHONY: quadlet -quadlet: - # Modify quadlet files to match the server, model and app image - mkdir -p build - sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \ - -e "s|APPIMAGE|${APPIMAGE}|g" \ - -e "s|MODELIMAGE|${MODELIMAGE}|g" \ - quadlet/${APP}.image \ - > build/${APP}.image - sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \ - -e "s|APPIMAGE|${APPIMAGE}|g" \ - -e "s|MODELIMAGE|${MODELIMAGE}|g" \ - quadlet/${APP}.yaml \ - > build/${APP}.yaml - cp quadlet/${APP}.kube build/${APP}.kube - -.PHONY: install -install: - wget https://www.slimjetbrowser.com/chrome/files/103.0.5060.53/google-chrome-stable_current_amd64.deb - sudo dpkg -i google-chrome-stable_current_amd64.deb - wget https://chromedriver.storage.googleapis.com/103.0.5060.53/chromedriver_linux64.zip - unzip chromedriver_linux64.zip - pip install -r tests/requirements.txt - -.PHONY: run -run: - podman run -it -p 8501:8501 -e MODEL_SERVICE_ENDPOINT=http://10.88.0.1:8001/v1 ghcr.io/ai-lab-recipes/${APP} - -.PHONY: test -test: - python3 -m pytest -vvv --driver=Chrome --driver-path=./chromedriver tests - -.PHONY: clean -clean: - rm -rf build +include ../../common/Makefile.common