-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_env.sh
executable file
·34 lines (29 loc) · 951 Bytes
/
setup_env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Setup the Conda environment for the project
ENV_NAME="a3i"
YAML_FILE="env.yml"
# Ensure `conda` is initialized
eval "$(conda shell.bash hook)"
# Check if the Conda environment exists
conda env list | grep -q "^$ENV_NAME "
# shellcheck disable=SC2181
if [ $? -eq 0 ]; then
echo "Conda environment '$ENV_NAME' already exists."
else
echo "Conda environment '$ENV_NAME' does not exist. Creating it from '$YAML_FILE'..."
if [ -f "$YAML_FILE" ]; then
conda env create -f "$YAML_FILE"
if [ $? -eq 0 ]; then
echo "Environment '$ENV_NAME' created successfully."
else
echo "Error: Failed to create the environment. Check the YAML file."
exit 1
fi
else
echo "Error: YAML file '$YAML_FILE' not found."
exit 1
fi
fi
# Output the command to activate the environment in the parent shell
echo "Run the following command to activate the environment in your shell:"
echo "conda activate $ENV_NAME"