This repository was archived by the owner on Oct 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAutomaticRun.sh
More file actions
executable file
·60 lines (47 loc) · 2.31 KB
/
AutomaticRun.sh
File metadata and controls
executable file
·60 lines (47 loc) · 2.31 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
#!/bin/bash
MODEL=("ItemKNN" "PFCN_DMF" "PFCN_biasedMF" "NFCF" "FOCF" "FairGo_PMF" "FairGo_GCN" "PFCN_PMF" "NGCF" "SGL" "LightGCN" "DMF" "NeuMF" "NNCF" "DGCF")
CONFIG=("ML,ml-1M" "LFM,LastFM-100K" "BR,BookRec-100K")
# LOG_DIR is the directory you'd like to save the results, e.g:
LOG_DIR="~/work/code-results/"
for config in ${CONFIG[@]}; do
IFS=',' read -r -a config_arr <<< "$config"
for model in ${MODEL[@]}; do
output_file="${LOG_DIR}Run_$(date +'%H%M')_${model}-${config_arr[1]}.log"
# command="python3 resume_run_recbole.py --model=${model} --config=Configuration${config_arr[0]}.yaml --dataset=${config_arr[1]} > ${output_file} 2>&1"
if [[ "$@" == *-r* ]] || [[ "$@" == *--resume* ]]; then
command="python3 resume_run_recbole.py --model=${model} --config=Configuration${config_arr[0]}.yaml --dataset=${config_arr[1]} > ${output_file} 2>&1"
echo "# NOTE: running in resume mode, only evaluating"
else
command="python3 run_recbole.py --model=${model} --config=Configuration${config_arr[0]}.yaml --dataset=${config_arr[1]} > ${output_file} 2>&1"
echo "# NOTE: running in FULL training mode."
fi
# Start timer
start=$(date +%s)
# Run the script in the background
eval $command &
# Get the process ID of the background task
pid=$!
# Display progress dots
echo -n "Running $model-$config_arr[1]..."
# Check the status of the process every second
while ps -p $pid > /dev/null; do
echo -n "."
sleep 1
done
# Calculate the duration
end=$(date +%s)
duration=$((end - start))
# Convert duration to MM:SS format
minutes=$((duration / 60))
seconds=$((duration % 60))
time_taken=$(printf "%02d:%02d" $minutes $seconds)
# Output time taken to run the code
echo ""
echo "Code with $output_file took $time_taken to run."
# Save only the last 20 lines of the log file
command2="tail -n 20 $output_file > ${output_file}.tmp && mv ${output_file}.tmp $output_file"
eval $command2 &
# Wait for 1 second before starting the next iteration
sleep 1
done
done