Skip to content

Commit b994bed

Browse files
committed
feedback
1 parent 868a5dd commit b994bed

1 file changed

Lines changed: 27 additions & 25 deletions

File tree

features/src/workbench-tools/install.sh

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set -o xtrace
1010

1111
readonly CLOUD="${CLOUD:-""}"
1212
readonly USERNAME="${USERNAME:-"root"}"
13-
readonly LIB_ENV="${LIBENV:-"/opt/conda/envs/workbench-ds"}"
13+
readonly LIBRARIES_ENV_DIR="${LIBENV:-"/opt/conda/envs/workbench-ds"}"
1414
readonly LIB_PYTHON_VERSION="${LIBPYTHONVERSION:-"3.14"}"
1515
USER_HOME_DIR="${USERHOMEDIR:-"/home/${USERNAME}"}"
1616
if [[ "${USER_HOME_DIR}" == "/home/root" ]]; then
@@ -71,15 +71,16 @@ fi
7171

7272
# Install the samtools family of tools in a separate environment since some of
7373
# the other tools depend on old versions of these.
74-
CONDA_PACKAGES_1=(
74+
readonly CONDA_PACKAGES_SAMTOOLS=(
7575
"bioconda::bcftools>=1.23"
7676
"bioconda::htslib>=1.23" # includes bgzip and tabix
7777
"bioconda::samtools>=1.23"
7878
)
79+
readonly SAMTOOLS_ENV_DIR="${WORKBENCH_TOOLS_DIR}/samtools"
7980

8081
# Environment 2 contains the genomics CLI tools. They will be added to the
8182
# PATH but will not be usable as Python libraries.
82-
CONDA_PACKAGES_2=(
83+
readonly CONDA_PACKAGES_BINARIES=(
8384
"conda-forge::python"
8485
"conda-forge::pip"
8586
"conda-forge::perl>=5.32"
@@ -93,12 +94,13 @@ CONDA_PACKAGES_2=(
9394
"bioconda::regenie"
9495
"bioconda::vcftools"
9596
)
97+
readonly BINARIES_ENV_DIR="${WORKBENCH_TOOLS_DIR}/binaries"
9698

9799
# Environment 3 contains data science Python libraries. These should be
98100
# accessible from the user's default Python environment, which is why we install
99101
# them separately and give the user control over whether to inject them into an
100102
# existing environment or create a new one.
101-
CONDA_PACKAGES_3=(
103+
CONDA_PACKAGES_LIBRARIES=(
102104
"conda-forge::google-cloud-storage"
103105
"conda-forge::ipykernel"
104106
"conda-forge::ipywidgets"
@@ -117,50 +119,50 @@ CONDA_PACKAGES_3=(
117119
# Build isolated environments
118120
mkdir -p "${WORKBENCH_TOOLS_DIR}"
119121
echo "Building Environment 1 (Samtools family)..."
120-
mamba create --prefix "${WORKBENCH_TOOLS_DIR}/1" -y "${CONDA_PACKAGES_1[@]}"
122+
mamba create --prefix "${SAMTOOLS_ENV_DIR}" -y "${CONDA_PACKAGES_SAMTOOLS[@]}"
121123

122124
echo "Building Environment 2 (Genomics CLI Tools)..."
123-
mamba create --prefix "${WORKBENCH_TOOLS_DIR}/2" -y "${CONDA_PACKAGES_2[@]}"
125+
mamba create --prefix "${BINARIES_ENV_DIR}" -y "${CONDA_PACKAGES_BINARIES[@]}"
124126

125127
echo "Building Environment 3 (Python Libraries)..."
126128
LIB_ENV_EXISTS=0
127129

128-
if [ -d "${LIB_ENV}" ]; then
130+
if [ -d "${LIBRARIES_ENV_DIR}" ]; then
129131
# SCENARIO A: Target environment already exists on host. Inject packages into it.
130132
LIB_ENV_EXISTS=1
131-
echo "Host environment detected at ${LIB_ENV}. Injecting data science packages..."
133+
echo "Host environment detected at ${LIBRARIES_ENV_DIR}. Injecting data science packages..."
132134

133-
if mamba list -p /opt/conda/envs/jupyter --full-name python --json | jq -e 'length == 0' >/dev/null; then
135+
if mamba list -p "${LIBRARIES_ENV_DIR}" --full-name python --json | jq -e 'length == 0' >/dev/null; then
134136
echo "No Python installation found in host environment. Adding python=${LIB_PYTHON_VERSION} to package list."
135-
CONDA_PACKAGES_3+=("conda-forge::python=${LIB_PYTHON_VERSION}")
137+
CONDA_PACKAGES_LIBRARIES+=("conda-forge::python=${LIB_PYTHON_VERSION}")
136138
fi
137-
mamba install --prefix "${LIB_ENV}" -y "${CONDA_PACKAGES_3[@]}"
139+
mamba install --prefix "${LIBRARIES_ENV_DIR}" -y "${CONDA_PACKAGES_LIBRARIES[@]}"
138140
else
139141
# SCENARIO B: Target environment does not exist. Create it from scratch.
140-
echo "No host environment found. Creating standalone environment at ${LIB_ENV}..."
141-
mkdir -p "$(dirname "${LIB_ENV}")"
142+
echo "No host environment found. Creating standalone environment at ${LIBRARIES_ENV_DIR}..."
143+
mkdir -p "$(dirname "${LIBRARIES_ENV_DIR}")"
142144

143-
CONDA_PACKAGES_3+=("conda-forge::python=${LIB_PYTHON_VERSION}")
144-
mamba create --prefix "${LIB_ENV}" -y "${CONDA_PACKAGES_3[@]}"
145+
CONDA_PACKAGES_LIBRARIES+=("conda-forge::python=${LIB_PYTHON_VERSION}")
146+
mamba create --prefix "${LIBRARIES_ENV_DIR}" -y "${CONDA_PACKAGES_LIBRARIES[@]}"
145147
fi
146148

147149
# Install dsub via pip if on GCP. The conda version is outdated.
148-
# dsub is installed in LIB_ENV because it can be used as a Python library, and
149-
# users may want to install additional packages alongside it.
150+
# dsub is installed in LIBRARIES_ENV_DIR because it can be used as a Python
151+
# library, and users may want to install additional packages alongside it.
150152
# PYTHONNOUSERSITE=1 prevents pip from seeing/modifying packages in user site-packages.
151153
if [[ "${CLOUD}" == "gcp" ]]; then
152-
PYTHONNOUSERSITE=1 "${LIB_ENV}/bin/pip" install dsub
154+
PYTHONNOUSERSITE=1 "${LIBRARIES_ENV_DIR}/bin/pip" install dsub
153155
fi
154156

155157
# Force the perl and python scripts to use the correct perl/python
156-
find -L "${WORKBENCH_TOOLS_DIR}/2/bin" -type f -executable -exec \
158+
find -L "${BINARIES_ENV_DIR}/bin" -type f -executable -exec \
157159
sed -i --follow-symlinks \
158-
-e "1s|^#\!/usr/bin/env perl\\r\?$|#\!${WORKBENCH_TOOLS_DIR}/2/bin/perl|" \
159-
-e "1s|^#\!/usr/bin/env python\\r\?$|#\!${WORKBENCH_TOOLS_DIR}/2/bin/python|" {} \;
160+
-e "1s|^#\!/usr/bin/env perl\\r\?$|#\!${BINARIES_ENV_DIR}/bin/perl|" \
161+
-e "1s|^#\!/usr/bin/env python\\r\?$|#\!${BINARIES_ENV_DIR}/bin/python|" {} \;
160162

161163
# Make the login user the owner of the conda environments
162164
chown -R "${USERNAME}:" "${WORKBENCH_TOOLS_DIR}"
163-
chown -R "${USERNAME}:" "${LIB_ENV}"
165+
chown -R "${USERNAME}:" "${LIBRARIES_ENV_DIR}"
164166

165167
{
166168
echo "# Workbench Tools Configuration"
@@ -169,15 +171,15 @@ chown -R "${USERNAME}:" "${LIB_ENV}"
169171
# If it already existed (LIB_ENV_EXISTS=1), we leave the host image's PATH untouched to prevent shadowing.
170172
if [[ "${LIB_ENV_EXISTS}" == "0" ]]; then
171173
# shellcheck disable=SC2016 # we want $PATH to be evaluated at runtime
172-
printf 'export PATH="%s:$PATH"\n' "${LIB_ENV}/bin"
174+
printf 'export PATH="%s:$PATH"\n' "${LIBRARIES_ENV_DIR}/bin"
173175
fi
174176

175177
# Set PATH to include workbench-tools binaries
176178
# shellcheck disable=SC2016 # we want $PATH to be evaluated at runtime
177-
printf 'export PATH="$PATH:%s"\n' "${WORKBENCH_TOOLS_DIR}/1/bin:${WORKBENCH_TOOLS_DIR}/2/bin"
179+
printf 'export PATH="$PATH:%s"\n' "${SAMTOOLS_ENV_DIR}/bin:${BINARIES_ENV_DIR}/bin"
178180

179181
# Set CROMWELL_JAR environment variable
180-
printf 'export CROMWELL_JAR="%s"\n' "${WORKBENCH_TOOLS_DIR}/2/share/cromwell/cromwell.jar"
182+
printf 'export CROMWELL_JAR="%s"\n' "${BINARIES_ENV_DIR}/share/cromwell/cromwell.jar"
181183
} >> "${USER_HOME_DIR}/.bashrc"
182184

183185
# Allow .bashrc to be sourced in non-interactive shells

0 commit comments

Comments
 (0)