-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_script.sh
executable file
·81 lines (74 loc) · 2.78 KB
/
install_script.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
#!/bin/bash
# D. Nurkowski ([email protected])
AUTHOR="Daniel Nurkowski <[email protected]>"
SPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/"
DATA_LOCAL="./data/processed"
DATA_REMOTE="https://www.repository.cam.ac.uk/bitstream/handle/1810/318115/OSCML_Data.zip?sequence=1&isAllowed=y"
echo
function check_conda {
echo "Verifying conda installation."
echo "-------------------------------------------------------------"
conda_version=$(conda --version)
if [ $? -eq 0 ]; then
echo
echo "INFO: Found "$conda_version
else
echo "ERROR: Could not find conda installation. On Windows, you must run this script from Anaconda Prompt for conda to be correctly located. Aborting installation."
read -n 1 -s -r -p "Press any key to continue"
exit -1
fi
echo
echo
}
function recreate_conda_env {
echo "Creating / updating conda environment and installing the oscml package."
echo "-------------------------------------------------------------"
# This will recreate conda environment
echo -n "Provide conda environment name to be created for this project: "
read CONDA_ENV_NAME
# Remove the environment (if one already exists)
conda remove --name $CONDA_ENV_NAME --all
# Update the environment name in the yml file
sed -i '1s/.*/name: '$CONDA_ENV_NAME'/' environment.yml
# Create the new environment
conda env create -f environment.yml
echo
echo
}
function get_data_from_server {
echo "Downloading required project data..."
echo "-------------------------------------------------------------"
echo
curl $DATA_REMOTE -o $DATA_LOCAL"/data.zip"
unzip $DATA_LOCAL"/data.zip" -d $DATA_LOCAL
rm -f $DATA_LOCAL"/data.zip"
echo
echo
}
if [ "$1" == "-i" ]
then
check_conda
recreate_conda_env
elif [ "$1" == "-d" ]
then
get_data_from_server
elif [ "$1" == "-a" ]
then
check_conda
recreate_conda_env
get_data_from_server
else
echo "==============================================================================================================="
echo "OSCML project installation script."
echo
echo "Please run the script with one of the following flags set:"
echo "--------------------------------------------------------------------------------------------------------"
echo " -i : creates conda environment for this project and installs the oscml package in it including all"
echo " the necessary dependencies"
echo " -d : downloads project data from the remote location"
echo " -a : performs all the above steps in one go"
fi
echo
echo "==============================================================================================================="
echo
read -n 1 -s -r -p "Press any key to continue"