-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start adding a script to manage the python environment, this addresses …
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash -f | ||
# | ||
# manage_python_env -- setup the python environment in order to use CTSM python tools | ||
# | ||
# Simple bash script to setup the python environment for the user so they can run the CTSM | ||
# python tools using "conda". | ||
# | ||
|
||
# Check if conda is in your path | ||
conda --help >& /dev/null | ||
if [ $? != 0 ]; then | ||
echo "conda is NOT in your path add it with modules or whatever is required on your system to get it in your path" | ||
echo "on cheyenne use -- module load conda" | ||
exit -1 | ||
fi | ||
ctsm_python=ctsm_py | ||
|
||
|
||
#---------------------------------------------------------------------- | ||
# Usage subroutine | ||
usage() { | ||
echo "" | ||
echo "**********************" | ||
echo "usage:" | ||
echo "./manage_python_env" | ||
echo "" | ||
echo "valid arguments: " | ||
echo "[-h|--help] " | ||
echo " Displays this help message" | ||
echo "**********************" | ||
} | ||
|
||
while [ $# -gt 0 ]; do | ||
case $1 in | ||
-h|--help ) | ||
usage | ||
exit 0 | ||
;; | ||
* ) | ||
echo "ERROR:: invalid argument sent in: $2" | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
echo "Use conda to install the python environment needed to run the CTSM python tools in the conda environment: $ctsm_python" | ||
|
||
# Check if the environment already exists, if it does continue, if not create it | ||
conda list -n $ctsm_python >& /dev/null | ||
if [ $? != 0 ]; then | ||
echo "Create $ctsm_python" | ||
conda create -n $ctsm_python | ||
else | ||
echo "$ctsm_python environment already exists" | ||
fi | ||
echo "Install $ctsm_python this can take a long time, be patient...." | ||
conda install --yes -q -n $ctsm_python --file python/conda_env_ctsm_py.txt | ||
if [ $? != 0 ]; then | ||
echo "Trouble installing the $ctsm_python python environment" | ||
exit -2 | ||
fi | ||
echo "Activate $ctsm_python" | ||
conda activate $ctsm_python | ||
if [ $? != 0 ]; then | ||
echo "Trouble activating the $ctsm_python python environment fix as outlined above and then run" | ||
echo "conda activate $ctsm_python" | ||
echo "On CGD systems for tcsh you need to source the conda.csh under the /etc/profile.d/ subdirectory of the /usr/local/anaconda-* version you are using for python" | ||
exit -3 | ||
fi | ||
echo "Successfully installed the $ctsm_python python environment" |