Repository: comet-ml/opik
Pull request #1651: add demo-data-generatior job and probes for backend services
Author: login: liyaka
Created: 2025-03-25T17:25:49Z | Merged: 2025-03-26T12:50:11Z

## Details

## Issues

Resolves #

## Testing

## Documentation



Diff:
diff --git a/.gitignore b/.gitignore
index 57e84bdda09..9b9a794bb8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,7 +60,6 @@ pip-log.txt
 
 # charts
 deployment/helm_chart/opik/charts
-deployment/helm_chart/opik/values-cloud-test.yaml
-deployment/helm_chart/opik/values-test.yaml
+deployment/helm_chart/opik/values-*.yaml
 temp
 opik-sandbox-executor-python.tar.gz
diff --git a/deployment/helm_chart/opik/README.md b/deployment/helm_chart/opik/README.md
index ef0714e425d..785c3b104cb 100644
--- a/deployment/helm_chart/opik/README.md
+++ b/deployment/helm_chart/opik/README.md
@@ -146,6 +146,11 @@ Call opik api on http://localhost:5173/api
 | component.backend.initContainers[0].command[1] | string | `"-c"` |  |
 | component.backend.initContainers[0].image | string | `"curlimages/curl:8.12.1"` |  |
 | component.backend.initContainers[0].name | string | `"wait-for-clickhouse-service"` |  |
+| component.backend.livenessProbe.path | string | `"/health-check?name=all&type=alive"` |  |
+| component.backend.livenessProbe.port | int | `8080` |  |
+| component.backend.readinessProbe.initialDelaySeconds | int | `20` |  |
+| component.backend.readinessProbe.path | string | `"/health-check?name=all&type=ready"` |  |
+| component.backend.readinessProbe.port | int | `8080` |  |
 | component.backend.replicaCount | int | `1` |  |
 | component.backend.run_migration | bool | `true` |  |
 | component.backend.service.ports[0].name | string | `"http"` |  |
@@ -212,6 +217,7 @@ Call opik api on http://localhost:5173/api
 | component.python-backend.service.ports[0].targetPort | int | `8000` |  |
 | component.python-backend.service.type | string | `"ClusterIP"` |  |
 | component.python-backend.serviceAccount.create | bool | `true` |  |
+| demoDataJob | bool | `true` |  |
 | fullnameOverride | string | `""` |  |
 | localFE | bool | `false` |  |
 | localFEAddress | string | `"host.minikube.internal:5174"` |  |
diff --git a/deployment/helm_chart/opik/templates/demo-data-generator-job.yaml b/deployment/helm_chart/opik/templates/demo-data-generator-job.yaml
new file mode 100644
index 00000000000..86c129acf5c
--- /dev/null
+++ b/deployment/helm_chart/opik/templates/demo-data-generator-job.yaml
@@ -0,0 +1,42 @@
+{{- if and .Values.demoDataJob (index .Values.component "python-backend" "enabled") .Values.component.frontend.enabled .Values.component.backend.enabled }}
+apiVersion: batch/v1
+kind: Job
+metadata:
+  name: {{ include "opik.name" $ }}-demo-data-generator
+  labels:
+    {{- include "opik.labels" $  | nindent 4 }}
+    component: {{ include "opik.name" $ }}-demo-data-generator
+    {{- with .Values.commonLabels }}
+    {{- toYaml . | nindent 4 }}
+    {{- end }}
+  annotations:
+    "helm.sh/hook": post-install,post-upgrade
+    "helm.sh/hook-weight": "5"
+    helm.sh/hook-delete-policy: before-hook-creation
+spec:
+  template:
+    metadata:
+      name:  {{ include "opik.name" $ }}-demo-data-generator
+    spec:
+      restartPolicy: Never
+      initContainers:          
+      - name: wait-for-python-backend-service
+        image: curlimages/curl:8.12.1
+        command: ["/bin/sh", "-c"]
+        args: ['while [ $(curl -ksw "%{http_code}" "http://opik-python-backend:8000/healthcheck" -o /dev/null) -ne 200 ]; do sleep 5; echo "Opik Python Backend is not available. Waiting for the Python Backend..."; done']
+      - name: wait-for-frontend-service
+        image: curlimages/curl:8.12.1
+        command: ["/bin/sh", "-c"]
+        args: ['while [ $(curl -ksw "%{http_code}" "http://opik-frontend:5173" -o /dev/null) -ne 200 ]; do sleep 5; echo "Opik Frontend is not available. Waiting for the Opik Frontend..."; done']
+      containers:
+      - name: demo-data-generator
+        image: "{{ .Values.registry }}/opik-python-backend:{{ (index .Values.component "python-backend" "image" "tag") }}"
+        command: [ "sh", "-c", "./demo_data_entrypoint.sh" ]
+        env:
+        - name: CREATE_DEMO_DATA
+          value: "true"
+        - name: PYTHON_BACKEND_URL
+          value: "http://opik-python-backend:8000"
+  backoffLimit: 3
+
+{{- end }}
\ No newline at end of file
diff --git a/deployment/helm_chart/opik/values.yaml b/deployment/helm_chart/opik/values.yaml
index eebe442feae..5e911b34798 100644
--- a/deployment/helm_chart/opik/values.yaml
+++ b/deployment/helm_chart/opik/values.yaml
@@ -13,6 +13,8 @@ registry: &registry ghcr.io/comet-ml/opik
 localFEAddress: "host.minikube.internal:5174"
 localFE: false
 
