serving (MLflow), HK1K verification command and the tea-verify DaskJob

- serving: plans and biomarkers as MLflow "models from code" (standalone
  wrapper files), code_paths = only the module's package + contracts;
  plan.json artifact and plan params; biomarker models pin plan_uri and
  plan_hash. privacy: no study codes / dates / paths, binary artifacts
  refused, baselines from fewer than 5 children refused.
- verify: python -m tea_modulo.verify hk1k lists HK1K in a worker task, runs
  the pipeline remotely (line 50 Hz), checks the remote run equals a plain
  sequential run in one task, summarizes the posterior rhythm by age group
  (groups < 5 suppressed) and writes the summary under processed/usuarios/.
  Any input prefix but raw/eeg-helsinki/ is refused.
- deploy: Dockerfile.verify (dask:1.1 + antropy, fhir.resources, meegkit,
  pytest; tea-modulo from the local checkout), .dockerignore keeping .venv,
  eeg/ and any signal or patient file out, dask-verify.yaml (own 2x4-worker
  cluster, no eeg-data PVC, keys only on workers), verify.sh.

Tests: MLflow round trips on sqlite, model loads with only its own code in
a fresh interpreter, privacy refusals, verify guards.
This commit is contained in:
AlbertoPMDM
2026-11-18 20:24:03 -06:00
parent 038836a701
commit 4956f36d80
15 changed files with 723 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
# tea-verify: the team's dask image plus what the tea_modulo verification needs.
# Built from the local checkout (submodules included) by deploy/verify.sh.
FROM 192.168.20.18:5000/dask:1.1
# missing from dask:1.1; versions as checked locally
RUN pip install --no-cache-dir "antropy==0.2.3" "fhir.resources==8.3.0" "meegkit==0.2.0" pytest
# tea-modulo from the local checkout (biomarcadores-tea @ 7dfc641, codigo @ c7a4736:
# the legacy = submodule tests need them). .dockerignore keeps .venv, eeg/ and any
# signal or patient file out of the build context.
COPY . /opt/tea-modulo
ARG TEA_COMMIT=unknown
ENV TEA_COMMIT=$TEA_COMMIT
LABEL tea_modulo.commit=$TEA_COMMIT
RUN pip install --no-cache-dir --no-deps -e /opt/tea-modulo
WORKDIR /opt/tea-modulo
+68
View File
@@ -0,0 +1,68 @@
# tea-verify: test suite + HK1K check, in its own small Dask cluster.
# Applied by deploy/verify.sh (it substitutes COMMIT). HK1K (public) only;
# the eeg-data PVC (patient data) is NOT mounted.
apiVersion: kubernetes.dask.org/v1
kind: DaskJob
metadata:
name: tea-verify
spec:
job:
spec:
restartPolicy: Never
containers:
- name: job
image: 192.168.20.18:5000/tea-verify:COMMIT
workingDir: /opt/tea-modulo
command: [sh, -c]
args:
- |
set -e
export DASK_SCHEDULER="$DASK_SCHEDULER_ADDRESS"
export MLFLOW_DISABLE_AGENT_HINT=1
python -m pytest -q -p no:cacheprovider -m "not cluster"
python -m pytest -q -p no:cacheprovider -m cluster
python -m tea_modulo.verify hk1k --out processed/usuarios/alberto/tea-verify/
env:
- {name: OMP_NUM_THREADS, value: "1"}
- {name: OPENBLAS_NUM_THREADS, value: "1"}
- {name: MKL_NUM_THREADS, value: "1"}
resources:
requests: {memory: 6Gi, cpu: "2"}
limits: {memory: 6Gi}
cluster:
spec:
worker:
replicas: 2
spec:
containers:
- name: worker
image: 192.168.20.18:5000/tea-verify:COMMIT
args: [dask-worker, --name, $(DASK_WORKER_NAME), --nworkers, "4", --nthreads, "1", --memory-limit, 4.25GiB]
resources:
requests: {memory: 19Gi, cpu: "4"}
limits: {memory: 19Gi}
env:
- {name: AWS_ENDPOINT_URL, value: "http://seaweedfs-s3.seaweedfs:8333"}
- {name: OMP_NUM_THREADS, value: "1"}
- {name: OPENBLAS_NUM_THREADS, value: "1"}
- {name: MKL_NUM_THREADS, value: "1"}
- {name: MLFLOW_DISABLE_AGENT_HINT, value: "1"}
envFrom:
- secretRef: {name: seaweed-s3}
scheduler:
spec:
containers:
- name: scheduler
image: 192.168.20.18:5000/tea-verify:COMMIT
args: [dask-scheduler]
ports:
- {name: tcp-comm, containerPort: 8786}
- {name: http-dashboard, containerPort: 8787}
service:
type: ClusterIP
selector:
dask.org/cluster-name: tea-verify
dask.org/component: scheduler
ports:
- {name: tcp-comm, port: 8786, targetPort: tcp-comm}
- {name: http-dashboard, port: 8787, targetPort: http-dashboard}
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Build, push and run the tea-verify DaskJob for the current commit.
# deploy/verify.sh build + push + apply
# deploy/verify.sh --logs follow the job pod's log
# deploy/verify.sh --delete remove the DaskJob
set -euo pipefail
cd "$(dirname "$0")/.."
REG=192.168.20.18:5000
case "${1:-}" in
--logs) pod=$(kubectl get pods -l dask.org/cluster-name=tea-verify,dask.org/component=job -o name | head -1)
exec kubectl logs -f "${pod:-job/tea-verify}" ;;
--delete) exec kubectl delete daskjob tea-verify --ignore-not-found ;;
esac
if [ -n "$(git status --porcelain --ignore-submodules=none)" ]; then
echo "uncommitted changes: commit first, so the image tag is a real commit" >&2; exit 1
fi
C=$(git rev-parse --short HEAD)
docker build -f deploy/Dockerfile.verify --build-arg TEA_COMMIT="$C" -t "$REG/tea-verify:$C" .
docker push "$REG/tea-verify:$C"
kubectl delete daskjob tea-verify --ignore-not-found
sed "s/tea-verify:COMMIT/tea-verify:$C/g" deploy/dask-verify.yaml | kubectl apply -f -
echo "applied tea-verify:$C — follow with: deploy/verify.sh --logs"