Skip to content

Commit 3deaf60

Browse files
committed
add alg install script
1 parent 4af3739 commit 3deaf60

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

install_algorithms.sh

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# note: make sure conda srbench environment is installed
2+
set -e
3+
4+
if (($#==1)); #check if number of arguments is 1
5+
then
6+
subnames=($1)
7+
else
8+
subnames=$(ls algorithms/)
9+
fi
10+
11+
failed=()
12+
succeeded=()
13+
14+
# install methods
15+
echo "////////////////////////////////////////"
16+
echo "installing SR methods..."
17+
echo ${subnames}
18+
echo "////////////////////////////////////////"
19+
20+
# install all methods
21+
for SUBNAME in ${subnames[@]} ; do
22+
23+
echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
24+
echo ".................... Installing $SUBNAME ..."
25+
26+
SUBFOLDER=algorithms/$SUBNAME
27+
SUBENV=srbench-$SUBNAME
28+
# install method
29+
# cd $SUBFOLDER
30+
pwd
31+
echo "Installing dependencies for ${SUBNAME}"
32+
echo "........................................"
33+
echo "Copying base environment"
34+
echo "........................................"
35+
conda create --name $SUBENV --clone srbench
36+
if test -f "environment.yml" ; then
37+
echo "Update alg env from environment.yml"
38+
echo "........................................"
39+
mamba env update -n $SUBENV -f ${SUBFOLDER}/environment.yml
40+
fi
41+
42+
if test -f "requirements.txt" ; then
43+
echo "Update alg env from requirements.txt"
44+
echo "........................................"
45+
mamba run -n srbench-${SUBENV} pip install -r ${SUBFOLDER}/requirements.txt
46+
fi
47+
48+
eval "$(conda shell.bash hook)"
49+
conda init bash
50+
conda activate $SUBENV
51+
if test -f "install.sh" ; then
52+
echo "running install.sh..."
53+
echo "........................................"
54+
cd $SUBFOLDER
55+
bash install.sh
56+
cd ../../
57+
else
58+
echo "::warning::No install.sh file found in ${SUBFOLDER}."
59+
echo " Assuming the method is a conda package specified in environment.yml."
60+
fi
61+
62+
# Copy files and environment
63+
# echo "Copying files and environment to experiment/methods ..."
64+
# echo "........................................"
65+
# cd ../../
66+
mkdir -p experiment/methods/$SUBNAME
67+
cp $SUBFOLDER/regressor.py experiment/methods/$SUBNAME/
68+
cp $SUBFOLDER/metadata.yml experiment/methods/$SUBNAME/
69+
touch experiment/methods/$SUBNAME/__init__.py
70+
71+
# export env
72+
echo "Exporting environment"
73+
# conda env export -n $SUBENV > $SUBFOLDER/environment.lock.yml
74+
conda env export -n $SUBENV > $SUBFOLDER/environment.lock.yml
75+
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
76+
done

0 commit comments

Comments
 (0)