From bf2c98a01a7b81d99d82b5437031ada06aced3d6 Mon Sep 17 00:00:00 2001
From: Colm Talbot <colm.talbot@ligo.org>
Date: Mon, 30 Jan 2023 21:32:44 +0000
Subject: [PATCH] MAINT: pin pymc version in dockerfiles

---
 .gitlab-ci.yml                                | 15 +++++++-----
 containers/v3-dockerfile-test-suite-python310 |  2 +-
 containers/v3-dockerfile-test-suite-python38  |  2 +-
 containers/v3-dockerfile-test-suite-python39  |  2 +-
 containers/write_dockerfiles.py               | 24 +++++--------------
 5 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 901b3d8d4..2c3cdc765 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -268,13 +268,16 @@ pages:
 
 .build-container: &build-container
   stage: deploy
-  image: docker:20.10.12
+  image: docker:20.10.23
   needs: ["containers"]
-  except:
-    refs:
-      - schedules
-    changes:
-      - containers/*
+  rules:
+    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
+      changes:
+        compare_to: 'refs/heads/main'
+        paths:
+          - containers/*
+      when: manual
+    - if: $CI_PIPELINE_SOURCE == "schedule"
   script:
     - cd containers
     - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
diff --git a/containers/v3-dockerfile-test-suite-python310 b/containers/v3-dockerfile-test-suite-python310
index 71fd9f377..a67ea409c 100644
--- a/containers/v3-dockerfile-test-suite-python310
+++ b/containers/v3-dockerfile-test-suite-python310
@@ -32,7 +32,7 @@ RUN conda install -n ${conda_env} -c conda-forge scikit-image celerite george
 
 # Install dependencies and samplers
 RUN pip install corner healpy cython tables
-RUN conda install -n ${conda_env} dynesty emcee nestle ptemcee pymultinest ultranest cpnest kombine dnest4 zeus-mcmc pytorch pymc nessai ptmcmcsampler -c conda-forge -c pytorch
+RUN conda install -n ${conda_env} dynesty emcee nestle ptemcee pymultinest ultranest cpnest kombine dnest4 zeus-mcmc pytorch 'pymc>=4' nessai ptmcmcsampler -c conda-forge -c pytorch
 
 # Install Polychord
 RUN apt-get update --allow-releaseinfo-change
diff --git a/containers/v3-dockerfile-test-suite-python38 b/containers/v3-dockerfile-test-suite-python38
index bde0d526d..3369172c0 100644
--- a/containers/v3-dockerfile-test-suite-python38
+++ b/containers/v3-dockerfile-test-suite-python38
@@ -32,7 +32,7 @@ RUN conda install -n ${conda_env} -c conda-forge scikit-image celerite george
 
 # Install dependencies and samplers
 RUN pip install corner healpy cython tables
-RUN conda install -n ${conda_env} dynesty emcee nestle ptemcee pymultinest ultranest cpnest kombine dnest4 zeus-mcmc pytorch pymc nessai ptmcmcsampler -c conda-forge -c pytorch
+RUN conda install -n ${conda_env} dynesty emcee nestle ptemcee pymultinest ultranest cpnest kombine dnest4 zeus-mcmc pytorch 'pymc>=4' nessai ptmcmcsampler -c conda-forge -c pytorch
 
 # Install Polychord
 RUN apt-get update --allow-releaseinfo-change
diff --git a/containers/v3-dockerfile-test-suite-python39 b/containers/v3-dockerfile-test-suite-python39
index 5dbafefa3..6035f103e 100644
--- a/containers/v3-dockerfile-test-suite-python39
+++ b/containers/v3-dockerfile-test-suite-python39
@@ -32,7 +32,7 @@ RUN conda install -n ${conda_env} -c conda-forge scikit-image celerite george
 
 # Install dependencies and samplers
 RUN pip install corner healpy cython tables
-RUN conda install -n ${conda_env} dynesty emcee nestle ptemcee pymultinest ultranest cpnest kombine dnest4 zeus-mcmc pytorch pymc nessai ptmcmcsampler -c conda-forge -c pytorch
+RUN conda install -n ${conda_env} dynesty emcee nestle ptemcee pymultinest ultranest cpnest kombine dnest4 zeus-mcmc pytorch 'pymc>=4' nessai ptmcmcsampler -c conda-forge -c pytorch
 
 # Install Polychord
 RUN apt-get update --allow-releaseinfo-change
diff --git a/containers/write_dockerfiles.py b/containers/write_dockerfiles.py
index 14bb63ebe..a90d11776 100644
--- a/containers/write_dockerfiles.py
+++ b/containers/write_dockerfiles.py
@@ -6,23 +6,11 @@ with open("dockerfile-template", "r") as ff:
 python_versions = [(3, 8), (3, 9), (3, 10)]
 today = date.today().strftime("%Y%m%d")
 
-conda_sampler_dict = dict(
-    python38=[
-        "dynesty", "emcee", "nestle", "ptemcee", "pymultinest", "ultranest",
-        "cpnest", "kombine", "dnest4", "zeus-mcmc",
-        "pytorch", "pymc", "nessai", "ptmcmcsampler",
-    ],
-    python39=[
-        "dynesty", "emcee", "nestle", "ptemcee", "pymultinest", "ultranest",
-        "cpnest", "kombine", "dnest4", "zeus-mcmc",
-        "pytorch", "pymc", "nessai", "ptmcmcsampler",
-    ],
-    python310=[
-        "dynesty", "emcee", "nestle", "ptemcee", "pymultinest", "ultranest",
-        "cpnest", "kombine", "dnest4", "zeus-mcmc",
-        "pytorch", "pymc", "nessai", "ptmcmcsampler",
-    ]
-)
+samplers = [
+    "dynesty", "emcee", "nestle", "ptemcee", "pymultinest", "ultranest",
+    "cpnest", "kombine", "dnest4", "zeus-mcmc",
+    "pytorch", "'pymc>=4'", "nessai", "ptmcmcsampler",
+]
 
 for python_major_version, python_minor_version in python_versions:
     key = f"python{python_major_version}{python_minor_version}"
@@ -38,5 +26,5 @@ for python_major_version, python_minor_version in python_versions:
             date=today,
             python_major_version=python_major_version,
             python_minor_version=python_minor_version,
-            conda_samplers=" ".join(conda_sampler_dict[key])
+            conda_samplers=" ".join(samplers)
         ))
-- 
GitLab