-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_summarize.sh
77 lines (60 loc) · 1.64 KB
/
run_summarize.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
#!/bin/bash
source summarize.conf
usage() {
echo "Run the script with"
echo " $ bash $0 [-d <directory>] [-f <file>] [-l <file>]"
echo
echo " -d The directory to CFG pickle files"
echo " -f The file to be summarized"
echo " -l The file with a list of files to be summarized"
}
sum_run() {
fname=$(basename $1)
echo "[RUN] [$(date '+%Y%m%d-%H%M%S.%N')] | FILE: $fname"
}
sum_fin() {
fname=$(basename $1)
echo "[FIN] [$(date '+%Y%m%d-%H%M%S.%N')] | FILE: $fname"
}
summarize() {
source summarize.conf
[[ $1 == '' ]] && echo 'File path not provided' && exit 1
fpath=$1
sum_run $fpath
# main section
python $MAIN_SCRIPT --method $METHOD -f $fpath -s $SAVE_DIR
sum_fin $fpath
}
[[ $1 == '' ]] && usage && exit 0
mkdir -p $SAVE_DIR
input=$1
export -f summarize
export -f sum_run
export -f sum_fin
while getopts "ho:d:f:l:" argv; do
case $argv in
h )
usage
exit 0
;;
d )
dir=$OPTARG
[[ -d $dir ]] || (echo 'Invalid Directory' && usage && exit 1)
find $dir -type f -name '*.pickle' | xargs -P $WORKERS -I {} bash -c "summarize {}"
;;
f )
file=$OPTARG
[[ -f $file ]] || (echo 'Invalid File' && usage && exit 1)
bash -c "summarize $file"
;;
l )
list=$OPTARG
[[ -f $list ]] || (echo 'Invalid File' && usage && exit 1)
cat $list | xargs -P $WORKERS -I {} bash -c "summarize {}"
;;
? )
usage
exit 1
;;
esac
done