|
1 |
| -# note: make sure conda environment is installed |
2 |
| -# and activated before running install. |
3 |
| -# see configure.sh |
4 |
| -# or run this as: |
5 |
| -# conda run -n srbench bash install.sh |
| 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 |
6 | 10 |
|
7 | 11 | failed=()
|
8 | 12 | succeeded=()
|
9 | 13 |
|
10 | 14 | # install methods
|
11 | 15 | echo "////////////////////////////////////////"
|
12 |
| -echo "installing SR methods from scripts..." |
| 16 | +echo "installing SR methods..." |
| 17 | +echo ${subnames} |
13 | 18 | echo "////////////////////////////////////////"
|
14 | 19 |
|
15 |
| -# move to methods folder |
16 |
| -cd experiment/methods/src/ |
17 |
| - |
18 | 20 | # install all methods
|
19 |
| -for install_file in $(ls *.sh) ; do |
| 21 | +for SUBNAME in ${subnames[@]} ; do |
| 22 | + |
20 | 23 | echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
|
21 |
| - echo ".................... Running $install_file..." |
22 |
| - |
23 |
| - name=${install_file%.sh} |
24 |
| - # Option to redirect logs: |
25 |
| - # bash ${install_file} > "${name}.log" 2> "${name}.err" |
26 |
| - bash ${install_file} |
27 |
| - |
28 |
| - if [ $? -gt 0 ]; |
29 |
| - then |
30 |
| - # failed+=("${install_file}") |
31 |
| - failed+=("$name") |
32 |
| - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $install_file FAILED" |
| 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 ../../ |
33 | 57 | else
|
34 |
| - succeeded+=("$install_file") |
35 |
| - echo "........................................ $install_file complete" |
| 58 | + echo "::warning::No install.sh file found in ${SUBFOLDER}." |
| 59 | + echo " Assuming the method is a conda package specified in environment.yml." |
36 | 60 | fi
|
37 |
| - echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" |
38 |
| -done |
39 | 61 |
|
40 |
| -echo "${#succeeded[@]} successful installs:" |
41 |
| -for s in ${succeeded[@]} ; do |
42 |
| - echo " "$s |
43 |
| -done |
44 |
| -echo "${#failed[@]} failed installs:" |
45 |
| -for f in ${failed[@]} ; do |
46 |
| - echo " "$f |
47 |
| -done |
| 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 |
48 | 70 |
|
49 |
| -if [ ${#failed[@]} -gt 0 ] ; then |
50 |
| - exit 1 |
51 |
| -else |
52 |
| - echo "All installations completed successfully." |
53 |
| -fi |
| 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