Просмотр исходного кода

Slightly better error handling

Vecna 3 месяцев назад
Родитель
Сommit
7afc097edc
1 измененных файлов с 50 добавлено и 8 удалено
  1. 50 8
      run.sh

+ 50 - 8
run.sh

@@ -1,5 +1,28 @@
 #!/bin/bash
 
+abort() {
+    echo "Step $1 failed."
+    echo "To restart from this step, try running:"
+    if [ "$1" == "setup" ]; then
+        echo "    rm -rf belarus-2020-2021 cmz lox-new lox-old sigma-compiler simga-proofs spongefish"
+    elif [ "$1" == "belarus" ]; then
+        echo "    rm -rf appendix-a-results.{pdf,tex} section-3-results"
+        echo "    docker stop tp-belarus"
+        echo "    docker rm tp-belarus"
+    elif [ "$1" == "lox-gen" ]; then
+        echo "    rm -rf parsing-results/{lox-{old,new},troll-patrol}"
+        echo "    docker stop {lox-{old,new},troll-patrol}-{trust_levels,invitations,blockage_migration{05,50,100}}.log troll-patrol-reporting.log"
+        echo "    docker rm {lox-{old,new},troll-patrol}-{trust_levels,invitations,blockage_migration{05,50,100}}.log troll-patrol-reporting.log"
+    elif [ "$1" == "lox-eval" ]; then
+        echo "    rm -f appendix-b-results.{pdf,tex} table-{2,3}-results.{pdf,tex}"
+        echo "    docker stop tp-lox"
+        echo "    docker rm tp-lox"
+    fi
+    echo "Then run this script again."
+    echo "Exiting..."
+    exit 1
+}
+
 if [ -z "$(command -v numactl)" ]; then
     echo "This script uses numactl to isolate each experiment to a single processing unit."
     echo "You do not seem to have numactl installed. You can still run this script without numactl, but this may affect the results."
@@ -13,22 +36,41 @@ if [ -z "$(command -v numactl)" ]; then
 fi
 
 # Set up dockers
-if [ ! -f belarus-2020-2021 ]; then
-    ./scripts/setup.sh || exit 1
+if [ ! -d troll-patrol ]; then
+    # Clean up any remnants of previous attempts and try again
+    rm -rf belarus-2020-2021 cmz lox-new lox-old sigma-compiler simga-proofs spongefish
+
+    # Set up our dockers
+    ./scripts/setup.sh || abort "setup"
 fi
 
 # Get Belarus results
-if [ "$1" == "--fast" ]; then
-    ./scripts/belarus.sh --fast
-else
-    ./scripts/belarus.sh
+if [[ ! -f appendix-a-results.pdf || ! -f section-3-results ]]; then
+    # Clean up any remnants of previous attempts and try again
+    rm -f appendix-a-results.{pdf,tex} section-3-results
+
+    if [ "$1" == "--fast" ]; then
+        ./scripts/belarus.sh --fast || abort "belarus"
+    else
+        ./scripts/belarus.sh || abort "belarus"
+    fi
 fi
 
 # Run Lox benchmarks
-./scripts/generate-lox-results.sh
+if [[ ! -d parsing-results/lox-old || ! -d parsing-results/lox-new || ! -d parsing-results/troll-patrol ]]; then
+    # Clean up any remnants of previous attempts and try again
+    rm -rf parsing-results/{lox-{old,new},troll-patrol}
+
+    ./scripts/generate-lox-results.sh || abort "lox-gen"
+fi
 
 # Process Lox benchmark results
-./scripts/process-lox-results.sh
+if [[ ! -f appendix-b-results.pdf || ! -f table-2-results.pdf || ! -f table-3-results.pdf ]]; then
+    # Clean up any remnants of previous attempts and try again
+    rm -f appendix-b-results.{pdf,tex} table-{2,3}-results.{pdf,tex}
+
+    ./scripts/process-lox-results.sh || abort "lox-eval"
+fi
 
 echo "Done!"
 echo "Results from Section 3 can be found in the section-3-results file."