+demoDataJob: true
+
 component:
   backend:
     enabled: true
@@ -33,13 +35,13 @@ component:
       image: curlimages/curl:8.12.1
       command: ["/bin/sh", "-c"]
       args: ['while [ $(curl -ksw "%{http_code}" "http://clickhouse-opik-clickhouse:8123" -o /dev/null) -ne 200 ]; do sleep 5; echo "Clickhouse is not available. Waiting for the Clickhouse..."; done']
-    # livenessProbe:
-    #   path: /health-check?name=all&type=alive
-    #   port:  8080
-    # readinessProbe:
-    #   path: /health-check?name=all&type=ready
-    #   port:  8080
-    #   initialDelaySeconds: 20
+    livenessProbe:
+      path: /health-check?name=all&type=alive
+      port:  8080
+    readinessProbe:
+      path: /health-check?name=all&type=ready
+      port:  8080
+      initialDelaySeconds: 20
 
     env:
       STATE_DB_PROTOCOL: "jdbc:mysql://"
@@ -135,7 +137,6 @@ component:
     ingress:
       enabled: false
 
-    
   frontend:
     enabled: true
     serviceAccount: 


Reviews:
user: login: thiagohora
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T09:47:30Z
user: login: andrescrz
body: Let's double check the feedback before moving forward.
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-26T09:55:34Z
user: login: liyaka
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-26T10:00:22Z
user: login: liyaka
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-26T10:01:01Z
user: login: thiagohora
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T10:04:34Z
user: login: liyaka
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-26T10:14:53Z
user: login: liyaka
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-26T10:15:02Z
user: login: thiagohora
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T10:18:35Z
user: login: liyaka
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-26T10:26:13Z
user: login: liyaka
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-26T10:38:15Z
user: login: thiagohora
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T10:44:56Z
user: login: andrescrz
body: Let's clean up the docker compose dependency and we're good to go.
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-26T10:56:58Z
user: login: thiagohora
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T12:13:30Z
user: login: thiagohora
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T12:41:18Z

Review comments:
diff_hunk: @@ -13,6 +13,8 @@ registry: &registry ghcr.io/comet-ml/opik
 localFEAddress: "host.minikube.internal:5174"
 localFE: false
 
+demoDataJob: true
path: deployment/helm_chart/opik/values.yaml
user: login: thiagohora
body: Can we use the `CREATE_DEMO_DATA` env to define this and add true as a default value? To keep it the same as the docker compose file
created_at: 2025-03-26T09:47:30Z
author_association: CONTRIBUTOR
diff_hunk: @@ -13,6 +13,8 @@ registry: &registry ghcr.io/comet-ml/opik
 localFEAddress: "host.minikube.internal:5174"
 localFE: false
 
+demoDataJob: true
path: deployment/helm_chart/opik/values.yaml
user: login: andrescrz
body: Flag `demoData` should be false for installations with Comet, as the later takes care of generating this demo data.

This should be true for Open Source self-hosted only. 

