1
1
# note: make sure conda srbench environment is installed
2
2
set -e
3
3
4
+ # script to read yaml
5
+ function parse_yaml {
6
+ local prefix=$2
7
+ local s=' [[:space:]]*' w=' [a-zA-Z0-9_]*' fs=$( echo @| tr @ ' \034' )
8
+ sed -ne " s|^\($s \):|\1|" \
9
+ -e " s|^\($s \)\($w \)$s :$s [\" ']\(.*\)[\" ']$s \$ |\1$fs \2$fs \3|p" \
10
+ -e " s|^\($s \)\($w \)$s :$s \(.*\)$s \$ |\1$fs \2$fs \3|p" $1 |
11
+ awk -F$fs ' {
12
+ indent = length($1)/2;
13
+ vname[indent] = $2;
14
+ for (i in vname) {if (i > indent) {delete vname[i]}}
15
+ if (length($3) > 0) {
16
+ vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
17
+ printf("%s%s%s=\"%s\"\n", "' $prefix ' ",vn, $2, $3);
18
+ }
19
+ }'
20
+ }
21
+
22
+ # install base srbench environment if it doesn't exist
23
+ if conda info --envs | grep srbench | grep -v " srbench-" ; then
24
+ echo " existing base srbench environment (not installing)" ;
25
+ else
26
+ echo " installing base srbench environment"
27
+
28
+ mamba env create -y -f base_environment.yml
29
+
30
+ eval " $( conda shell.bash hook) "
31
+
32
+ conda init bash
33
+ fi
34
+
35
+
36
+
4
37
if (( $# == 1 )) ; # check if number of arguments is 1
5
38
then
6
39
subnames=($1 )
@@ -13,56 +46,76 @@ succeeded=()
13
46
14
47
# install methods
15
48
echo " ////////////////////////////////////////"
16
- echo " installing SR methods... "
49
+ echo " installing these SR methods: "
17
50
echo ${subnames}
18
51
echo " ////////////////////////////////////////"
19
52
20
53
# install all methods
21
54
for SUBNAME in ${subnames[@]} ; do
22
55
56
+ build_clone_base_env=" yes"
57
+
23
58
echo " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
24
59
echo " .................... Installing $SUBNAME ..."
25
60
26
61
SUBFOLDER=algorithms/$SUBNAME
27
62
SUBENV=srbench-$SUBNAME
28
- # install method
29
- # cd $SUBFOLDER
30
- pwd
31
- echo " Installing dependencies for ${SUBNAME} "
32
- echo " ........................................"
33
- echo " Making environment"
34
- echo " ........................................"
35
- # conda create --name $SUBENV --clone srbench
36
- mamba env create --name $SUBENV -f base_environment.yml -f ${SUBFOLDER} /environment.yml
37
- # if test -f "environment.yml" ; then
38
- # echo "Update alg env from environment.yml"
39
- # echo "........................................"
40
- # mamba env update -n $SUBENV -f ${SUBFOLDER}/environment.yml
41
- # fi
42
-
43
- if test -f " requirements.txt" ; then
63
+
64
+ # #######################################
65
+ # read yaml
66
+ eval $( parse_yaml $SUBFOLDER /metadata.yml)
67
+ # #######################################
68
+
69
+ if [ " ${build_clone_base_env} " == " yes" ] ; then
70
+ echo " $build_clone_base_env " is set to yes
71
+
72
+ echo " ........................................"
73
+ echo " Cloning base environment"
74
+ echo " ........................................"
75
+
76
+ if conda info --envs | grep -q $SUBENV ; then
77
+ echo " not cloning base because ${SUBENV} already exists"
78
+ else
79
+ conda create --name $SUBENV --clone srbench
80
+ # update from base environment
81
+ if test -f " ${SUBFOLDER} /environment.yml" ; then
82
+ echo " Update alg env from environment.yml"
83
+ echo " ........................................"
84
+ mamba env update -n $SUBENV -f ${SUBFOLDER} /environment.yml
85
+ fi
86
+ fi
87
+ else
88
+
89
+ echo " ........................................"
90
+ echo " Creating environment ${SUBENV} from scratch"
91
+ echo " ........................................"
92
+ mamba create -n $SUBENV -f ${SUBFOLDER} /environment.yml
93
+ fi
94
+
95
+
96
+ if test -f " ${SUBFOLDER} /requirements.txt" ; then
44
97
echo " Update alg env from requirements.txt"
45
98
echo " ........................................"
46
99
mamba run -n srbench-${SUBENV} pip install -r ${SUBFOLDER} /requirements.txt
47
100
fi
48
101
49
- eval " $( conda shell.bash hook) "
50
- conda init bash
51
- conda activate $SUBENV
102
+ # eval "$(conda shell.bash hook)"
103
+ # conda init bash
104
+ # conda activate $SUBENV
52
105
cd $SUBFOLDER
53
106
if test -f " install.sh" ; then
54
107
echo " running install.sh..."
55
108
echo " ........................................"
56
- bash install.sh
109
+ mamba run -n $SUBENV bash install.sh
57
110
else
58
111
echo " ::warning::No install.sh file found in ${SUBFOLDER} ."
59
112
echo " Assuming the method is a conda package specified in environment.yml."
60
113
fi
61
114
cd ../../
62
115
63
116
# Copy files and environment
64
- # echo "Copying files and environment to experiment/methods ..."
65
- # echo "........................................"
117
+ echo " Copying files and environment to experiment/methods ..."
118
+ echo " ........................................"
66
119
# cd ../../
67
120
mkdir -p experiment/methods/$SUBNAME
68
121
cp $SUBFOLDER /regressor.py experiment/methods/$SUBNAME /
0 commit comments