-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSETUP.sh
executable file
·110 lines (101 loc) · 3.9 KB
/
SETUP.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
# Installs Opal dependencies and downloads some data files.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR"
#===================
# version comparison function from https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
#===================
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
echo ========================================
echo Testing dependency: vowpal-wabbit command \'vw\'
if [ -x "$(command -v vw)" ]; then
echo "vowpal-wabbit found. Testing version..."
vercomp $(vw --version) 8.1.1
code=$?
if [ "$code" -eq 0 ] || [ "$code" -eq 1 ]; then
echo "vowpal-wabbit version >=8.1.1 found."
else
echo "ERROR: vowpal-wabbit version <8.1.1. Please update."
echo "e.g. on Ubuntu, run \"sudo apt-get install vowpal-wabbit\"."
echo "On other OS, see install instructions here: https://github.com/VowpalWabbit/vowpal_wabbit"
echo "Note: Python pip package vowpalwabbit does not install the vw command, so will not work."
exit 1
fi
else
echo "ERROR: vowpal-wabbit not found. Please install."
echo "e.g. on Ubuntu, run \"sudo apt-get install vowpal-wabbit\"."
echo "On other OS, see install instructions here: https://github.com/VowpalWabbit/vowpal_wabbit"
echo "Note: Python pip package vowpalwabbit does not install the vw command, so will not work."
exit 1
fi
echo ========================================
echo Testing Python package dependencies:
if ! [ -x "$(command -v python3)" ]; then
echo "Python 3 must be installed. See your package manager for details."
exit 1
fi
python3 -c "import pandas, sklearn"
if [ "$?" -eq 1 ]; then
echo "Python packages pandas and/or sklearn not found. Please install."
echo "e.g. if using pip installer, use \"pip3 install wheel pandas sklearn\""
echo "Note, if you are using Ubuntu and do not have pip installed, you can install using \"sudo apt-get install python3-pip\"."
echo "Otherwise, see instructions here: https://pip.pypa.io/en/stable/installing/"
exit 1
fi
echo ========================================
echo Downloading and extracting example datasets
echo ========================================
if [ ! -f data/examples.installed ]; then
wget -c http://giant.csail.mit.edu/opal/data.tar.bz2 || curl -O http://giant.csail.mit.edu/opal/data.tar.bz2
tar -xjf data.tar.bz2
rm data.tar.bz2
touch data/examples.installed
else
echo "Examples already installed"
fi
echo ========================================
echo Installation complete!
echo Test out Opal on the exmaple data with:
echo ./opal.py simulate data/A1/test data/A1/train out_dir -c0.1 -r
totalk=$(awk '/^MemTotal:/{print $2}' /proc/meminfo)
if [ "$?" -ne 0 ]; then
echo ========================================
echo WARNING: Cannot access /proc/meminfo to check for system memory.
echo Opal\'s default parameters may not work with less than 32 GiB of RAM.
echo Opal is also not guaranteed to be compatible with non-Linux OSes. YMMV
echo ========================================
elif [ "$totalk" -lt 33550000 ]; then
echo ========================================
echo WARNING: System has less than 32 GiB of RAM.
echo Opal may run out of memory for the model using standard parameters.
echo ========================================
fi