-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjbs
executable file
·164 lines (146 loc) · 4.4 KB
/
jbs
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
LOCKDIR=/dev/shm/jbslock
monitor(){
#output=$2
statsDir=$1
output=$statsDir/res.out
totWikis=524867
wikis=`grep -m1 fetched "$statsDir/profiler" | cut -d' ' -f3`
milTime=`grep -m1 total "$statsDir/profiler" | cut -d' ' -f3`
minTime=$(($milTime/60000))
hrTime=$(($minTime/60))
hrMinTime=$(($minTime%60))
milPerPage=$(($milTime/wikis))
expecRemain=$(( (($totWikis-$wikis)*$milPerPage)/60000 ))
expecRemainH=$(($expecRemain/60))
expecRemainHM=$(($expecRemain%60))
tanachRefs=`grep "jbr:text-tanach" "$statsDir/pages_uri" | wc -l`
tanachUniq=`grep "jbr:text-tanach" "$statsDir/pages_uri" | sort | uniq | wc -l`
gmaraRefs=`grep "jbr:text-bavli" "$statsDir/pages_uri" | wc -l`
gmaraUniq=`grep "jbr:text-bavli" "$statsDir/pages_uri" | sort | uniq | wc -l`
rambamRefs=`grep "jbr:text-mishnetorah" "$statsDir/pages_uri" | wc -l`
rambamUniq=`grep "jbr:text-mishnetorah" "$statsDir/pages_uri" | sort | uniq | wc -l`
halachaRefs=`grep "jbr:text-shulchanaruch" "$statsDir/pages_uri" | wc -l`
halachaUniq=`grep "jbr:text-shulchanaruch" "$statsDir/pages_uri" | sort | uniq | wc -l`
matchingWikis=`cat "$statsDir/pages_with_uri" | sort | uniq | wc -l`
if [[ -e $output ]]; then
tooMany=`grep "Too many" $output | wc -l`
failConv=`grep "uri" $output | wc -l`
failRate=0
if [[ $failConv != 0 ]]; then
failRate=$(($wikis/$failConv))
fi
badRange=`grep "Range Too large" $output | wc -l`
reversRange=`grep "reverse" $output | wc -l`
fi
echo -e "\nfetched wikis: $wikis \n"
echo "run time: $minTime min = $hrTime hr and $hrMinTime min"
echo "millie per wiki page: $milPerPage"
echo -e "expected remaining: $expecRemain min = $expecRemainH hr and $expecRemainHM min\n"
echo "tanach refs: $tanachRefs (unique: $tanachUniq)"
echo "gmara refs: $gmaraRefs (unique: $gmaraUniq)"
echo "rambam refs: $rambamRefs (unique: $rambamUniq)"
echo "halacha refs: $halachaRefs (unique: $halachaUniq)"
echo -e "found wikis: $matchingWikis \n"
if [[ ! -e $output ]]; then
exit
fi
echo "Too Many error: $tooMany"
echo "fail conversions: $failConv"
if [[ $failRate != 0 ]]; then
echo -e "fail conversions rate: 1/$failRate pages\n"
fi
echo "ranges out of bound: $badRange"
echo -e "revers ranges: $reversRange \n"
}
run(){
java -cp target/jbs-classifier-1.0-SNAPSHOT-jar-with-dependencies.jar MainClass $@
}
monitor_running(){
echo -e "using timestamp $TS \n"
monitor "results/$TS"
wait
}
start(){
if [[ -e $LOCKDIR ]]; then
echo "jbs start already running"
return
fi
trap ':' HUP
mypid=$(bash -c 'echo $PPID')
TS=$(date +%Y.%m.%d_%H.%M.%S)
echo "Using timestamp $TS"
mkdir -p results/$TS
java -cp target/jbs-classifier-1.0-SNAPSHOT-jar-with-dependencies.jar MainClass --all -T $TS $@ >& results/$TS/res.out &
pid=$!
trap "rm -rf $LOCKDIR; kill -9 $pid" TERM
trap monitor_running USR1
mkdir -p $LOCKDIR
touch $LOCKDIR/$mypid
wait
rm -rf $LOCKDIR
}
stop(){
if [[ ! -e $LOCKDIR ]]; then
echo "jbs was not started"
return
fi
pid=$(ls $LOCKDIR)
kill -TERM $pid
}
status(){
if [[ ! -e $LOCKDIR ]]; then
echo "jbs was not started"
return
fi
pid=$(ls $LOCKDIR)
kill -USR1 $pid
}
usage(){
echo "Usage: jbs <option>"
echo ""
echo "Following options are available:"
echo ""
echo "run|-r [classifier flags] - run the classifier with provided flags."
echo "monitor|-m [result folder] - print result summary."
echo "start [classifier flags] - running classifier on all wikipedia on background."
echo " output is saved to res.out in the results folder."
echo "stop - stop started classifier."
echo "status - print current started classifier resault summery."
echo "build|-b - build the classifier."
echo "update|-u - update the classifier code."
echo ""
echo "To see classifier different options run: $0 run --help"
echo ""
}
case "$1" in
'monitor'|'-m')
shift
monitor $@
;;
'run'|'-r')
shift
run $@
;;
'start')
shift
start $@ &
;;
'stop')
stop
;;
'status')
status
;;
'build'|'-b')
mvn clean install
;;
'update'|'-u')
git pull
mvn clean install
;;
*)
echo -e "Unrecogized option\n"
usage
;;
esac