Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quadlet code generation #50

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {}