-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
executable file
·60 lines (51 loc) · 1.64 KB
/
run.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
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 <solver-type> <uld-file> <package-file> <output-dir>"
echo ""
echo "Supported Solver Types:"
echo " - BasicOverlap (no guarantee of 100% priority packing)"
echo " - BasicNonOverlap (no guarantee of 100% priority packing)"
echo " - Tree"
echo " - Preference"
echo " - MixedTree (Buggy, does not work)"
exit 1
}
# Check if the correct number of arguments is provided
if [ "$#" -ne 4 ]; then
usage
fi
DIRECTORY="src/"
treat_warn_as_err=0
warn_found=0
# Find all .py files and search for lines containing 'WARNING'
while IFS= read -r -d '' file; do
if grep -H "WARNING" "$file" &>/dev/null; then
echo "Warning found in: $file"
echo "-----------------------"
grep -Hn "WARNING" "$file"
echo "-----------------------"
warn_found=1
fi
done < <(find "$DIRECTORY" -name "*.py" -print0)
if [ "$warn_found" -eq 1 ]; then
if [ "$treat_warn_as_err" -eq 1 ]; then
echo "Treating warnings as errors."
exit 1
fi
else
echo "No warnings found."
fi
# Assign arguments to variables for better readability
SOLVER_TYPE=$1
ULD_FILE=$2
PACKAGE_FILE=$3
OUTPUT_DIR=$4
mkdir -p "$OUTPUT_DIR"
# Validate solver type
if [[ "$SOLVER_TYPE" != "BasicOverlap" && "$SOLVER_TYPE" != "BasicNonOverlap" && "$SOLVER_TYPE" != "Tree" && "$SOLVER_TYPE" != "Preference" && "$SOLVER_TYPE" != "MixedTree" ]]; then
echo "Error: Invalid solver type '$SOLVER_TYPE'."
usage
fi
# Run the main.py script with the provided arguments
python3 src/main.py "$SOLVER_TYPE" "$ULD_FILE" "$PACKAGE_FILE" "$OUTPUT_DIR"