Looks that this default is fine for stand-alone Opik self-hosting, but let's make sure we handle that for those other installations.
created_at: 2025-03-26T09:48:59Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,42 @@
+{{- if and .Values.demoDataJob (index .Values.component "python-backend" "enabled") .Values.component.frontend.enabled }}
path: deployment/helm_chart/opik/templates/demo-data-generator-job.yaml
user: login: andrescrz
body: The Java backend should be enabled too. Not sure if you need to explicitly check that here.
created_at: 2025-03-26T09:49:58Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,42 @@
+{{- if and .Values.demoDataJob (index .Values.component "python-backend" "enabled") .Values.component.frontend.enabled }}
+apiVersion: batch/v1
+kind: Job
+metadata:
+  name: {{ include "opik.name" $ }}-demo-data-generator
+  labels:
+    {{- include "opik.labels" $  | nindent 4 }}
+    component: {{ include "opik.name" $ }}-demo-data-generator
+    {{- with .Values.commonLabels }}
+    {{- toYaml . | nindent 4 }}
+    {{- end }}
+  annotations:
+    "helm.sh/hook": post-install,post-upgrade
+    "helm.sh/hook-weight": "5"
+    helm.sh/hook-delete-policy: before-hook-creation
+spec:
+  template:
+    metadata:
+      name:  {{ include "opik.name" $ }}-demo-data-generator
+    spec:
+      restartPolicy: Never
+      initContainers:          
+      - name: wait-for-python-backend-service
path: deployment/helm_chart/opik/templates/demo-data-generator-job.yaml
user: login: andrescrz
body: In this case, it needs to wait for the Java backend too.
created_at: 2025-03-26T09:50:46Z
author_association: MEMBER
diff_hunk: @@ -135,7 +137,14 @@ component:
     ingress:
       enabled: false
 
-    
+    livenessProbe:
+      path: /health-check
+      port:  8080
+    readinessProbe:
+      path: /health-check
+      port:  8080
path: deployment/helm_chart/opik/values.yaml
user: login: andrescrz
body: For the `python-backend` the path should be `/healthcheck` on port `8000`.
created_at: 2025-03-26T09:53:06Z
author_association: MEMBER
diff_hunk: @@ -13,6 +13,8 @@ registry: &registry ghcr.io/comet-ml/opik
 localFEAddress: "host.minikube.internal:5174"
 localFE: false
 
+demoDataJob: true
path: deployment/helm_chart/opik/values.yaml
user: login: liyaka
body: @thiagohora `CREATE_DEMO_DATA`  it's not enough, cause the job has to be disabled for any comet installation (cloud or selfhosted), but I will add it as well
created_at: 2025-03-26T10:00:22Z
author_association: COLLABORATOR
diff_hunk: @@ -13,6 +13,8 @@ registry: &registry ghcr.io/comet-ml/opik
 localFEAddress: "host.minikube.internal:5174"
 localFE: false
 
+demoDataJob: true
path: deployment/helm_chart/opik/values.yaml
user: login: liyaka
body: it does not appear in default helm values, will add it there as well
created_at: 2025-03-26T10:01:00Z
author_association: COLLABORATOR
diff_hunk: @@ -13,6 +13,8 @@ registry: &registry ghcr.io/comet-ml/opik
 localFEAddress: "host.minikube.internal:5174"
 localFE: false
 
+demoDataJob: true
path: deployment/helm_chart/opik/values.yaml
user: login: thiagohora
body: It's fine, we can switch the default value, but just keep the envar as the way to enable it 
created_at: 2025-03-26T10:04:33Z
author_association: CONTRIBUTOR
diff_hunk: @@ -13,6 +13,8 @@ registry: &registry ghcr.io/comet-ml/opik
 localFEAddress: "host.minikube.internal:5174"
 localFE: false
 
+demoDataJob: true
path: deployment/helm_chart/opik/values.yaml
user: login: liyaka
body: Yes, that's exactly the idea.
After these changes will be merged to to main, and the new version of helm will be released, I will update the cloud envs configurations and the self-hosted chart accordingly.
[same for minio, which isthe default for standalone Opik installations]
created_at: 2025-03-26T10:14:53Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,42 @@
+{{- if and .Values.demoDataJob (index .Values.component "python-backend" "enabled") .Values.component.frontend.enabled }}
path: deployment/helm_chart/opik/templates/demo-data-generator-job.yaml
user: login: liyaka
body: added
created_at: 2025-03-26T10:15:01Z
author_association: COLLABORATOR
diff_hunk: @@ -69,6 +71,7 @@ component:
       AWS_ACCESS_KEY_ID: THAAIOSFODNN7EXAMPLE # rootUser for minio
       AWS_SECRET_ACCESS_KEY: LESlrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY # rootPassword for minio
       S3_URL: "http://opik-minio:9000"
