Skip to content

Commit a07021c

Browse files
update init conda env
Signed-off-by: Yiheng Wang <[email protected]>
1 parent f767da8 commit a07021c

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

ci/run_premerge_cpu.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,13 @@ init_conda_env() {
8282
local bundle_identifier="$2"
8383
local conda_env_name="conda_env_${bundle_identifier}"
8484

85-
if [[ -z "$CONDA_SHLVL" || "$CONDA_SHLVL" -eq 0 ]]; then
86-
if [ -n "$CONDA_EXE" ]; then
87-
source "$(dirname "$CONDA_EXE")/../etc/profile.d/conda.sh"
88-
elif [ -n "$MINICONDA_PATH_0" ] && [ -f "$MINICONDA_PATH_0/etc/profile.d/conda.sh" ]; then
89-
source "$MINICONDA_PATH_0/etc/profile.d/conda.sh"
90-
else
91-
echo "Warning: Could not reliably source conda.sh for Conda activation."
92-
fi
85+
# Always source conda.sh to ensure conda activate is available
86+
if [ -n "$CONDA_EXE" ] && [ -f "$(dirname "$CONDA_EXE")/../etc/profile.d/conda.sh" ]; then
87+
source "$(dirname "$CONDA_EXE")/../etc/profile.d/conda.sh"
88+
elif [ -n "$MINICONDA_PATH_0" ] && [ -f "$MINICONDA_PATH_0/etc/profile.d/conda.sh" ]; then
89+
source "$MINICONDA_PATH_0/etc/profile.d/conda.sh"
90+
else
91+
echo "Warning: Could not reliably source conda.sh for Conda activation."
9392
fi
9493

9594
if conda env list | grep -q "^${conda_env_name}[[:space:]]"; then

ci/run_premerge_gpu.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,13 @@ init_conda_env() {
6969
local bundle_identifier="$2"
7070
local conda_env_name="conda_env_${bundle_identifier}"
7171

72-
if [[ -z "$CONDA_SHLVL" || "$CONDA_SHLVL" -eq 0 ]]; then
73-
if [ -n "$CONDA_EXE" ]; then
74-
source "$(dirname "$CONDA_EXE")/../etc/profile.d/conda.sh"
75-
elif [ -n "$MINICONDA_PATH_0" ] && [ -f "$MINICONDA_PATH_0/etc/profile.d/conda.sh" ]; then
76-
source "$MINICONDA_PATH_0/etc/profile.d/conda.sh"
77-
else
78-
echo "Warning: Could not reliably source conda.sh for Conda activation."
79-
fi
72+
# Always source conda.sh to ensure conda activate is available
73+
if [ -n "$CONDA_EXE" ] && [ -f "$(dirname "$CONDA_EXE")/../etc/profile.d/conda.sh" ]; then
74+
source "$(dirname "$CONDA_EXE")/../etc/profile.d/conda.sh"
75+
elif [ -n "$MINICONDA_PATH_0" ] && [ -f "$MINICONDA_PATH_0/etc/profile.d/conda.sh" ]; then
76+
source "$MINICONDA_PATH_0/etc/profile.d/conda.sh"
77+
else
78+
echo "Warning: Could not reliably source conda.sh for Conda activation."
8079
fi
8180

8281
if conda env list | grep -q "^${conda_env_name}[[:space:]]"; then

0 commit comments

Comments
 (0)