-
Notifications
You must be signed in to change notification settings - Fork 80
/
install.sh
executable file
·126 lines (102 loc) · 3.88 KB
/
install.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# note: make sure conda srbench environment is installed
set -e
# script to read yaml
function parse_yaml {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
}
}'
}
# install base srbench environment if it doesn't exist
if conda info --envs | grep srbench | grep -v "srbench-"; then
echo "existing base srbench environment (not installing)";
else
echo "installing base srbench environment"
mamba env create -f base_environment.yml
eval "$(conda shell.bash hook)"
conda init bash
fi
if (($#==1)); #check if number of arguments is 1
then
subnames=($1)
else
subnames=$(ls algorithms/)
fi
failed=()
succeeded=()
# install methods
echo "////////////////////////////////////////"
echo "installing these SR methods:"
echo ${subnames}
echo "////////////////////////////////////////"
# install all methods
for SUBNAME in ${subnames[@]} ; do
build_clone_base_env="yes"
echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
echo ".................... Installing $SUBNAME ..."
SUBFOLDER="./algorithms/$SUBNAME"
SUBENV="srbench-$SUBNAME"
########################################
# read yaml
eval $(parse_yaml $SUBFOLDER/metadata.yml)
########################################
echo "build_clone_base_env: ${build_clone_base_env}"
if [ ${build_clone_base_env} == "yes" ] ; then
echo "........................................"
echo "Cloning base environment"
echo "........................................"
if conda info --envs | grep -q $SUBENV ; then
echo "not cloning base because ${SUBENV} already exists"
else
conda create --name $SUBENV --clone srbench
# update from base environment
if test -f "${SUBFOLDER}/environment.yml" ; then
echo "Update alg env from environment.yml"
echo "........................................"
mamba env update -n $SUBENV -f ${SUBFOLDER}/environment.yml
fi
fi
else
echo "........................................"
echo "Creating environment ${SUBENV} from scratch"
echo "........................................"
mamba create -n $SUBENV -f ${SUBFOLDER}/environment.yml
fi
if test -f "${SUBFOLDER}/requirements.txt" ; then
echo "Update alg env from requirements.txt"
echo "........................................"
mamba run -n ${SUBENV} pip install -r ${SUBFOLDER}/requirements.txt
fi
# eval "$(conda shell.bash hook)"
# conda init bash
# conda activate $SUBENV
cd $SUBFOLDER
if test -f "install.sh" ; then
echo "running install.sh..."
echo "........................................"
mamba run -n $SUBENV bash install.sh
else
echo "::warning::No install.sh file found in ${SUBFOLDER}."
echo " Assuming the method is a conda package specified in environment.yml."
fi
cd ../../
# Copy files and environment
bash scripts/copy_algorithm_files.sh $SUBNAME
# export env
echo "Exporting environment"
echo "........................................"
# conda env export -n $SUBENV > $SUBFOLDER/environment.lock.yml
conda env export -n $SUBENV > $SUBFOLDER/environment.lock.yml
conda env export -n $SUBENV
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
done