2
2
3
3
# Copyright 2023 University of Birmingham, ResearchSoftwareGroup
4
4
# v0.1 by Simon Hartley
5
- #
6
5
# This program is free software: you can redistribute it and/or modify
7
6
# it under the terms of the GNU General Public License as published by
8
7
# the Free Software Foundation, either version 3 of the License, or
21
20
# move to dir which this script is in:
22
21
cd " ${0%/* } "
23
22
24
- export PROJECTROOT=$( pwd)
23
+ PROJECTROOT=$( pwd)
24
+ export PROJECTROOT
25
25
26
26
# colours for the terminal
27
27
export RED=' \e[38;5;198m'
@@ -194,24 +194,24 @@ function call_python() {
194
194
# ######################################
195
195
function main() {
196
196
197
- echo " odir->" ${odir}
198
- echo " venv_name->" ${venv_name}
199
- echo " save_freq->" ${save_freq}
200
- echo " episode_max->" ${episode_max}
201
- echo " del_env->" ${del_env}
202
- echo " data_dir->" ${data_dir}
203
- echo " steps_episode_max->" ${steps_episode_max}
197
+ echo " odir->${odir} "
198
+ echo " venv_name->${venv_name} "
199
+ echo " save_freq->${save_freq} "
200
+ echo " episode_max->${episode_max} "
201
+ echo " del_env->${del_env} "
202
+ echo " data_dir->${data_dir} "
203
+ echo " steps_episode_max->${steps_episode_max} "
204
204
205
205
# make the output folder
206
206
if [[ ! -e $odir ]]; then
207
- mkdir -p ${odir}
207
+ mkdir -p " ${odir} "
208
208
elif [[ ! -d $odir ]]; then
209
209
echo " $odir already exists but is not a directory"
210
210
exit_abnormal
211
211
fi
212
212
213
213
214
- start=` date -u +%s`
214
+ start=' date -u +%s'
215
215
Bask_load_modules_DeepCell
216
216
ACTFILE=" ${PROJECTROOT} /apps/${venv_name} /bin/activate"
217
217
if test -f " $ACTFILE " ; then
@@ -226,12 +226,14 @@ function main() {
226
226
# Do Python AI training and work
227
227
call_python
228
228
# ***********************************************************************
229
+
229
230
if [[ $del_env =~ ^[Yy]$ ]]
230
231
then
231
232
# do rm of env folder
232
233
clean
233
234
fi ;
234
- end=` date -u +%s`
235
+
236
+ end=' date -u +%s'
235
237
236
238
runtime=$( date -u -d " 0 $end seconds - $start seconds" +" %H:%M:%S" )
237
239
@@ -249,35 +251,35 @@ function main() {
249
251
250
252
while getopts " :o:s:e:p:d:r:" opt; do
251
253
case $opt in
252
- o) odir=${OPTARG%/ } ; ;; # Remove trailing slash if present
254
+ o) odir=${OPTARG%/ } ; ;; # Remove trailing slash if present
253
255
e) venv_name=$OPTARG ; ;;
254
256
d) del_env=$OPTARG ; ;;
255
257
s)
256
- save_freq=$OPTARG # Set $checkpoints to specified value.
257
- re_isanum=' ^[0-9]+$' # Regex: match whole numbers only
258
- if ! [[ $save_freq =~ $re_isanum ]] ; then # if $checkpoints not whole:
258
+ save_freq=$OPTARG # Set $checkpoints to specified value.
259
+ re_isanum=' ^[0-9]+$' # Regex: match whole numbers only
260
+ if ! [[ ${ save_freq} =~ $re_isanum ]] ; then # if $checkpoints not whole:
259
261
echo " Error: checkpoints must be a positive, whole number."
260
- exit_abnormal # Exit abnormally.
262
+ exit_abnormal # Exit abnormally.
261
263
fi ; ;;
262
264
p)
263
- episode_max=$OPTARG # Set $episode_max to specified value.
264
- re_isanum=' ^[0-9]+$' # Regex: match whole numbers only
265
- if ! [[ $episode_max =~ $re_isanum ]] ; then # if $episode_max not whole:
265
+ episode_max=$OPTARG # Set $episode_max to specified value.
266
+ re_isanum=' ^[0-9]+$' # Regex: match whole numbers only
267
+ if ! [[ $episode_max =~ $re_isanum ]] ; then # if $episode_max not whole:
266
268
echo " Error: episode_max must be a positive, whole number."
267
- exit_abnormal # Exit abnormally.
268
- elif [ $episode_max -eq " 0" ]; then # If it's zero:
269
+ exit_abnormal # Exit abnormally.
270
+ elif [ " $episode_max " -eq " 0" ]; then # If it's zero:
269
271
echo " Error: episode_max must be greater than zero."
270
- exit_abnormal # Exit abnormally.
272
+ exit_abnormal # Exit abnormally.
271
273
fi ; ;;
272
274
r)
273
- steps_episode_max=$OPTARG # Set $steps_episode_max to specified value.
274
- re_isanum=' ^[0-9]+$' # Regex: match whole numbers only
275
- if ! [[ $steps_episode_max =~ $re_isanum ]] ; then # if $steps_episode_max not whole:
275
+ steps_episode_max=$OPTARG # Set $steps_episode_max to specified value.
276
+ re_isanum=' ^[0-9]+$' # Regex: match whole numbers only
277
+ if ! [[ ${ steps_episode_max} =~ $re_isanum ]] ; then # if $steps_episode_max not whole:
276
278
echo " Error: steps_episode_max must be a positive, whole number."
277
- exit_abnormal # Exit abnormally.
278
- elif [ $ steps_episode_max -eq " 0" ]; then # If it's zero:
279
+ exit_abnormal # Exit abnormally.
280
+ elif [ " ${ steps_episode_max} " -eq " 0" ]; then # If it's zero:
279
281
echo " Error: steps_episode_max must be greater than zero."
280
- exit_abnormal # Exit abnormally.
282
+ exit_abnormal # Exit abnormally.
281
283
fi ; ;;
282
284
\? ) echo " Error: invalid option: -$OPTARG " ; exit_abnormal ;;
283
285
:) echo " Error: option -$OPTARG requires an argument" ; exit 1 ;;
293
295
# ######################################
294
296
295
297
exit 0 # Exit normally.
296
-
297
-
0 commit comments