Skip to content

Commit 27887b9

Browse files
committed
Refactor web-app structure and add chart and CI tests
1 parent ad11e2c commit 27887b9

24 files changed

+379
-266
lines changed
Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Adapted from https://github.com/stackhpc/azimuth/blob/master/.github/workflows/build-push-artifacts.yaml
22
name: Publish artifacts
33
# Run the tasks on every push
4-
# TODO: Add path filtering to only run on relevant changes
54
on: push
65
jobs:
76
# Job to run change detection
@@ -24,9 +23,10 @@ jobs:
2423
id: filter
2524
with:
2625
base: ${{ github.ref_name }}
26+
# TODO: Make image filters more granular
2727
filters: |
2828
images:
29-
- 'images/**'
29+
- 'web-apps/**'
3030
chart:
3131
- 'chart/**'
3232
@@ -35,12 +35,11 @@ jobs:
3535
name: Build and push images
3636
runs-on: ubuntu-latest
3737
needs: changes
38-
if: ${{ needs.changes.outputs.images == 'true' || github.ref_type == 'tag' }}
38+
# if: ${{ needs.changes.outputs.images == 'true' || github.ref_type == 'tag' }}
3939
strategy:
4040
matrix:
4141
include:
42-
# - component: api
43-
- component: ui
42+
- component: chat-interface
4443
steps:
4544
- name: Check out the repository
4645
uses: actions/checkout@v4
@@ -56,46 +55,45 @@ jobs:
5655
id: image-meta
5756
uses: docker/metadata-action@v5
5857
with:
59-
images: ghcr.io/stackhpc/azimuth-llm-${{ matrix.component }}-base
58+
images: ghcr.io/stackhpc/azimuth-llm-${{ matrix.component }}
6059
# Produce the branch name or tag and the SHA as tags
6160
tags: |
6261
type=ref,event=branch
6362
type=ref,event=tag
6463
type=sha,prefix=
6564
6665
- name: Build and push image
67-
uses: stackhpc/github-actions/docker-multiarch-build-push@allow-continue-after-scan
66+
uses: azimuth-cloud/github-actions/docker-multiarch-build-push@update-trivy-action
6867
with:
69-
cache-key: ${{ matrix.component }}-base
70-
context: ./images/${{ matrix.component }}-base
68+
cache-key: ${{ matrix.component }}
69+
context: ./web-apps/${{ matrix.component }}
7170
platforms: linux/amd64,linux/arm64
7271
push: true
7372
tags: ${{ steps.image-meta.outputs.tags }}
7473
labels: ${{ steps.image-meta.outputs.labels }}
75-
fail_on_high_severity_cve: false
7674

77-
# Job to build and publish Helm chart
78-
build_push_chart:
79-
name: Build and push Helm chart
80-
runs-on: ubuntu-latest
81-
# Only build and push the chart if chart files have changed
82-
needs: [changes]
83-
if: ${{ needs.changes.outputs.chart == 'true' || github.ref_type == 'tag' }}
84-
steps:
85-
- name: Check out the repository
86-
uses: actions/checkout@v4
87-
with:
88-
# This is important for the semver action to work correctly
89-
# when determining the number of commits since the last tag
90-
fetch-depth: 0
75+
# # Job to build and publish Helm chart
76+
# build_push_chart:
77+
# name: Build and push Helm chart
78+
# runs-on: ubuntu-latest
79+
# # Only build and push the chart if chart files have changed
80+
# needs: [changes]
81+
# if: ${{ needs.changes.outputs.chart == 'true' || github.ref_type == 'tag' }}
82+
# steps:
83+
# - name: Check out the repository
84+
# uses: actions/checkout@v4
85+
# with:
86+
# # This is important for the semver action to work correctly
87+
# # when determining the number of commits since the last tag
88+
# fetch-depth: 0
9189

92-
- name: Get SemVer version for current commit
93-
id: semver
94-
uses: stackhpc/github-actions/semver@master
90+
# - name: Get SemVer version for current commit
91+
# id: semver
92+
# uses: azimuth-cloud/github-actions/semver@master
9593

96-
- name: Publish Helm charts
97-
uses: stackhpc/github-actions/helm-publish@master
98-
with:
99-
token: ${{ secrets.GITHUB_TOKEN }}
100-
version: ${{ steps.semver.outputs.version }}
101-
app-version: ${{ steps.semver.outputs.short-sha }}
94+
# - name: Publish Helm charts
95+
# uses: azimuth-cloud/github-actions/helm-publish@master
96+
# with:
97+
# token: ${{ secrets.GITHUB_TOKEN }}
98+
# version: ${{ steps.semver.outputs.version }}
99+
# app-version: ${{ steps.semver.outputs.short-sha }}

