-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlambda.sh
More file actions
82 lines (61 loc) · 2.16 KB
/
lambda.sh
File metadata and controls
82 lines (61 loc) · 2.16 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
#
# Configuration and Github SSH key setup
#
# What is the IP address of the Lambda Labs Ubuntu machine?
export LAMBDA_IP="<YOUR_LAMBDA_IP_ADDRESS>"
# Which region FS are we using?
export LAMBDA_REGION_FS="default-us-south-2"
# Lambda Labs SSH key
export LAMBDA_LABS_KEY="lambda-labs-ssh-key.pem"
# Copy over Github SSH keys
scp -i ~/.ssh/${LAMBDA_LABS_KEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ~/.ssh/id_lambda_github* ubuntu@${LAMBDA_IP}:.ssh/
#
# SSH over to the Lambda Labs machine. Run the rest of the code below locally there.
#
# TODO: Fix this so the script below runs from this SSH command.
#
ssh -i ~/.ssh/${LAMBDA_LABS_KEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ubuntu@${LAMBDA_IP}
# Do everything on the persistent filesystem
cd ${HOME}/${LAMBDA_REGION_FS}
# Update apt
sudo apt update -y
# Install Java for PySpark ETL
sudo apt install openjdk-11-jre-headless -y
#
# Anaconda Python 3.12 in a conda environment
#
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
export MINICONDA_HOME="${HOME}/${LAMBDA_REGION_FS}/miniconda3"
./Miniconda3-latest-Linux-x86_64.sh -b -p "${MINICONDA_HOME}"
export PATH="${MINICONDA_HOME}/bin:${PATH}"
conda init bash
source ~/.bashrc
# Accept Anaconda TOS
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
# Create the project's _environment_
conda create -n eridu python=3.12 -y
conda activate eridu
# Install poetry and disable virtualenvs - we have conda
sudo apt install pipx -y
pipx install --force poetry
poetry config virtualenvs.create false
#
# Github SSH authentication and code checkout
#
cat >> ~/.ssh/config <<'EOF'
Host github.com
AddKeysToAgent yes
StrictHostKeyChecking no
IdentityFile ~/.ssh/id_lambda_github
EOF
eval "$(ssh-agent -s)"
# Clone the project repository and install its dependencies
cd ${HOME}/${LAMBDA_REGION_FS}
git clone git@github.com:Graphlet-AI/eridu.git
cd eridu
poetry install
echo 'export PATH=/home/ubuntu/.local/bin:$PATH' >> ~/.bashrc
source ~/.bashrc