Skip to content

Commit

Permalink
fixing chatbot tests, chatbot makefile and common makefile
Browse files Browse the repository at this point in the history
Signed-off-by: greg pereira <[email protected]>
  • Loading branch information
Gregory-Pereira committed Apr 9, 2024
1 parent 4bb793b commit 2b08204
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/chatbot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ jobs:
working-directory: ./recipes/natural_language_processing/chatbot
run: make install

- name: Download model
working-directory: ./model_servers/${{ matrix.image_name }}/
run: make download-model-mistral

- name: Run Functional Tests
working-directory: ./recipes/natural_language_processing/chatbot
run: make functional-tests
Expand Down
15 changes: 14 additions & 1 deletion recipes/common/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,18 @@ run:

.PHONY: clean
clean:
rm -rf build
-rm -rf build
-rm -rf tests/__pycache__
-rm ./$(MODEL_NAME) &> /dev/null

.PHONY: check-model-in-path
check-model-in-path:
if [ ! -f "../../../models/$(MODEL_NAME)" ]; then \
echo "Model file -- $(MODEL_NAME) -- not present in the models directory."; \
exit 1; \
else \
if [ ! -f "./$(MODEL_NAME)" ]; then \
ln -s ../../../models/$(MODEL_NAME) ./$(MODEL_NAME); \
fi; \
fi;
exit 0
12 changes: 10 additions & 2 deletions recipes/natural_language_processing/chatbot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ PORT ?= 8501
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

.PHONY: download-model-mistral
download-model-llama:
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:
Expand All @@ -12,6 +20,7 @@ install:

.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} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver tests/functional; \
elif [[ -n "$(CHROMEDRIVER_EXISTS)" ]] && [[ -z "$(LOCAL_CHROMEDRIVER_EXISTS)" ]]; then \
Expand All @@ -31,6 +40,5 @@ integration-tests:
else \
echo "fetching chromedriver"; \
make install; \
URL=${URL} IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_EXISTS) tests/integration
URL=${URL} IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_EXISTS) tests/integration; \
fi;

Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import pytest_container
import os
import logging

REGISTRY=os.environ['REGISTRY']
IMAGE_NAME=os.environ['IMAGE_NAME']
MODEL_NAME=os.environ['MODEL_NAME']

logging.info("""
Starting pytest with the following ENV vars:
REGISTRY: {REGISTRY}
IMAGE_NAME: {IMAGE_NAME}
MODEL_NAME: {MODEL_NAME}
For:
model_server: whispercpp
""".format(REGISTRY=REGISTRY, IMAGE_NAME=IMAGE_NAME, MODEL_NAME=MODEL_NAME))


MS = pytest_container.Container(
url=f"containers-storage:{os.environ['REGISTRY']}/llamacpp_python",
url=f"containers-storage:{REGISTRY}/{IMAGE_NAME}",
volume_mounts=[
pytest_container.container.BindMount(
container_path="/locallm/models",
host_path="./",
container_path=f"/locallm/models/${MODEL_NAME}",
host_path=f"./{MODEL_NAME}",
flags=["ro"]
)
],
extra_environment_variables={
"MODEL_PATH": "models/mistral-7b-instruct-v0.1.Q4_K_M.gguf",
"MODEL_PATH": f"/locall/models/{MODEL_NAME}",
"HOST": "0.0.0.0",
"PORT": "8001"
},
Expand All @@ -22,7 +36,7 @@
host_port=8001
)
],
extra_launch_args=["--net=host"]
extra_launch_args=["--network=host"]
)

CB = pytest_container.Container(
Expand Down

0 comments on commit 2b08204

Please sign in to comment.