-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
111 additions
and
4 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 registry.access.redhat.com/ubi9/python-311:1-52 | ||
|
||
USER root | ||
|
||
COPY playground/tests/requirements.txt . | ||
|
||
RUN pip3 install -r requirements.txt && \ | ||
dnf install -y podman buildah && \ | ||
dnf clean all |
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,8 @@ | ||
{ | ||
"name": "ai_recepies", | ||
"build": { | ||
"dockerfile": "Containerfile", | ||
"context": ".." | ||
}, | ||
"privileged": true | ||
} |
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,50 @@ | ||
name: playground | ||
|
||
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: ./playground/Containerfile | ||
context: playground | ||
|
||
- name: Set up Python | ||
uses: actions/[email protected] | ||
|
||
- run: pip install -r playground/tests/requirements.txt | ||
|
||
- name: Run tests | ||
run: pytest |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
FROM registry.access.redhat.com/ubi9/python-39:latest | ||
FROM registry.access.redhat.com/ubi9/python-311:1-52 | ||
WORKDIR /locallm | ||
COPY requirements.txt /locallm/requirements.txt | ||
RUN pip install --upgrade pip | ||
RUN pip install --no-cache-dir --upgrade -r /locallm/requirements.txt | ||
RUN pip install --no-cache-dir --verbose -r /locallm/requirements.txt | ||
COPY run.sh run.sh | ||
EXPOSE 8001 | ||
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,3 @@ | ||
.PHONY: build | ||
build: | ||
buildah bud -f Containerfile --no-cache -t 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
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 |
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,22 @@ | ||
import pytest_container | ||
import os | ||
import requests | ||
import pytest | ||
|
||
|
||
def pytest_generate_tests(metafunc): | ||
pytest_container.auto_container_parametrize(metafunc) | ||
|
||
@pytest.fixture() | ||
def download_model(): | ||
url = 'https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q5_K_S.gguf' | ||
r = requests.get(url) | ||
with open('locallm/models/llama-2-7b-chat.Q5_K_S.gguf', 'wb') as f: | ||
f.write(r.content) | ||
|
||
@pytest.fixture() | ||
def run_container(download_model): | ||
pytest_container.Container( | ||
url=f"containers-storage:{os.environ['REGISTRY']}/{os.environ['IMAGE_NAME']}", | ||
forwarded_ports=[pytest_container.PortForwarding(container_port=8001,host_port=8001)] | ||
) |
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,5 @@ | ||
pip==24.0 | ||
pytest-container==0.3.0 | ||
pytest-testinfra==10.1.0 | ||
pytest==8.1.1 | ||
requests==2.31.0 |
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 @@ | ||
import pytest_container | ||
from .conftest import run_container | ||
|
||
CONTAINER_IMAGES = [] | ||
|
||
def test_alive(auto_container: pytest_container.container.ContainerData, host, run_container): | ||
global CONTAINER_IMAGES | ||
CONTAINER_IMAGES.append(run_container()) | ||
res = host.run_expect([0],f"curl localhost:{auto_container.forwarded_ports[0].host_port}",).stdout.strip() |