.github/workflows/test-pr.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test pull request
2+
on:
3+
pull_request:
4+
jobs:
5+
chart_validation:
6+
runs-on: ubuntu-latest
7+
env:
8+
CLUSTER_NAME: chart-testing
9+
RELEASE_NAME: ci-test
10+
steps:
11+
- name: Checkout the repo
12+
uses: actions/checkout@v4
13+
14+
- name: Install Helm
15+
uses: azure/setup-helm@v4
16+
17+
- name: Set up chart testing
18+
uses: helm/chart-testing-action@v2
19+
20+
- name: Run chart linting
21+
run: ct lint --config ct.yaml
22+
23+
- name: Run helm template with default values
24+
run: helm template ci-test .
25+
working-directory: chart
26+
27+
- name: Build all web app images
28+
run: ./build.sh
29+
working-directory: web-apps
30+
31+
- name: Create Kind Cluster
32+
uses: helm/kind-action@v1
33+
with:
34+
cluster-name: ${{ env.CLUSTER_NAME }}
35+
36+
- name: Load local docker images into kind cluster
37+
run: |
38+
IMAGE_NAMES=$(docker image ls | grep ghcr.io/stackhpc/azimuth-llm- | awk '{print $1}')
39+
kind load docker-image $IMAGE_NAMES -n ${{ env.CLUSTER_NAME }}
40+
41+
- name: Add Helm repos for dependencies
42+
run: |
43+
helm repo add stakater https://stakater.github.io/stakater-charts
44+
45+
# https://github.com/helm/charts/blob/master/test/README.md#providing-custom-test-values
46+
# Each chart/ci/*-values.yaml file will be treated as a separate test case with it's
47+
# own helm install/test process.
48+
- name: Run chart install and test
49+
run: ct install --config ct.yaml
50+

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ __pycache__/
88

99
# Ignore local dev helpers
1010
test-values.y[a]ml
11-
chart/web-app/settings.yml
12-
gradio-client-test.py
1311
**venv*/
1412

15-
1613
# Helm chart stuff
1714
chart/Chart.lock
18-
chart/charts
15+
chart/charts

chart/.helmignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ venv/
3030
__pycache__/
3131
images/
3232
.hf-token.secret
33-
hu-poc/
3433
test-values.yaml
3534
web-app/settings.yml
36-
web-app/example-settings.yml
35+
web-app/example-settings.yml
36+
ci/

chart/Chart.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
apiVersion: v2
22
name: azimuth-llm
33
description: HuggingFace LLM model serving along with a simple web interface.
4+
maintainers:
5+
- name: "Scott Davidson"
6+
7+
url: https://github.com/sd109
48

59
# A chart can be either an 'application' or a 'library' chart.
610
#
@@ -32,4 +36,4 @@ dependencies:
3236
- name: reloader
3337
version: 1.0.63
3438
repository: https://stakater.github.io/stakater-charts
35-
condition: ui.enabled
39+
condition: ui.enabled

chart/ci/web-apps-only-values.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
api:
2+
enabled: false
3+
ui:
4+
image:
5+
repository: ghcr.io/stackhpc/azimuth-llm-chat-interface
6+
tag: latest
7+
imagePullPolicy: Never
8+
service:
9+
zenith:
10+
enabled: false
11+
appSettings:
12+
hf_model_name: AMead10/c4ai-command-r-08-2024-awq
13+
backend_url: https://llm3-compute.cms.hu-berlin.de
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- if .Values.api.enabled -}}
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: gradio-client-response
6+
annotations:
7+
"helm.sh/hook": test
8+
spec:
9+
template:
10+
spec:
11+
containers:
12+
- name: gradio-client-test
13+
image: ghcr.io/stackhpc/azimuth-llm-chat-interface
14+
imagePullPolicy: IfNotPresent
15+
command:
16+
- python
17+
- gradio-client-test.py
18+
- http://{{ .Values.ui.service.name }}.{{ .Release.Namespace }}.svc
19+
restartPolicy: Never
20+
# Allow plenty of retries since downloading
21+
# model weights can take a long time.
22+
backoffLimit: 10
23+
{{- end -}}

chart/templates/test/web-app.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if not .Values.api.enabled -}}
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: web-app-liveness
6+
annotations:
7+
"helm.sh/hook": test
8+
spec:
9+
template:
10+
spec:
11+
containers:
12+
- name: web-app-test
13+
image: nicolaka/netshoot:v0.12
14+
imagePullPolicy: IfNotPresent
15+
command:
16+
- nc
17+
- -vz
18+
- {{ .Values.ui.service.name }}.{{ .Release.Namespace }}.svc
19+
- "80"
20+
restartPolicy: Never
21+
backoffLimit: 3
22+
{{- end -}}

chart/templates/ui/app-config-map.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ metadata:
66
labels:
77
{{- include "azimuth-llm.labels" . | nindent 4 }}
88
data:
9-
{{ (.Files.Glob "web-app/*").AsConfig | nindent 2 }}
10-
settings.yml: |
9+
overrides.yml: |
1110
{{- .Values.ui.appSettings | toYaml | nindent 4 }}
12-
{{- end -}}
11+
{{- end -}}

chart/templates/ui/deployment.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,20 @@ spec:
2323
containers:
2424
- name: {{ .Release.Name }}-ui
2525
image: {{ printf "%s:%s" .Values.ui.image.repository .Values.ui.image.version }}
26+
imagePullPolicy: {{ .Values.ui.image.imagePullPolicy }}
2627
ports:
2728
- name: ui
28-
containerPort: 7680
29-
workingDir: /etc/web-app
29+
containerPort: 7860
3030
volumeMounts:
3131
- name: app
3232
mountPath: /etc/web-app
33-
command:
34-
- python
35-
args:
36-
- {{ .Values.ui.entrypoint }}
37-
- {{ .Values.huggingface.model }}
3833
env:
3934
- name: PYTHONUNBUFFERED
4035
value: "1"
4136
tty: true # Make stdout from python visible in k8s logs
4237
readinessProbe:
4338
tcpSocket:
44-
port: 7680
39+
port: 7860
4540
periodSeconds: 5
4641
volumes:
4742
- name: app

0 commit comments

Comments
 (0)