Skip to content

Commit 150fa6d

Browse files
author
Andrew Delman
committed
updates to jupyter_env_setup.sh
1 parent 1d7c256 commit 150fa6d

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

ECCO-ACCESS/Cloud_access_to_ECCO_datasets/jupyter_env_setup.sh

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,31 @@
1212
# ~/ECCO-v4-Python-Tutorial/ECCO-ACCESS/Cloud_access_to_ECCO_datasets/jupyter_env_setup.sh
1313

1414

15+
1516
# # Start body of script
1617

18+
red_start='\033[0;31m'
19+
blue_start='\033[0;34m'
20+
nocolor_start='\033[0m'
21+
1722
# install wget
1823
sudo dnf install wget -y
24+
echo -e "${red_start}Installed wget${nocolor_start}"
1925

20-
# retrieve and install miniforge in /opt/
26+
# install tmux
27+
sudo dnf install tmux -y
28+
echo -e "${red_start}Installed tmux${nocolor_start}"
29+
30+
# retrieve and install miniforge in /tmp/
2131
# assuming EBS volume is already attached to instance
32+
echo -e "${red_start}Starting Miniforge3 installation${nocolor_start}"
2233
mkdir -p /tmp
2334
wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh" -O /tmp/Miniforge3.sh
24-
sudo bash /tmp/Miniforge3.sh -b -p /opt/conda
25-
sudo chmod -R a+w /opt/conda
26-
source "/opt/conda/etc/profile.d/conda.sh"
27-
source "/opt/conda/etc/profile.d/mamba.sh"
35+
bash /tmp/Miniforge3.sh -b -p /tmp/conda
36+
rm -f /tmp/Miniforge.sh
37+
source "/tmp/conda/etc/profile.d/conda.sh"
38+
source "/tmp/conda/etc/profile.d/mamba.sh"
2839

29-
red_start='\033[0;31m'
30-
nocolor_start='\033[0m+'
3140
echo -e "${red_start}Completed Miniforge3 installation${nocolor_start}"
3241

3342
# add conda and mamba to path
@@ -46,6 +55,7 @@ echo -e "${red_start}Created jupyter environment${nocolor_start}"
4655

4756
# install python packages (using mamba) in jupyter environment
4857
mamba activate jupyter
58+
echo -e "${red_start}Installing Python packages in jupyter environment${nocolor_start}"
4959
mamba install requests tqdm numpy pandas -y
5060
mamba install xorg-libice libexpat libevent -y
5161
mamba install nspr alsa-lib libogg libpq -y
@@ -90,34 +100,35 @@ pip install ecco_v4_py
90100

91101
echo -e "${red_start}Completed Python package installations${nocolor_start}"
92102

103+
echo -e "${red_start}Setting up NASA Earthdata authentication${nocolor_start}"
93104
# NASA Earthdata authentication
94105
# check if credentials are already archived in ~/.netrc, and if not then prompt the user for them
95106
earthdata_cred_stored=0
96107
if [ -f ~/.netrc ]; then
97108
if grep -q "machine urs.earthdata.nasa.gov" ~/.netrc; then
98109
earthdata_cred_stored=1
110+
echo -e "${red_start}Earthdata credentials already archived"
99111
fi
100112
fi
101113
if [ $earthdata_cred_stored -eq 0 ]; then
102114
if [ -f ~/.netrc ]; then sudo chmod 600 ~/.netrc; fi
103115
read -p 'NASA Earthdata username: ' uservar
104116
read -sp 'NASA Earthdata password: ' passvar
105117
echo -e "machine urs.earthdata.nasa.gov\n login ${uservar}\n password ${passvar}\n" >> ~/.netrc
118+
119+
echo -e "\n${red_start}NASA Earthdata authentication info archived in ~\/.netrc${nocolor_start}"
106120
fi
107121
sudo chmod 400 ~/.netrc
108122

109-
echo -e "${red_start}Set up NASA Earthdata authentication${nocolor_start}"
110-
111123
# set up Jupyter lab, to be opened in a tmux session using password
112124
PW="$(python3 -c 'from notebook.auth import passwd; import getpass; print(passwd(getpass.getpass(), algorithm="sha256"))')"
113-
jlab_start="\'jupyter lab --no-browser --autoreload --port=9889 --ip=\'127.0.0.1\' --NotebookApp.token=\'\' --NotebookApp.password=\"$PW\" --notebook-dir=\"~/ECCO-v4-Python-Tutorial/Tutorials_as_Jupyter_Notebooks\" \'"
125+
jlab_start="\'mamba activate jupyter && jupyter lab --no-browser --autoreload --port=9889 --ip=\'127.0.0.1\' --NotebookApp.token=\'\' --NotebookApp.password=\"$PW\" --notebook-dir=\"~/ECCO-v4-Python-Tutorial/Tutorials_as_Jupyter_Notebooks\" \'"
114126
tmux new-session -d -s jupyterlab ${jlab_start}
115127

116-
blue_start='\033[0;34m'
117128
echo -e "${red_start}Started Jupyter lab in tmux session jupyterlab"
118129
echo -e "${red_start}Access from your local machine in a browser window at"
119130
echo -e "${blue_start}http://127.0.0.1:9889/"
120131
echo -e "${red_start}tmux session can be accessed with"
121132
echo -e "${blue_start}tmux -a -t jupyterlab"
122133
echo -e "${red_start}and terminated with"
123-
echo -e "${blue_start}tmux kill-ses -t jupyterlab"
134+
echo -e "${blue_start}tmux kill-ses -t jupyterlab${nocolor_start}"

0 commit comments

Comments
 (0)