diff --git a/helm-charts/cogstack-ce-helm/templates/_helpers.tpl b/helm-charts/cogstack-ce-helm/templates/_helpers.tpl index 1987250..dc309da 100644 --- a/helm-charts/cogstack-ce-helm/templates/_helpers.tpl +++ b/helm-charts/cogstack-ce-helm/templates/_helpers.tpl @@ -65,6 +65,47 @@ Create the name of the service account to use Dependency URLs */}} + +{{- define "medcat-service.service-name" -}} +{{ include "medcat-service.fullname" (dict "Values" .Values "Chart" (dict "Name" "medcat-service") "Release" .Release ) }} +{{- end -}} + +{{- define "medcat-service.port" -}} +{{ index .Values "medcat-service" "service" "port" }} +{{- end -}} + +{{- define "medcat-service.url" -}} +{{- $url := (index .Values "medcat-service" "url") | default "" -}} +{{- if $url -}} +{{ $url }} +{{- else if not (index .Values "medcat-service" "enabled") -}} +"unset" +{{- else -}} +http://{{ include "medcat-service.service-name" . }}:{{ include "medcat-service.port" . }} +{{- end -}} +{{- end -}} + +{{- define "anoncat-service.service-name" -}} +{{ include "medcat-service.fullname" (dict "Values" (index .Values "anoncat-service") "Chart" (dict "Name" "anoncat-service") "Release" .Release ) }} +{{- end -}} + +{{- define "anoncat-service.port" -}} +{{ index .Values "anoncat-service" "service" "port" }} +{{- end -}} + +{{- define "anoncat-service.url" -}} +{{- $url := (index .Values "anoncat-service" "url") | default "" -}} +{{- if $url -}} +{{ $url }} +{{- else if not (index .Values "anoncat-service" "enabled") -}} +"unset" +{{- else -}} +http://{{ include "anoncat-service.service-name" . }}:{{ include "anoncat-service.port" . }} +{{- end -}} +{{- end -}} + + + {{- define "opensearch.url" -}} {{- if .Values.opensearch.enabled }} {{- $serviceName := include "opensearch.serviceName" (index .Subcharts "opensearch") -}} diff --git a/helm-charts/cogstack-ce-helm/templates/jupyterhub-configmap.yaml b/helm-charts/cogstack-ce-helm/templates/jupyterhub-configmap.yaml new file mode 100644 index 0000000..01358f3 --- /dev/null +++ b/helm-charts/cogstack-ce-helm/templates/jupyterhub-configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: cogstack-ce-helm-jupyterhub-config +data: + MEDCAT_SERVICE_URL: {{ include "medcat-service.url" . }} + ANONCAT_SERVICE_URL: {{ include "anoncat-service.url" . }} diff --git a/helm-charts/cogstack-ce-helm/templates/medcat-trainer-provisioining.yaml b/helm-charts/cogstack-ce-helm/templates/medcat-trainer-provisioining.yaml index a94dccc..4f3da74 100644 --- a/helm-charts/cogstack-ce-helm/templates/medcat-trainer-provisioining.yaml +++ b/helm-charts/cogstack-ce-helm/templates/medcat-trainer-provisioining.yaml @@ -15,7 +15,7 @@ data: description: "Example project for medcat trainer using MedCAT Service" annotationGuidelineLink: "https://docs.google.com/document/d/1xxelBOYbyVzJ7vLlztP2q1Kw9F5Vr1pRwblgrXPS7QM/edit?usp=sharing" useModelService: true - modelServiceUrl: "http://{{ include "cogstack-ce-helm.fullname" . }}-medcat-service:5000" + modelServiceUrl: {{ include "medcat-service.url" . }} - dataset: name: "Example Dataset - psych.csv - deid" url: "https://raw.githubusercontent.com/CogStack/cogstack-nlp/be9825f151da2d3b6faac80d49e5be91a1629c68/medcat-trainer/notebook_docs/example_data/psych.csv" @@ -25,5 +25,5 @@ data: description: "Example project for medcat trainer using AnonCAT Service" annotationGuidelineLink: "https://docs.google.com/document/d/1xxelBOYbyVzJ7vLlztP2q1Kw9F5Vr1pRwblgrXPS7QM/edit?usp=sharing" useModelService: true - modelServiceUrl: "http://{{ include "cogstack-ce-helm.fullname" . }}-anoncat-service:5000" + modelServiceUrl: {{ include "anoncat-service.url" . }} {{- end }} \ No newline at end of file diff --git a/helm-charts/cogstack-ce-helm/templates/opensearch-provisioning-config-map.yaml b/helm-charts/cogstack-ce-helm/templates/opensearch-provisioning-config-map.yaml index ffe6529..7fb26a5 100644 --- a/helm-charts/cogstack-ce-helm/templates/opensearch-provisioning-config-map.yaml +++ b/helm-charts/cogstack-ce-helm/templates/opensearch-provisioning-config-map.yaml @@ -1,6 +1,6 @@ apiVersion: v1 kind: ConfigMap metadata: - name: opensearch-provisioning-config + name: {{ include "cogstack-ce-helm.fullname" . }}-opensearch-provisioning-config data: {{ (.Files.Glob "provisioning/*").AsConfig | indent 2 }} diff --git a/helm-charts/cogstack-ce-helm/templates/opensearch-provisioning-post-install.yaml b/helm-charts/cogstack-ce-helm/templates/opensearch-provisioning-post-install.yaml index f46a81b..544fac5 100644 --- a/helm-charts/cogstack-ce-helm/templates/opensearch-provisioning-post-install.yaml +++ b/helm-charts/cogstack-ce-helm/templates/opensearch-provisioning-post-install.yaml @@ -39,5 +39,5 @@ spec: volumes: - name: opensearch-provisioning-config configMap: - name: opensearch-provisioning-config + name: {{ include "cogstack-ce-helm.fullname" . }}-opensearch-provisioning-config {{- end }} \ No newline at end of file diff --git a/helm-charts/cogstack-ce-helm/values.yaml b/helm-charts/cogstack-ce-helm/values.yaml index b33d30b..bcd0652 100644 --- a/helm-charts/cogstack-ce-helm/values.yaml +++ b/helm-charts/cogstack-ce-helm/values.yaml @@ -114,3 +114,15 @@ cogstack-jupyterhub: tag: "2.2.2" # -- JupyterHub singleuser image pull policy. pullPolicy: IfNotPresent + extraEnv: + MEDCAT_SERVICE_URL: + valueFrom: + configMapKeyRef: + name: cogstack-ce-helm-jupyterhub-config + key: MEDCAT_SERVICE_URL + ANONCAT_SERVICE_URL: + name: ANONCAT_SERVICE_URL + valueFrom: + configMapKeyRef: + name: cogstack-ce-helm-jupyterhub-config + key: ANONCAT_SERVICE_URL diff --git a/helm-charts/cogstack-jupyterhub-helm/examples/medcat-opensearch-e2e.ipynb b/helm-charts/cogstack-jupyterhub-helm/examples/medcat-opensearch-e2e.ipynb index 845c943..e40efdb 100644 --- a/helm-charts/cogstack-jupyterhub-helm/examples/medcat-opensearch-e2e.ipynb +++ b/helm-charts/cogstack-jupyterhub-helm/examples/medcat-opensearch-e2e.ipynb @@ -49,7 +49,7 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": null, "id": "17deaa5c", "metadata": {}, "outputs": [ @@ -77,7 +77,7 @@ "sample_text = \"John was diagnosed with Kidney Failure\"\n", "\n", "# Service URLs from environment variables\n", - "medcat_base_url = os.getenv(\"MEDCAT_URL\", \"http://cogstack-medcat-service:5000\").rstrip(\"/\")\n", + "medcat_base_url = os.getenv(\"MEDCAT_SERVICE_URL\", \"http://cogstack-medcat-service:5000\").rstrip(\"/\")\n", "medcat_url = medcat_base_url + \"/api/process\"\n", "\n", "opensearch_url = os.getenv(\"OPENSEARCH_URL\", \"https://opensearch-cluster-master:9200\")\n", @@ -107,7 +107,8 @@ "annotations_index = \"discharge_annotations\"\n", "\n", "# Static demo note id used across all steps\n", - "note_id = \"demo-note-kidney-failure-001\"" + "note_id = \"demo-note-kidney-failure-001\"\n", + "subject_id = 1" ] }, { diff --git a/helm-charts/cogstack-jupyterhub-helm/examples/medcat-service-tutorial.ipynb b/helm-charts/cogstack-jupyterhub-helm/examples/medcat-service-tutorial.ipynb index da883e9..7de9a08 100644 --- a/helm-charts/cogstack-jupyterhub-helm/examples/medcat-service-tutorial.ipynb +++ b/helm-charts/cogstack-jupyterhub-helm/examples/medcat-service-tutorial.ipynb @@ -54,11 +54,11 @@ "sample_text = \"John was diagnosed with Kidney Failure\"\n", "\n", "medcat_base_url = os.getenv(\n", - " \"MEDCAT_URL\", \"http://cogstack-medcat-service:5000\"\n", + " \"MEDCAT_SERVICE_URL\", \"http://cogstack-medcat-service:5000\"\n", ").rstrip(\"/\")\n", "\n", "anoncat_base_url = os.getenv(\n", - " \"ANONCAT_URL\", \"http://cogstack-ce-anoncat-service:5000\"\n", + " \"ANONCAT_SERVICE_URL\", \"http://cogstack-ce-anoncat-service:5000\"\n", ").rstrip(\"/\")\n", "\n", "medcat_url = medcat_base_url + \"/api/process\"\n", diff --git a/helm-charts/cogstack-jupyterhub-helm/values.yaml b/helm-charts/cogstack-jupyterhub-helm/values.yaml index 4d8d11a..ff90d70 100644 --- a/helm-charts/cogstack-jupyterhub-helm/values.yaml +++ b/helm-charts/cogstack-jupyterhub-helm/values.yaml @@ -35,11 +35,12 @@ jupyterhub: c.Application.log_level = 'DEBUG' 00-custom-spawner: | # Custom environment variables for user pods - c.KubeSpawner.environment = { - 'GRANT_SUDO': '1', - 'CHOWN_HOME': 'yes', - 'CHOWN_HOME_OPTS': '-R', - } + c.KubeSpawner.environment = c.KubeSpawner.environment or {} + c.KubeSpawner.environment.update({ + 'GRANT_SUDO': '1', + 'CHOWN_HOME': 'yes', + 'CHOWN_HOME_OPTS': '-R', + }) # Allow root in notebooks c.KubeSpawner.args = ['--allow-root'] proxy: diff --git a/helm-charts/local_dev_startup.sh b/helm-charts/local_dev_startup.sh index 67313fa..5de989d 100644 --- a/helm-charts/local_dev_startup.sh +++ b/helm-charts/local_dev_startup.sh @@ -25,7 +25,14 @@ helm test medcat-service --logs ## helm install trainer-registry oci://registry-1.docker.io/cogstacksystems/medcat-trainer-helm --wait --timeout 5m0s -helm upgrade cogstack-ce-helm ./cogstack-ce-helm --install +# Run cogstack-ce-helm + +helm repo add opensearch https://opensearch-project.github.io/helm-charts/ +helm dependency update ./medcat-trainer-helm +helm dependency update ./cogstack-jupyterhub-helm +helm dependency update ./cogstack-ce-helm + +helm upgrade cogstack-ce-helm ./cogstack-ce-helm --install --dependency-update --wait --timeout 30m0s # Stop any running port forwards # ps -ef | grep '[p]ort-forward' | awk '{print $2}' | xargs -r kill