-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrun.sh
More file actions
70 lines (56 loc) · 2.18 KB
/
run.sh
File metadata and controls
70 lines (56 loc) · 2.18 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
#!/bin/bash
# Set the script directory based on the CoverageControl_ws environment variable
SCRIPT_DIR="${CoverageControl_ws}/src/CoverageControl/python"
# Set the parameters directory based on the environment variable
PARAMS_DIR="${CoverageControl_ws}/lpac/params/"
# Set env size
ENV_SIZE=1024
# Define the parameter file names
DATA_PARAMS_FILE="data_params.toml"
# DATA_GEN_ALGORITHM="--algorithm CentralizedCVT"
LEARNING_PARAMS_FILE="learning_params.toml"
EVAL_PARAMS_FILE="eval.toml"
# Function to print messages in red
print_error() {
echo -e "\033[0;31m$1\033[0m"
}
# Function to print the completion time and duration of each command
print_completion() {
local command_name=$1
local start_time=$2
local end_time=$(date +%s)
echo "Completed $command_name at $(date +'%Y-%m-%d %H:%M:%S')"
echo "Duration of $command_name: $((end_time - start_time)) seconds"
}
# Run a command with timing and error checking
run_command() {
local command=$1
local name=$2
start_time=$(date +%s)
echo "Starting $name at $(date +'%Y-%m-%d %H:%M:%S')"
# Execute the command
eval $command
if [ $? -ne 0 ]; then
print_error "$name failed."
exit 1
fi
print_completion "$name" $start_time
}
# Ensure the environment variable CoverageControl_ws is set
if [ -z "${CoverageControl_ws}" ]; then
print_error "Environment variable CoverageControl_ws is not set."
exit 1
fi
# Data generation in parts
# for i in {0..4}
# do
# echo "Running data generation for $i"
# run_command "python ${SCRIPT_DIR}/data_generation/data_generation.py ${PARAMS_DIR}/${DATA_PARAMS_FILE} --append-dir data/$i --split False" "Data Generation"
# done
# Edit and execute process_data.sh
# Running the data generation script
run_command "python ${SCRIPT_DIR}/data_generation/data_generation.py ${PARAMS_DIR}/${DATA_PARAMS_FILE} ${DATA_GEN_ALGORITHM} --split True" "Data Generation"
# Running the training script
run_command "python ${SCRIPT_DIR}/training/train_lpac.py ${PARAMS_DIR}/${LEARNING_PARAMS_FILE} ${ENV_SIZE}" "Model Training"
# Running the evaluation script
run_command "python ${SCRIPT_DIR}/evaluators/eval.py ${PARAMS_DIR}/${EVAL_PARAMS_FILE}" "Model Evaluation"