-
Notifications
You must be signed in to change notification settings - Fork 2
/
mk_heldout_core.sh
executable file
·112 lines (95 loc) · 2.31 KB
/
mk_heldout_core.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
#!/usr/bin/bash
cdir=models/configurations/;
sdirDef=submission.heldout.core;
gpuDef=0;
sdir=$sdirDef;
gpu=$gpuDef;
cbase="$1"; shift;
cpt="$1"; shift;
if [ -n "$1" ]; then
sdir="$1"; shift;
fi
if [ -n "$1" ]; then
gpu="$1"; shift;
fi
out=$sdir.zip;
cat <<EOF
$0 configuration:
configBase: ${cbase:-MISSING}
in folder $cdir
EOF
if [ -f "$cdir$cbase" ]; then
ls -l "$cdir$cbase";
else
echo " Choices include:"
ls -1 "$cdir"|grep 'pred.yaml$'|sed -e 's/^/ /';
fi
cat <<EOF
checkpoint: ${cpt:-MISSING}
submissionDir: $sdir
gpuID: $gpu
output: $out
EOF
[ -f "$cpt" ] && ls -l "$cpt";
if [ -z "$cpt" -o -n "$1" ]; then
cat <<EOF
usage: $0 {configBase} {checkpoint} [submissionDir] [gpuID]
The {configBase} file will be read from $cdir.
Predictions will be collected in folder submissionDir.
If not specified the default is: $sdirDef
For stage-1 support set submissionDir to: submission
The default gpuID is $gpuDef. Use a single GPU.
Examples: $0 config_baseline_stage2-pred.yaml \\
lightning_logs/YOURMODEL/checkpoints/YOURCHECK.ckpt
EOF
exit
fi
if [ -d "$sdir" ]; then
echo Deleting existing $sdir in 9 seconds unless you abort by Ctrl-C
sleep 9 && rm -rf "$sdir/*" || exit;
else
mkdir "$sdir";
if [ -d "$sdir" ]; then
echo "Created $sdir"
else
echo "Could not create $sdir - aborting.";
exit
fi
fi
for y in 2019 2020; do
d=$sdir/$y;
[ -d "$d" ] || mkdir "$d";
for r in boxi_0015 boxi_0034 boxi_0076 \
roxi_0004 roxi_0005 roxi_0006 roxi_0007; do
echo /=== $r $y for $cpt
cin=$cdir$cbase;
cnew=${cbase%.yaml}-$$-$r-$y.yaml;
cout=$cdir$cnew;
sed -e "s/%REGION%/$r/g" -e "s/%YEAR%/$y/" -e "s/%SDIR%/$sdir/" \
<"$cin" >"$cout";
python train.py --gpus $gpu --mode heldout --config_path "$cnew" \
--checkpoint "$cpt"
rm $cout;
done
done
if pushd $sdir; then
echo /=== output summary
ls -l */*
fl=`find -type f|grep -v '/[.]'|sed -e 's/ /%20/g'`;
for f in $fl; do
f="${f//%20/ }";
echo Compressing $f ...
gzip -9f "$f" &
done
wait;
echo ...zip packing $sdir
[ -s "../$out" ] && rm -f "../$out";
zip -0mr ../$out * -x .\* \*/.\*
popd
rmdir $sdir;
ls -l $out;
else
echo "Cannot change to $sdir - aborting"
exit
fi
echo \\=== done