+      CREATE_DEMO_DATA: "true"
path: deployment/helm_chart/opik/values.yaml
user: login: thiagohora
body: This shouldn't be here; this should affect `demo-data-generator`, which uses the `python-backend`.
created_at: 2025-03-26T10:18:34Z
author_association: CONTRIBUTOR
diff_hunk: @@ -135,7 +137,14 @@ component:
     ingress:
       enabled: false
 
-    
+    livenessProbe:
+      path: /health-check
+      port:  8080
+    readinessProbe:
+      path: /health-check
+      port:  8080
path: deployment/helm_chart/opik/values.yaml
user: login: liyaka
body: it doesn't work, so i will remove it for now
I see:
Liveness probe failed: Get "http://10.4.99.173:8000/healthcheck": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
created_at: 2025-03-26T10:26:12Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,42 @@
+{{- if and .Values.demoDataJob (index .Values.component "python-backend" "enabled") .Values.component.frontend.enabled }}
+apiVersion: batch/v1
+kind: Job
+metadata:
+  name: {{ include "opik.name" $ }}-demo-data-generator
+  labels:
+    {{- include "opik.labels" $  | nindent 4 }}
+    component: {{ include "opik.name" $ }}-demo-data-generator
+    {{- with .Values.commonLabels }}
+    {{- toYaml . | nindent 4 }}
+    {{- end }}
+  annotations:
+    "helm.sh/hook": post-install,post-upgrade
+    "helm.sh/hook-weight": "5"
+    helm.sh/hook-delete-policy: before-hook-creation
+spec:
+  template:
+    metadata:
+      name:  {{ include "opik.name" $ }}-demo-data-generator
+    spec:
+      restartPolicy: Never
+      initContainers:          
+      - name: wait-for-python-backend-service
path: deployment/helm_chart/opik/templates/demo-data-generator-job.yaml
user: login: liyaka
body: added
for docker-compose as well
created_at: 2025-03-26T10:38:15Z
author_association: COLLABORATOR
diff_hunk: @@ -167,6 +167,8 @@ services:
     depends_on:
       frontend:
         condition: service_healthy
+      backend:
path: deployment/docker-compose/docker-compose.yaml
user: login: thiagohora
body: The fronend already depends on the backend
created_at: 2025-03-26T10:44:56Z
author_association: CONTRIBUTOR
diff_hunk: @@ -167,6 +167,8 @@ services:
     depends_on:
       frontend:
         condition: service_healthy
+      backend:
path: deployment/docker-compose/docker-compose.yaml
user: login: andrescrz
body: Yes, remove for docker-compose. It waits indirectly through the frontend.
created_at: 2025-03-26T10:54:57Z
author_association: MEMBER
diff_hunk: @@ -167,6 +167,8 @@ services:
     depends_on:
       frontend:
         condition: service_healthy
+      backend:
path: deployment/docker-compose/docker-compose.yaml
user: login: thiagohora
body: So can should remove it 
created_at: 2025-03-26T12:13:30Z
author_association: CONTRIBUTOR

PR comments:
user: login: liyaka
created_at: 2025-03-26T11:41:02Z
body: @thiagohora @andrescrz so no need i helm as well for the same reason
author_association: COLLABORATOR
user: login: thiagohora
created_at: 2025-03-26T11:56:14Z
body: > @thiagohora @andrescrz so no need i helm as well for the same reason

Not sure I understood. We just mean that the frontend already depends on the backend
author_association: CONTRIBUTOR
user: login: liyaka
created_at: 2025-03-26T12:06:33Z
body: @thiagohora 
so no need to add dependency on `backend` for `demo-data-generator` since it depends on `frontend`, which depends on `backend` - in both docker-compose and helm

author_association: COLLABORATOR
user: login: thiagohora
created_at: 2025-03-26T12:08:09Z
body: > @thiagohora so no need to add dependency on `backend` for `demo-data-generator` since it depends on `frontend`, which depends on `backend` - in both docker-compose and helm

correct
author_association: CONTRIBUTOR