-
Notifications
You must be signed in to change notification settings - Fork 2
/
run
executable file
·92 lines (78 loc) · 1.98 KB
/
run
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
#!/bin/bash
set -e
export OMP_NUM_THREADS=1
image=ocr2021
remimage=tmbdev/$image
die() {
echo "ERROR: $*"
exit 1
}
cmd_venv() { # set up a virtualenv
test -f venv/bin/activate || python3 -m venv venv
source venv/bin/activate
pip3 install -U pip
pip3 install numpy
pip3 install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html
pip3 install -U -r requirements.txt
pip3 install -U jupyterlab
pip3 install -U ipywidgets
jupyter nbextension enable --py widgetsnbextension
pip3 install -U bash_kernel
python -m bash_kernel.install
pip3 install -U pytest
jupyter kernelspec list
}
cmd_lab() { # run jupyter lab in the environment
set -e
source venv/bin/activate
jupyter lab "$@"
}
cmd_clean() { # remove temporary files
rm -f *-info.txt
rm -f *.pth *.pth.tar
rm -f *.log
}
cmd_cleanlogs() { # clean up log files
source venv/bin/activate
mkdir -p ./JUNK
mv -v $(python3 -m ocropus.slog findempty *.sqlite3) ./JUNK/.
}
cmd_build() { # build the docker container
(cd docker && docker build - -t ocr2021-base "$@" < Dockerfile-base)
(cd docker && docker build --no-cache . -t $image)
}
cmd_pushk8s() { # push to local microk8s registry
docker tag ocr2021 localhost:32000/ocr2021
docker push localhost:32000/ocr2021
}
cmd_push() { # push to docker
docker tag ocr2021 tmbdev/ocr2021
docker push tmbdev/ocr2021
}
cmd_help() { # help message
echo
echo available commands:
echo
grep '^cmd_[_0-9a-z]*() {' $0 | sed 's/cmd_//;s/\(.*\)() *{* *#* */\1 -- /'
}
cmd=${1:-help}
shift
case $cmd in
help)
echo; echo available commands:; echo
grep '^cmd_[_0-9a-z]*() {' "$0" | sed 's/cmd_//;s/\(.*\)() *{* *#* */\1 -- /'
;;
*.py)
# cmd_versions
set -e
# hg status grep -v '^M ' > /dev/null
cmd_venv > venv.log
source venv/bin/activate
export OMP_NUM_THREADS=1
python3 "$cmd" "$@"
;;
*)
set -e
"cmd_$cmd" "$@"
;;
esac