Skip to content
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
4 changes: 3 additions & 1 deletion helm-charts/local_dev_startup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
minikube start --cni=calico --cpus=no-limit --memory=no-limit
export MINIKUBE_HOME="$HOME/.minikube-${HOSTNAME}"
export KUBECONFIG="$HOME/.kube/config-${HOSTNAME}"
minikube start -p cogstack-platform --cni=calico --cpus=no-limit --memory=no-limit
minikube addons enable metrics-server

minikube dashboard --url=true &
Expand Down
1 change: 0 additions & 1 deletion helm-charts/medcat-service-helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Create a values file like `values-model-download.yaml` and set these values:
```yaml
model:
downloadUrl: "http://localhost:9000/models/my-model.zip"
name: my-model.zip
```

Use this if you prefer dynamic loading of models at runtime.
Expand Down
1 change: 0 additions & 1 deletion helm-charts/medcat-service-helm/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ Create a values file like `values-model-download.yaml` and set these values:
```yaml
model:
downloadUrl: "http://localhost:9000/models/my-model.zip"
name: my-model.zip
```

Use this if you prefer dynamic loading of models at runtime.
Expand Down
3 changes: 2 additions & 1 deletion helm-charts/medcat-service-helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ If release name contains chart name it will be used as a full name.
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- $basename := $name | trimSuffix "-helm" }}
{{- if or (contains $name .Release.Name) (eq .Release.Name $basename) }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
Expand Down
34 changes: 23 additions & 11 deletions helm-charts/medcat-service-helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ spec:
{{- tpl (toYaml $value) $ | nindent 14 }}
{{- end }}
{{- range $key, $value := .Values.env }}
{{- if ne $key "APP_MEDCAT_MODEL_PACK" }}
- name: "{{ tpl $key $ }}"
value: "{{ tpl (print $value) $ }}"
{{- end }}
{{- end }}
{{- if .Values.model.downloadUrl }}
# Note this overrides any previous env setting if downloading is enabled
- name: "APP_MEDCAT_MODEL_PACK"
value: "/models/{{ .Values.model.name}}"
value: '/models/{{ default "medcat-model.zip" .Values.model.name }}'
{{ else }}
- name: "APP_MEDCAT_MODEL_PACK"
value: {{ .Values.env.APP_MEDCAT_MODEL_PACK | quote }}
{{- end}}
{{- with .Values.livenessProbe }}
livenessProbe:
Expand Down Expand Up @@ -95,24 +99,32 @@ spec:
{{- end }}
{{- if .Values.model.downloadUrl }}
- name: model-downloader
image: busybox:1.28
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
command:
- sh
- -c
- |
echo "Downloading model $MODEL_NAME from $MODEL_PACK_URL"
set -e
echo "Downloading model to $APP_MEDCAT_MODEL_PACK from $MODEL_PACK_URL"
mkdir -p /models
wget -O "/models/$MODEL_NAME" "$MODEL_PACK_URL"
if [ $? -ne 0 ]; then
echo "Failed to download model from $MODEL_PACK_URL" >&2
exit 1
fi
python - <<'PY'
import os
import requests

url = os.environ["MODEL_PACK_URL"]
path = os.environ.get("APP_MEDCAT_MODEL_PACK")

r = requests.get(url, allow_redirects=True)
r.raise_for_status()
with open(path, "wb") as f:
f.write(r.content)
PY
echo "Download finished successfully"
env:
- name: MODEL_PACK_URL
value: {{ .Values.model.downloadUrl}}
- name: MODEL_NAME
value: {{ .Values.model.name}}
- name: APP_MEDCAT_MODEL_PACK
value: '/models/{{ default "medcat-model.zip" .Values.model.name }}'
volumeMounts:
- name: models
mountPath: /models
Expand Down
Loading