Skip to content

Commit

Permalink
add quadlet for code-generation app (#50)
Browse files Browse the repository at this point in the history
Signed-off-by: sallyom <somalley@redhat.com>
  • Loading branch information
sallyom committed Feb 16, 2024
1 parent 39dd04c commit 2b32133
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 2 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
MODEL_SERVICE_IMAGE: locallm-model-service
CHATBOT_IMAGE: locallm-chatbot
SUMMARIZER_IMAGE: locallm-text-summarizer
CODEGEN_IMAGE: locallm-codegen
RAG_IMAGE: locallm-rag
CHROMADB_IMAGE: locallm-chromadb
steps:
Expand Down Expand Up @@ -49,6 +50,13 @@ jobs:
files: |
summarizer-langchain/**
- name: Get changed code-generation files
id: changed-files-codegen
uses: tj-actions/changed-files@v42
with:
files: |
code-generation/**
- name: Get changed chatbot files
id: changed-files-chatbot
uses: tj-actions/changed-files@v42
Expand All @@ -64,14 +72,14 @@ jobs:
rag-langchain/builds/chromadb/**
- name: Install qemu dependency
if: steps.changed-files-model-service.outputs.any_changed == 'true' || steps.changed-files-chatbot.outputs.any_changed == 'true' || steps.changed-files-summarizer.outputs.any_changed == 'true' || steps.changed-files-rag.outputs.any_changed == 'true'
if: steps.changed-files-model-service.outputs.any_changed == 'true' || steps.changed-files-chatbot.outputs.any_changed == 'true' || steps.changed-files-summarizer.outputs.any_changed == 'true' || steps.changed-files-rag.outputs.any_changed == 'true' || steps.changed-files-codegen.outputs.any_changed == 'true'
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Login Quay Container registry
if: >
(steps.changed-files-model-service.outputs.any_changed == 'true' || steps.changed-files-chatbot.outputs.any_changed == 'true' || steps.changed-files-summarizer.outputs.any_changed == 'true' || steps.changed-files-rag.outputs.any_changed == 'true' || steps.changed-files-chromadb.outputs.any_changed == 'true') &&
(steps.changed-files-model-service.outputs.any_changed == 'true' || steps.changed-files-chatbot.outputs.any_changed == 'true' || steps.changed-files-summarizer.outputs.any_changed == 'true' || steps.changed-files-rag.outputs.any_changed == 'true' || steps.changed-files-chromadb.outputs.any_changed == 'true' || steps.changed-files-codegen.outputs.any_changed == 'true') &&
(github.event_name == 'push' || github.event_name == 'schedule') &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
uses: redhat-actions/podman-login@v1
Expand Down Expand Up @@ -127,6 +135,30 @@ jobs:
tags: ${{ steps.build_chatbot_multiplatform.outputs.tags }}
registry: ${{ env.REGISTRY }}

- name: Build code-generation
if: steps.changed-files-codegen.outputs.any_changed == 'true'
id: build_summarizer_multiplatform
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.CODEGEN_IMAGE }}
tags: latest ${{ github.sha }}
platforms: linux/amd64, linux/arm64
context: code-generation
containerfiles: |
./code-generation/builds/Containerfile
- name: Push code-generation image
id: push_codegen
if: >
(steps.changed-files-codegen.outputs.any_changed == 'true') &&
(github.event_name == 'push' || github.event_name == 'schedule') &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_codegen_multiplatform.outputs.image }}
tags: ${{ steps.build_codegen_multiplatform.outputs.tags }}
registry: ${{ env.REGISTRY }}

- name: Build summarizer
if: steps.changed-files-summarizer.outputs.any_changed == 'true'
id: build_summarizer_multiplatform
Expand Down
10 changes: 10 additions & 0 deletions code-generation/quadlet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Run code-generation as a systemd service

```bash
cp codegen.yaml /etc/containers/systemd/codegen.yaml
cp codegen.kube.example /etc/containers/codegen.kube
cp codegen.image /etc/containers/codegen.image
/usr/libexec/podman/quadlet --dryrun (optional)
systemctl daemon-reload
systemctl start codegen
```
7 changes: 7 additions & 0 deletions code-generation/quadlet/codegen.image
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Install]
WantedBy=codegen.service

[Image]
Image=quay.io/sallyom/models:mistral-7b-gguf
Image=quay.io/redhat-et/locallm-model-service:latest
Image=quay.io/redhat-et/locallm-codegen:latest
16 changes: 16 additions & 0 deletions code-generation/quadlet/codegen.kube.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Python script to run against downloaded LLM
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers

[Kube]
# Point to the yaml file in the same directory
Yaml=codegen.yaml

[Service]
Restart=always

[Install]
WantedBy=default.target
45 changes: 45 additions & 0 deletions code-generation/quadlet/codegen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: v1
kind: Pod
metadata:
labels:
app: codegen-langchain
name: codegen-langchain
spec:
initContainers:
- name: model-file
image: quay.io/sallyom/models:mistral-7b-gguf
command: ['/usr/bin/install', "/model/mistral-7b-instruct-v0.1.Q4_K_S.gguf", "/shared/"]
volumeMounts:
- name: model-file
mountPath: /shared
containers:
- env:
- name: MODEL_SERVICE_ENDPOINT
value: http://10.88.0.1:8001/v1
image: quay.io/redhat-et/locallm-codegen:latest
name: codegen-inference
ports:
- containerPort: 8501
hostPort: 8501
securityContext:
runAsNonRoot: true
- env:
- name: HOST
value: 0.0.0.0
- name: PORT
value: 8001
- name: MODEL_PATH
value: /model/mistral-7b-instruct-v0.1.Q4_K_S.gguf
image: quay.io/redhat-et/locallm-model-service:latest
name: codegen-model-service
ports:
- containerPort: 8001
hostPort: 8001
securityContext:
runAsNonRoot: true
volumeMounts:
- name: model-file
mountPath: /model
volumes:
- name: model-file
emptyDir: {}

0 comments on commit 2b32133

Please sign in to comment.