Repository navigation
Expand file tree
/
Copy pathdamoos.sh
More file actions
executable file
·211 lines (190 loc) · 3.67 KB
/
Copy pathdamoos.sh
File metadata and controls
executable file
·211 lines (190 loc) · 3.67 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: GPL-2.0
# This is the main runner script of damoos that interacts with the user.
DAMOOS=$(dirname "$0")
scheme_adapters=$(ls "$DAMOOS/scheme_adapters")
function pr_usage {
echo "Usage: $0 [OPTION]... <scheme adapter> <log file>"
echo
echo "OPTION"
echo " --dry Do nothing but show how it will work"
echo " -h, --help Show this usage"
echo
echo "Supported <scheme adapter>s are:"
for s in $scheme_adapters
do
echo " $s"
done
echo
}
if [ $# -lt 1 ]
then
pr_usage
exit 1
fi
while [ $# -ne 0 ]; do
case $1 in
"--dry")
DRYRUN=echo
shift 1
continue
;;
"--help" | "-h")
pr_usage
exit 0
;;
*)
if [ $# -ne 2 ]
then
pr_usage
exit 1
fi
adapter=$1
log_file=$2
wrong_scheme_name=1
for s in $scheme_adapters
do
if [ "$adapter" == "$s" ]
then
wrong_scheme_name=0
break
fi
done
if [ "$wrong_scheme_name" -eq 1 ]
then
pr_usage
exit 1
fi
break
;;
esac
done
adapter_dir="$DAMOOS/scheme_adapters/$adapter"
adapter_requirements=$(cat "$adapter_dir/requirements.txt")
cmd=""
if [[ "$adapter" == "simple_adapter" ]]
then
for line in $adapter_requirements
do
echo "Please enter ${line}"
read -r arg
args="${args} $arg"
done
cmd="sudo DAMOOS=\"$DAMOOS\" bash \"$adapter_dir/$adapter.sh\" $args"
elif [[ "$adapter" == "simple_rl_adapter" ]]
then
args="-p ${DAMOOS}"
for line in $adapter_requirements
do
echo "Please enter ${line}"
read -r arg
if [[ "$arg" == "$NL" ]]
then
continue
elif [[ $line == *"-lb"* ]]
then
args="${args} -lb $arg"
elif [[ $line == *"-w"* ]]
then
args="${args} -w $arg"
elif [[ $line == *"-n"* ]]
then
args="${args} -n $arg"
elif [[ $line == *"-lr"* ]]
then
args="${args} -lr $arg"
elif [[ $line == *"-dm"* ]]
then
args="${args} -dm $arg"
elif [[ $line == *"-e"* ]]
then
args="${args} -e $arg"
elif [[ $line == *"-d"* ]]
then
args="${args} -d $arg"
fi
done
cmd="sudo python3 $adapter_dir/simple_rl_adapter.py $args"
elif [[ "$adapter" == "polyfit_adapter" ]]
then
args="-dp ${DAMOOS}"
for line in $adapter_requirements
do
echo "Please enter ${line}"
read -r arg
if [[ "$arg" == "$NL" ]]
then
continue
elif [[ $line == *"-lb"* ]]
then
args="${args} -lb $arg"
elif [[ $line == *"-dm"* ]]
then
args="${args} -dm $arg"
elif [[ $line == *"-jp"* ]]
then
args="${args} -jp $arg"
elif [[ $line == *"-pfn"* ]]
then
args="${args} -pfn $arg"
fi
done
cmd="sudo python3 $adapter_dir/polyfit_adapter.py $args"
elif [[ "$adapter" == "pso_adapter" ]]
then
args="-dp ${DAMOOS}"
for line in $adapter_requirements
do
echo "Please enter ${line}"
read -r arg
if [[ "$arg" == "$NL" ]]
then
continue
elif [[ $line == *"-lb"* ]]
then
args="${args} -lb $arg"
elif [[ $line == *"-dm"* ]]
then
args="${args} -dm $arg"
elif [[ $line == *"-jp"* ]]
then
args="${args} -jp $arg"
fi
done
cmd="sudo python3 $adapter_dir/pso_adapter.py $args"
elif [[ "$adapter" == "multiD_polyfit_adapter" ]]
then
args="-dp ${DAMOOS}"
for line in $adapter_requirements
do
echo "Please enter ${line}"
read -r arg
if [[ "$arg" == "$NL" ]]
then
continue
elif [[ $line == *"-lb"* ]]
then
args="${args} -lb $arg"
elif [[ $line == *"-dm"* ]]
then
args="${args} -dm $arg"
elif [[ $line == *"-jp"* ]]
then
args="${args} -jp $arg"
fi
done
cmd="sudo python3 $adapter_dir/multiD_polyfit_adapter.py $args"
fi
if [ "$cmd" == "" ]
then
echo "something wrong!"
exit 1
fi
if $DRYRUN script -c "$cmd" -f "$log_file"
then
echo "Successfull!"
else
echo "Please fix the mentioned error"
exit 1
fi