-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.sh
executable file
·145 lines (123 loc) · 2.48 KB
/
run.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# user specified cation
ACTION=$1
# directory to python virtual environemnt, and binaries
PY_DIR=pyvirenv
PY_BIN=${PY_DIR}/bin/python3
PIP_BIN=${PY_DIR}/bin/pip3
# model entry point
HARNESS=./harness.py
# number of process to use for batching; throttle based on memory (2 for 64G)
BATCH_WORKERS=2
usage() {
# usage doc
echo -e "usage:
$0 pyenv <python binary>
$0 pydep
$0 batch
$0 <testconfig | traintest | stop | paperresults>
$0 clean [--all]
Python binary is the path to the python3 binary such as /usr/local/python/bin/python3."
}
prompt() {
echo "${1}--CNTRL-C to stop"
read
}
pyenv() {
PY_SRC_BIN=$1
if [ -z "$PY_SRC_BIN" ] ; then
usage
exit 1
fi
echo "creating python virtual environment in $PY_DIR"
if [ -e $PY_DIR ] ; then
echo "already exists"
exit 1
fi
$PY_SRC_BIN -m venv --copies $PY_DIR
echo "upgrading pip"
$PIP_BIN install --upgrade pip
}
pydep() {
$PIP_BIN install -r src/requirements.txt
$PIP_BIN install -r src/requirements-mednlp.txt --no-deps
}
batch() {
echo "rebatching using $BATCH_WORKERS workers"
$HARNESS batch --clear --override batch_stash.workers=${BATCH_WORKERS}
}
testconfig() {
for i in models/*.conf ; do
echo "testing $i"
$HARNESS traintest -p -c $i --override resources/debug.conf
done
}
traintest() {
for c in models/* ; do
echo "training and testing on ${c}..."
$HARNESS traintest --config $c
echo "training and testing complete on ${c}----"
done
}
stop() {
touch data/model/update.json
}
paperresults() {
$HARNESS stats
$HARNESS dumpmetrics --config models/fasttext.conf
}
hyperparams() {
models="fasttext glove300 glove50 majorsent-fixed-biobert majorsent-fixed majorsent-fixed-crf-biobert majorsent-fixed-crf word2vec"
mkdir -p hp
for i in ${models} ; do
echo $i
./harness.py hyperparams -c models/$i.conf --outputfile hyperparams/$i.csv
done
}
clean() {
prompt "Extremely destruction deletion about to occur, are you sure?"
if [ "$1" == "--all" ] ; then
for i in data $PY_DIR ; do
if [ -d $i ] ; then
echo "removing $i..."
rm -r $i
fi
done
fi
for i in results data/model ; do
if [ -d $i ] ; then
echo "removing $i..."
rm -r $i
fi
done
}
case $ACTION in
pyenv)
pyenv $2
;;
pydep)
pydep
;;
batch)
batch
;;
testconfig)
testconfig
;;
traintest)
traintest
;;
stop)
stop
;;
paperresults)
paperresults
;;
clean)
clean $2
;;
*)
usage
exit 1
;;
esac