Skip to content

Commit

Permalink
Spin Model Server in chatbot recipe
Browse files Browse the repository at this point in the history
Signed-off-by: Liora Milbaum <[email protected]>
  • Loading branch information
lmilbaum committed Mar 31, 2024
1 parent 36c6389 commit e72be5b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 13 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/chatbot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ on:
pull_request:
branches:
- main
paths:
- ./recipes/natural_language_processing/chatbot/**
- .github/workflows/chatbot.yaml
push:
branches:
- main
paths:
- ./recipes/natural_language_processing/chatbot/**
- .github/workflows/chatbot.yaml

env:
REGISTRY: ghcr.io
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/model_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ on:
pull_request:
branches:
- main
paths:
- ./model_servers/llamacpp_python/**
- .github/workflows/model_servers.yaml
push:
branches:
- main
paths:
- ./model_servers/llamacpp_python/**
- .github/workflows/model_servers.yaml

env:
REGISTRY: ghcr.io
Expand Down
3 changes: 2 additions & 1 deletion recipes/natural_language_processing/chatbot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ quadlet:
.PHONY: install
install:
pip install -r tests/requirements-test.txt
sudo snap install firefox

.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
pytest --driver Firefox
29 changes: 29 additions & 0 deletions recipes/natural_language_processing/chatbot/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
import pytest_container
import os
import pytest


MS = pytest_container.Container(
url=f"containers-storage:{os.environ['REGISTRY']}/model_servers",
volume_mounts=[
pytest_container.container.BindMount(
container_path="/locallm/models",
host_path="./",
flags=["ro"]
)
],
extra_environment_variables={
"MODEL_PATH": "models/mistral-7b-instruct-v0.1.Q4_K_M.gguf",
"HOST": "0.0.0.0",
"PORT": "8001"
},
forwarded_ports=[
pytest_container.PortForwarding(
container_port=8001,
host_port=8001
)
],
extra_launch_args=["--net=host"]
)

CB = pytest_container.Container(
url=f"containers-storage:{os.environ['REGISTRY']}/{os.environ['IMAGE_NAME']}",
extra_environment_variables={
Expand All @@ -21,3 +45,8 @@ def pytest_generate_tests(metafunc):

def pytest_addoption(parser):
pytest_container.add_logging_level_options(parser)

@pytest.fixture
def firefox_options(firefox_options):
firefox_options.headless = True
return firefox_options
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ def test_etc_os_release_present(auto_container: pytest_container.container.Conta
@tenacity.retry(stop=tenacity.stop_after_attempt(5), wait=tenacity.wait_exponential())
def test_alive(auto_container: pytest_container.container.ContainerData, host):
host.run_expect([0],f"curl http://localhost:{auto_container.forwarded_ports[0].host_port}",).stdout.strip()

@tenacity.retry(stop=tenacity.stop_after_attempt(5), wait=tenacity.wait_exponential())
def test_ui(auto_container: pytest_container.container.ContainerData, selenium):
selenium.get("http://localhost:{auto_container.forwarded_ports[0].host_port}")
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pip==24.0
pytest-container==0.4.0
pytest-selenium==4.1.0
pytest-testinfra==10.1.0
pytest==8.1.1
requests==2.31.0
Expand Down

0 comments on commit e72be5b

Please sign in to comment.