Skip to content

Commit

Permalink
Add flag to creation script
Browse files Browse the repository at this point in the history
  • Loading branch information
albrja committed Sep 10, 2024
1 parent 329c313 commit 6cf53b5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@ Help()
echo "Syntax: source environment.sh [-h|t|v]"
echo "options:"
echo "h Print this Help."
echo "v Verbose mode."
echo "t Type of conda environment. Either 'simulation' (default) or 'artifact'."
echo "n Make a new conda environment even if one currently exists."
}

# Define variables
username=$(whoami)
env_type="simulation"
make_new="no"

# Process input options
while getopts ":ht:" option; do
while getopts ":hnt:" option; do
case $option in
h) # display help
Help
return;;
t) # Type of conda environment to build
env_type=$OPTARG;;
n) # Create new environment
make_new="yes";;
\?) # Invalid option
echo "Error: Invalid option"
return;;
Expand Down Expand Up @@ -62,6 +65,11 @@ if [[ $create_env == '' ]]; then
echo "Environment $env_name does not exist."
create_env="yes"
env_exists="no"
elif [[ $make_new == 'yes' ]]; then
# User has requested to make a new environment
echo "Making a new environment."
create_env="yes"
env_exists="yes"
else
env_exists="yes"
conda activate $env_name
Expand Down Expand Up @@ -105,7 +113,9 @@ fi

if [[ $create_env == 'yes' ]]; then
if [[ $env_exists == 'yes' ]]; then
conda deactivate
if [[ $env_name == $CONDA_DEFAULT_ENV ]]; then
conda deactivate
fi
conda remove -n $env_name --all -y
fi
# Create conda environment
Expand Down

0 comments on commit 6cf53b5

Please sign in to comment.