Skip to content

Commit 5fb764c

Browse files
MNT: Use conda-lock lock file for reproducible environment (#32)
* Add lock.sh which uses the same Docker image used for deployment to install conda-lock and then build the conda-lock lock file from the high level environment.yml. * Add high level environment.yml and use conda-lock v2.x to create a hash level conda-lock.yml lock file of the environment. ``` conda-lock lock --micromamba --platform linux-64 --file environment.yml ``` * COPY conda-lock.yml lock file to Dockerfile during build. * Use the conda-lock.yml lock file to create an upload-nightly-action micromamba environment and activate it to have access to anaconda-client.
1 parent a5947da commit 5fb764c

6 files changed

Lines changed: 1198 additions & 9 deletions

File tree

.github/workflows/remove-wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
environment-name: remove-wheels
3737
create-args: >-
3838
python=3.11
39-
anaconda-client=1.12.0
39+
anaconda-client=1.12.1
4040
curl
4141
jq
4242

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ SHELL [ "/bin/bash", "-c" ]
88
ENV LC_ALL=C.UTF-8
99
ENV LANG=C.UTF-8
1010

11+
# lock file created by running lock.sh in the top level of the repository
12+
COPY --chown=mambauser conda-lock.yml /conda-lock.yml
1113
COPY --chown=mambauser cmd.sh /cmd.sh
1214
RUN chmod +x /cmd.sh
1315

cmd.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ if [ -z "${ANACONDA_TOKEN}" ]; then
2424
exit -1
2525
fi
2626

27-
export ANACONDA_CLIENT_VERSION="1.12.0"
28-
29-
# install anaconda-client
30-
echo "Installing anaconda-client v${ANACONDA_CLIENT_VERSION}..."
31-
32-
micromamba install \
27+
# Install anaconda-client from lock file
28+
echo "Installing anaconda-client from upload-nightly-action conda-lock lock file..."
29+
micromamba create \
3330
--yes \
34-
--channel conda-forge \
35-
"anaconda-client==${ANACONDA_CLIENT_VERSION}"
31+
--name upload-nightly-action \
32+
--file /conda-lock.yml
33+
34+
# 'micromamba' is running as a subprocess and can't modify the parent shell.
35+
# Thus you must initialize your shell before using activate and deactivate.
36+
eval "$(micromamba shell hook --shell bash)"
37+
micromamba activate upload-nightly-action
3638

3739
# trim trailing slashes from $INPUT_ARTIFACTS_PATH
3840
INPUT_ARTIFACTS_PATH="${INPUT_ARTIFACTS_PATH%/}"

0 commit comments

Comments
 (0)