diff run.sh @ 4:ec5f6b22417c draft

planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/pm_uep_opt commit 70a4d37ecdf5d586703cfc509922311e95d3205c
author muon-spectroscopy-computational-project
date Tue, 18 Jul 2023 13:27:15 +0000
parents e4097a3e3e75
children eea73e1f65cb
line wrap: on
line diff
--- a/run.sh	Fri Feb 03 15:40:08 2023 +0000
+++ b/run.sh	Tue Jul 18 13:27:15 2023 +0000
@@ -2,14 +2,33 @@
 
 set -o errexit
 
-for x in $1/*/*/*.yaml 
-do 
-    
-    if ! out=$(pm-uep-opt $x)
-    then 
-    echo 1>&2 "$out"; exit 1
+run(){
+    if ! out=$(pm-uep-opt $1); then 
+        echo 1>&2 "$out"; exit 1
     else
-    echo "$out"
+        echo "$out"
     fi
-done || exit
-#pm-uep-opt 
\ No newline at end of file
+}
+
+pids=()
+for x in $1/*/*/*.yaml; do 
+    run $x & pids+=($!)
+done
+
+declare -i failed=0
+for pid in ${pids[@]}; do
+    if ! wait $pid; then
+        failed+=1
+    fi
+done
+
+if [ $failed -eq ${#pids[@]} ]; then
+    >&2 echo "ERROR: All optimisations failed"
+    exit 1
+elif [ $failed -eq 0 ]; then
+    echo "All optimisations succeeded"
+    exit 0
+else
+    echo "WARNING: $failed optimisation(s) failed"
+    exit 0
+fi