-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathembed_wrapper.sh
More file actions
executable file
·86 lines (74 loc) · 1.52 KB
/
embed_wrapper.sh
File metadata and controls
executable file
·86 lines (74 loc) · 1.52 KB
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
#!/bin/bash
# parse
DELETE=false
CACHE=true
CMD=embed.py
REINSTALL=""
WRAPPER_PATH=""
while [[ $# -gt 0 ]]; do
case $1 in
-d|--delete)
DELETE=true
shift
;;
-r|--reinstall)
REINSTALL=true
shift
;;
--no-cache)
CACHE=false
shift
;;
--clock)
CMD=clock.py
shift
;;
--embed)
CMD=embed.py
shift
;;
*)
WRAPPER_PATH=$1
shift
;;
-*|--*)
echo "Unknown option: $1"
exit 1
;;
esac
done
run() {
cd $WRAPPER_PATH
# install environment
if [ -d "venv" ] && [ -z "$REINSTALL" ]; then
source venv/bin/activate
export INSTALL_DEP=false
else
export INSTALL_DEP=true
python_version=$(cat .python-version)
eval "$(pyenv init -)"
pyenv shell $python_version
if [ ! -d "venv" ]; then
python -m venv venv
fi
source venv/bin/activate
pip install -r ../../base_requirements.txt
fi
source ./init.sh
cd ../../
export PYTHONPATH=$PYTHONPATH:.:$WRAPPER_PATH
python -u $CMD --multirun +experiment=$HYDRA_EXPERIMENT ++cache=$CACHE
echo "Done"
}
delete() {
rm -rf $WRAPPER_PATH/venv
}
if [ -z "$WRAPPER_PATH" ]; then
echo "Please provide the path to the wrapper"
exit 1
fi
if $DELETE; then
delete
else
run
fi