Skip to content

Commit f63c22d

Browse files
feat(helm): Cogstack CE to provision medcat trainer on startup (#50)
1 parent fbba616 commit f63c22d

10 files changed

Lines changed: 80 additions & 20 deletions

File tree

deployment/kubernetes/charts/cogstack-helm-ce/Chart.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ dependencies:
1414
- name: opensearch-dashboards
1515
repository: https://opensearch-project.github.io/helm-charts/
1616
version: 3.5.0
17-
- name: jupyterhub
17+
- name: cogstack-jupyterhub
1818
repository: file://charts/jupyterhub
1919
version: 0.1.0
20-
digest: sha256:0dbf6980653337af2efa16bb340d0a04dca9ed517bf4ab3c87044da348e8a84c
21-
generated: "2026-02-27T16:13:56.822297965Z"
20+
digest: sha256:d9fb8600b71642cbbdcfc0e9c4b512f3efedadf99544b3e81f97f0deb5a8469a
21+
generated: "2026-03-03T17:30:34.27108704Z"

deployment/kubernetes/charts/cogstack-helm-ce/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,14 @@ helm install cogstack oci://registry-1.docker.io/cogstacksystems/cogstack-helm-c
2424
```
2525

2626
## Configuration
27-
28-
Key values in `values.yaml`:
27+
These are some values that are likely to need customization for your deployment:
2928

3029
| Value | Default | Description |
3130
|-------|---------|-------------|
32-
| `imagePullSecrets` | `[]` | Secrets for pulling images from a private registry. |
33-
| `nameOverride` | `""` | Override the chart name used in resource names. |
34-
| `fullnameOverride` | `""` | Override the full name used in resource names. |
3531
| `medcat-service.replicasCount` | `1` | Number of MedCAT service replicas. |
3632
| `anoncat-service.replicasCount` | `1` | Number of AnonCAT service replicas. |
37-
| `anoncat-service.env.APP_ENABLE_DEMO_UI` | `true` | Enable AnonCAT demo UI. |
38-
| `anoncat-service.env.DEID_MODE` | `true` | Run AnonCAT in de-identification mode. |
3933
| `anoncat-service.env.DEID_REDACT` | `false` | Redaction behaviour for de-identification. |
34+
| `medcat-trainer.env.CSRF_TRUSTED_ORIGINS` | `"http://localhost:8080"` | CSRF trusted origins for MedCAT Trainer frontend (set correct value for your deployment, this default works for port forwarding). |
4035

4136
Subcharts (MedCAT service, AnonCAT service, MedCAT Trainer) support additional options; see their respective charts under `../medcat-service-helm` and `../medcat-trainer-helm`. Pass them under the same keys as in this chart’s `values.yaml` (e.g. `medcat-service.*`, `anoncat-service.*`, `medcat-trainer-helm.*`).
4237

deployment/kubernetes/charts/cogstack-helm-ce/templates/NOTES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kubectl --namespace {{ .Release.Namespace }} port-forward $MEDCAT_POD_NAME 5000:
1414
export TRAINER_POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name=medcat-trainer,app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
1515
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $TRAINER_POD_NAME -o jsonpath="{.spec.containers[?(@.name==\"nginx\")].ports[0].containerPort}")
1616
export CONTAINER_PORT_API=$(kubectl get pod --namespace {{ .Release.Namespace }} $TRAINER_POD_NAME -o jsonpath="{.spec.containers[?(@.name==\"medcat-trainer\")].ports[0].containerPort}")
17-
kubectl --namespace {{ .Release.Namespace }} port-forward $TRAINER_POD_NAME 8000:$CONTAINER_PORT 8001:$CONTAINER_PORT_API &
17+
kubectl --namespace {{ .Release.Namespace }} port-forward $TRAINER_POD_NAME 8080:$CONTAINER_PORT 8001:$CONTAINER_PORT_API &
1818

1919
{{- if .Values.opensearch.enabled }}
2020
# 4. Opensearch
@@ -38,7 +38,7 @@ kubectl --namespace {{ .Release.Namespace }} port-forward svc/$JUPYTERHUB_PROXY_
3838

3939
echo "Visit http://127.0.0.1:5000 to use MedCAT Service"
4040
echo "Visit http://127.0.0.1:5001 to use AnonCAT"
41-
echo "Visit http://127.0.0.1:8000 to use MedCAT Trainer"
41+
echo "Visit http://127.0.0.1:8080 to use MedCAT Trainer"
4242
{{ if .Values.opensearch.enabled }}echo "Visit https://127.0.0.1:9200 to use OpenSearch"{{- end }}
4343
{{ if index .Values "opensearch-dashboards" "enabled" }}echo "Visit http://127.0.0.1:5601 to use OpenSearch Dashboards"{{- end }}
4444
{{ if index .Values "cogstack-jupyterhub" "enabled" }}echo "Visit http://127.0.0.1:8000 to use jupyterhub"{{- end }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- if and (index .Values "medcat-trainer" "provisioning" "enabled") (eq (index .Values "medcat-trainer" "provisioning" "existingConfigMap" "name") "cogstack-helm-ce-example-trainer-provisioining") }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ index .Values "medcat-trainer" "provisioning" "existingConfigMap" "name" }}
6+
data:
7+
provisioning.yaml: |
8+
projects:
9+
- dataset:
10+
name: "Example Dataset - psych.csv"
11+
url: "https://raw.githubusercontent.com/CogStack/cogstack-nlp/be9825f151da2d3b6faac80d49e5be91a1629c68/medcat-trainer/notebook_docs/example_data/psych.csv"
12+
description: "Dataset from https://raw.githubusercontent.com/CogStack/cogstack-nlp/be9825f151da2d3b6faac80d49e5be91a1629c68/medcat-trainer/notebook_docs/example_data/psych.csv"
13+
project:
14+
name: "Example Project"
15+
description: "Example project for medcat trainer using MedCAT Service"
16+
annotationGuidelineLink: "https://docs.google.com/document/d/1xxelBOYbyVzJ7vLlztP2q1Kw9F5Vr1pRwblgrXPS7QM/edit?usp=sharing"
17+
useModelService: true
18+
modelServiceUrl: "http://{{ include "cogstack-helm-ce.fullname" . }}-medcat-service:5000"
19+
- dataset:
20+
name: "Example Dataset - psych.csv - deid"
21+
url: "https://raw.githubusercontent.com/CogStack/cogstack-nlp/be9825f151da2d3b6faac80d49e5be91a1629c68/medcat-trainer/notebook_docs/example_data/psych.csv"
22+
description: "Dataset from https://raw.githubusercontent.com/CogStack/cogstack-nlp/be9825f151da2d3b6faac80d49e5be91a1629c68/medcat-trainer/notebook_docs/example_data/psych.csv"
23+
project:
24+
name: "Example Deid project"
25+
description: "Example project for medcat trainer using AnonCAT Service"
26+
annotationGuidelineLink: "https://docs.google.com/document/d/1xxelBOYbyVzJ7vLlztP2q1Kw9F5Vr1pRwblgrXPS7QM/edit?usp=sharing"
27+
useModelService: true
28+
modelServiceUrl: "http://{{ include "cogstack-helm-ce.fullname" . }}-anoncat-service:5000"
29+
{{- end }}

deployment/kubernetes/charts/cogstack-helm-ce/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ medcat-service:
2424
repository: cogstacksystems/medcat-service
2525
tag: "1.2.0"
2626

27+
28+
medcat-trainer:
29+
image:
30+
tag: "latest@sha256:dcbd9f7c480dcb88e072189d233a146317f210a826573fd0c47d469da5360be0"
31+
provisioning:
32+
enabled: true
33+
existingConfigMap:
34+
name: "cogstack-helm-ce-example-trainer-provisioining"
35+
env:
36+
CSRF_TRUSTED_ORIGINS: "http://localhost:8080"
37+
2738
opensearch:
2839
enabled: true
2940
extraEnvs:

deployment/kubernetes/charts/medcat-trainer-helm/templates/medcat-trainer-configmap.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,3 @@ data:
3939
stderr_logfile=/dev/stderr
4040
stderr_logfile_maxbytes=0
4141
autorestart=true
42-
{{- if and .Values.provisioning .Values.provisioning.enabled }}
43-
provisioning.yaml: |
44-
{{ toYaml .Values.provisioning.config | indent 4 }}
45-
{{- end }}

deployment/kubernetes/charts/medcat-trainer-helm/templates/medcat-trainer-deployment.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ spec:
8787
name: api-static
8888
{{- if and .Values.provisioning .Values.provisioning.enabled }}
8989
- mountPath: /home/configs/provisioning.yaml
90-
name: medcat-trainer-config
91-
subPath: provisioning.yaml
90+
name: medcat-trainer-provisioning-config
91+
subPath: {{ .Values.provisioning.existingConfigMap.subPath | default "provisioning.yaml" }}
9292
{{- end }}
9393
{{- if eq .Values.DB_ENGINE "sqlite3" }}
9494
- mountPath: /home/api/db
@@ -140,6 +140,15 @@ spec:
140140
- name: medcat-trainer-config
141141
configMap:
142142
name: {{ include "medcat-trainer-helm.fullname" . }}-config
143+
{{- if and .Values.provisioning .Values.provisioning.enabled }}
144+
- name: medcat-trainer-provisioning-config
145+
configMap:
146+
{{- if .Values.provisioning.existingConfigMap.name }}
147+
name: {{ .Values.provisioning.existingConfigMap.name }}
148+
{{- else }}
149+
name: {{ include "medcat-trainer-helm.fullname" . }}-provisioning
150+
{{- end }}
151+
{{- end }}
143152
- name: api-media
144153
persistentVolumeClaim:
145154
claimName: {{ include "medcat-trainer-helm.fullname" . }}-api-media
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if (and .Values.provisioning .Values.provisioning.enabled) }}
2+
{{- if not .Values.provisioning.existingConfigMap }}
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: {{ include "medcat-trainer-helm.fullname" . }}-provisioning
7+
data:
8+
provisioning.yaml: |
9+
{{ tpl (toYaml .Values.provisioning.config) . | indent 4 }}
10+
{{- end }}
11+
{{- end }}

deployment/kubernetes/charts/medcat-trainer-helm/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ env:
4242
provisioning:
4343
# -- Set to true to enable provisioning of projects and models on startup..
4444
enabled: false
45-
# -- Put yaml file contents here.See https://docs.cogstack.org/projects/medcat-trainer/en/latest/provisioning/
45+
# -- Optional: Reference an existing configmap for the provisioning config.
46+
existingConfigMap: {}
47+
# -- The name of an existing configmap. Contains a yaml definition under the key "provisioining.yaml"
48+
# name: ""
49+
# -- Put yaml file contents here. Can be templated See https://docs.cogstack.org/projects/medcat-trainer/en/latest/provisioning/
4650
config:
4751
projects:
4852
- dataset:

deployment/kubernetes/local_dev_startup.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ helm test medcat-service --logs
2525

2626
## helm install trainer-registry oci://registry-1.docker.io/cogstacksystems/medcat-trainer-helm --wait --timeout 5m0s
2727

28-
helm upgrade cogstack-helm-ce ./cogstack-helm-ce --install --render-subchart-notes --wait --timeout 5m0s
28+
helm upgrade cogstack-helm-ce ./cogstack-helm-ce --install
29+
30+
# Stop any running port forwards
31+
# ps -ef | grep '[p]ort-forward' | awk '{print $2}' | xargs -r kill
32+
# Port forward all services in cogstack-helm-ce
33+
# helm get notes cogstack-helm-ce | bash

0 commit comments

Comments
 (0)