-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun
executable file
·88 lines (77 loc) · 2.09 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
#!/bin/bash
set -e
export OMP_NUM_THREADS=1
cmd_venv() { # set up a virtualenv
test -d venv || 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
test -f requirements.dev.txt && pip3 install -U -r requirements.dev.txt
# python3 -m bash_kernel.install
pip3 install -U neovim
pip3 install -U jupyterlab
pip3 install -U pytest
pip3 install -U tabulate
python3 -m bash_kernel.install
pip3 install papermill
jupyter kernelspec list
}
cmd_lab() { # run jupyter lab in the environment
set -e
cmd_venv > venv.log
source venv/bin/activate
jupyter lab "$@"
}
cmd_words() {
source venv/bin/activate
unset GOPEN_VERBOSE
unset WDS_VERBOSE_CACHE
papermill train-words-v3.ipynb train-words-v3-LOG.ipynb --log-output --autosave-cell-every 60
}
cmd_trans() {
source venv/bin/activate
unset GOPEN_VERBOSE
unset WDS_VERBOSE_CACHE
papermill train-trans-v1.ipynb train-trans-v1-LOG.ipynb --log-output --autosave-cell-every 60
}
cmd_segs() {
source venv/bin/activate
unset GOPEN_VERBOSE
unset WDS_VERBOSE_CACHE
papermill train-segs-v3.ipynb train-segs-v3-LOG.ipynb --log-output --autosave-cell-every 60
}
cmd_segsv4() {
source venv/bin/activate
unset GOPEN_VERBOSE
unset WDS_VERBOSE_CACHE
papermill train-segs-v4.ipynb train-segs-v4-LOG.ipynb --log-output --autosave-cell-every 60
}
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