forked from containers/podman-desktop-extension-ai-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request containers#96 from lmilbaum/playground-tests
playground tests
- Loading branch information
Showing
13 changed files
with
171 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM quay.io/containers/podman:v4.9.3 | ||
|
||
USER root | ||
|
||
COPY model_servers/llamacpp_python/base/tests/requirements.txt . | ||
|
||
RUN dnf install -y python3.11 python3-pip buildah git && \ | ||
dnf clean all && \ | ||
pip3 install -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "recipes", | ||
"build": { | ||
"dockerfile": "Containerfile", | ||
"context": ".." | ||
}, | ||
"privileged": true, | ||
"containerEnv": { | ||
"REGISTRY": "ghcr.io", | ||
"IMAGE_NAME": "ai-lab-recipes/playground" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: llamacpp_python | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository_owner }}/playground | ||
|
||
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/[email protected] | ||
|
||
- name: Login to ghcr | ||
uses: docker/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Buildah Action | ||
uses: redhat-actions/[email protected] | ||
with: | ||
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: latest | ||
containerfiles: ./model_servers/llamacpp_python/base/Containerfile | ||
context: model_servers/llamacpp_python/ | ||
|
||
- name: Set up Python | ||
uses: actions/[email protected] | ||
|
||
- name: Run tests | ||
run: make -f model_servers/llamacpp_python/base/Makefile test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.gguf | ||
*.bin | ||
*_pycache_* | ||
port_check.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
FROM registry.access.redhat.com/ubi9/python-39:latest | ||
FROM registry.access.redhat.com/ubi9/python-311:1-52 | ||
WORKDIR /locallm | ||
COPY src . | ||
RUN pip install --upgrade pip | ||
RUN pip install --no-cache-dir --upgrade -r /locallm/requirements.txt | ||
RUN pip install --no-cache-dir --verbose -r ./requirements.txt | ||
EXPOSE 8001 | ||
ENTRYPOINT [ "sh", "run.sh" ] | ||
ENTRYPOINT [ "sh", "./run.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.PHONY: build | ||
build: | ||
podman build -f Containerfile -t ghcr.io/ai-lab-recipes/playground --format docker . | ||
|
||
models/llama-2-7b-chat.Q5_K_S.gguf: | ||
curl -s -S -L -f https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q5_K_S.gguf -z $@ -o $@.tmp && mv -f $@.tmp $@ 2>/dev/null || rm -f $@.tmp $@ | ||
|
||
.PHONY: install | ||
install: | ||
pip install -r model_servers/llamacpp_python/base/tests/requirements.txt | ||
|
||
.PHONY: run | ||
run: models/llama-2-7b-chat.Q5_K_S.gguf install | ||
podman run -it -d -p 8001:8001 -v ./models:/locallm/models:ro,Z -e MODEL_PATH=models/llama-2-7b-chat.Q5_K_S.gguf -e HOST=0.0.0.0 -e PORT=8001 --net=host ghcr.io/redhat-et/playground | ||
|
||
.PHONY: test | ||
test: models/llama-2-7b-chat.Q5_K_S.gguf install | ||
pytest --log-cli-level NOTSET |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pytest_container | ||
import os | ||
|
||
|
||
MS = pytest_container.Container( | ||
url=f"containers-storage:{os.environ['REGISTRY']}/{os.environ['IMAGE_NAME']}", | ||
volume_mounts=[ | ||
pytest_container.container.BindMount( | ||
container_path="/locallm/models", | ||
host_path="./models", | ||
flags=["ro"] | ||
) | ||
], | ||
extra_environment_variables={ | ||
"MODEL_PATH": "models/llama-2-7b-chat.Q5_K_S.gguf", | ||
"HOST": "0.0.0.0", | ||
"PORT": "8001" | ||
}, | ||
forwarded_ports=[ | ||
pytest_container.PortForwarding( | ||
container_port=8001, | ||
host_port=8001 | ||
) | ||
], | ||
extra_launch_args=["--net=host"] | ||
) | ||
|
||
def pytest_generate_tests(metafunc): | ||
pytest_container.auto_container_parametrize(metafunc) | ||
|
||
def pytest_addoption(parser): | ||
pytest_container.add_logging_level_options(parser) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pip==24.0 | ||
pytest-container==0.4.0 | ||
pytest-testinfra==10.1.0 | ||
pytest==8.1.1 | ||
requests==2.31.0 | ||
tenacity==8.2.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest_container | ||
from .conftest import MS | ||
import tenacity | ||
|
||
CONTAINER_IMAGES = [MS] | ||
|
||
|
||
def test_etc_os_release_present(auto_container: pytest_container.container.ContainerData): | ||
assert auto_container.connection.file("/etc/os-release").exists | ||
|
||
@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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
llama-cpp-python[server] | ||
llama-cpp-python[server]==0.2.57 | ||
pip==24.0 |