forked from patnr/HistoryMatching
-
Notifications
You must be signed in to change notification settings - Fork 0
/
colab_bootstrap.sh
44 lines (34 loc) · 1.08 KB
/
colab_bootstrap.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
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
# Colab doesn't provide
# - Auto-installing requirements.txt
# - Pre-loading data/modules (aside from the notebook itself)
# This script takes care of the above by cloning the full (shallow) repo.
# Install requirements
main () {
set -e
# Clear any existing REPO for a fresh git clone
rm -rf REPO
# Download repo
URL=https://github.com/patnr/HistoryMatching.git
if [[ ! -d REPO ]]; then git clone --depth=1 $URL REPO; fi
# https://pythonspeed.com/articles/upgrade-pip/
pip install --upgrade pip
# Install requirements
pip install -r REPO/requirements.txt
# Put repo contents (including hidden files) in PWD
shopt -s dotglob
cp -r REPO/notebooks/* ./
}
# Only run if we're on colab
if python -c "import google.colab" 2>/dev/null; then
# Use `bash -s -- --debug` to get verbose output
if echo $@ | grep -E -- '(--debug|-v)' > /dev/null ; then
main
else
# Quiet
main > /dev/null 2>&1
fi
echo "Initialization for Colab done."
else
echo "Not running on Colab => Didn't do anything."
fi