FROM ghcr.io/dask/dask:latest-py3.14

RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu

RUN pip install --no-cache-dir mne pyarrow scipy pandas ipykernel scikit-learn "fooof==1.1.1" yasa mlflow

RUN pip install --no-cache-dir git+http://10.0.10.41:3000/alberto/eeg.git
RUN pip install 'eeg[html]'

RUN pip install --no-cache-dir s3fs zarr xarray

# bayes-pim: PyMC/PyTensor (same versions as the project's .venv). PyTensor compiles its graphs with g++, and the base
# image has no C++ compiler, so it comes from conda-forge (the `gxx` package provides the plain `g++` name).
RUN mamba install -y -c conda-forge gxx && mamba clean -afy
RUN pip install --no-cache-dir "pymc==6.4.0" "pytensor==3.3.8" joblib

# bayes-pim: R with PIMixture 0.4.4 (Cheung's routines) to refit KPNC's models in R on the workers (dask:1.3).
# `interval` is not on conda, so it comes from CRAN. PIMixture is not on CRAN either: before building, unpack its source
# package (the NCI tarball, e.g. ~/kek/pimixture-tar-file on the admon host) into ./PIMixture/ (not committed here).
RUN mamba install -y -c conda-forge -c bioconda r-base r-survival r-optimx r-fdrtool r-plyr r-flexsurv \
        bioconductor-icens gcc gxx gfortran make && mamba clean -afy
RUN Rscript -e 'install.packages(c("perm", "MLEcens", "interval"), repos = "https://cloud.r-project.org", Ncpus = 8)' \
    && Rscript -e 'library(interval)'
COPY PIMixture /opt/PIMixture
RUN R CMD INSTALL /opt/PIMixture

# bayes-pim: BayesPIM 2.0 (Klausch, Lissenberg-Witte and Coupé 2026, doi:10.1002/sim.70433; CRAN, MIT) to fit the
# prevalence-incidence reference model on the workers (dask:1.4).
RUN mamba install -y -c conda-forge r-rcpp r-coda r-actuar r-posterior r-doparallel r-foreach r-jsonlite && mamba clean -afy
RUN Rscript -e 'install.packages("BayesPIM", repos = "https://cloud.r-project.org", Ncpus = 8)' \
    && Rscript -e 'library(BayesPIM); v <- as.character(packageVersion("BayesPIM")); cat("BayesPIM", v, "\n"); stopifnot(v == "2.0")'
