forked from EngineerDDP/Parallel-SGD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_worker.sh
executable file
·91 lines (77 loc) · 1.52 KB
/
build_worker.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
if [ $# -ne 1 ]; then
echo "Target Worker dir must be provided as parameter."
echo "Usage:"
echo -e "\t ./build_worker.sh {target directory}"
exit 1
fi
src_files=(
"./worker.py"
"./constants.py"
"./log.py"
)
src_dirs=(
"./network"
"./nn"
"./parallel_computing"
"./parallel_sgd"
"./rpc"
)
files_and_dir_check=1
for file in "${src_files[@]}"; do
{
if [ ! -f "$file" ]; then
echo -e "File not found:\t\t$file"
files_and_dir_check=0
fi
}
done
for dir in "${src_dirs[@]}"; do
{
if [ ! -d "$dir" ]; then
echo -e "Directory not found:\t$dir"
files_and_dir_check=0
fi
}
done
# Exit if some files are missing
if [ $files_and_dir_check -eq 0 ]; then
echo "Error:"
echo "This script can only be run inside project directory."
exit 2
fi
worker=$1
if [ ! -d "$worker" ]; then
mkdir "$worker"
else
echo "Target directory exists, override ? (yes)"
read input
if [ ! $input = "yes" ]; then
exit 0
else
echo "Override files..."
rm -rf "${worker:?}/"*
fi
fi
for dir in "${src_dirs[@]}"; do
{
cp -r $dir "$worker"/"$dir"
echo "Copy directory: $dir"
}
done
for file in "${src_files[@]}"; do
{
cp $file "$worker"/"$file"
echo "Copy file: $file"
}
done
Dockerfile_check=1
if [ ! -f "Dockerfile" ]; then
echo -e "Dockerfile not found"
Dockerfile_check=0
fi
if [ $Dockerfile_check -eq 1 ]; then
echo "Copy Dockerfile"
cp "Dockerfile" "$worker"/"../Dockerfile"
fi
python3 -m compileall "$worker"/
echo -e "\033[0;32;1mDone\033[0m"