From f295e43e75e8e881fc8dbb01225d61f4f094a8eb Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wouter.deconinck@umanitoba.ca>
Date: Sat, 14 Aug 2021 22:01:17 +0000
Subject: [PATCH] Make view12/14/15 parallel (one slice per job)

---
 bin/make_dawn_views         |  4 +++-
 scripts/view12/generate_eps | 15 ++++++++++-----
 scripts/view14/generate_eps | 13 +++++++++----
 scripts/view15/generate_eps | 12 ++++++++----
 views/view12.yml            |  8 +++++++-
 views/view14.yml            |  7 ++++++-
 views/view15.yml            |  7 ++++++-
 7 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/bin/make_dawn_views b/bin/make_dawn_views
index 0901aa8d..279119e8 100755
--- a/bin/make_dawn_views
+++ b/bin/make_dawn_views
@@ -58,6 +58,8 @@ parser.add_argument('-t', '--tag', type=str,
 parser.add_argument('--timeout', type=int,
         default=60,
         help='Timeout in seconds')
+        
+parser.add_argument('passthrough', nargs='*')
 
 args = parser.parse_args()
 
@@ -157,7 +159,7 @@ prim_file = os.path.abspath(prim_file)
 owd = os.getcwd()
 os.chdir(args.dawn_dir)
 subprocess.run(['pwd'])
-subprocess.run(['./generate_eps', '-t', args.tag, '-i', prim_file])
+subprocess.run(['./generate_eps', '-t', args.tag, '-i', prim_file] + args.passthrough)
 subprocess.run(['ls', '-lrth'])
 
 # upload the results
diff --git a/scripts/view12/generate_eps b/scripts/view12/generate_eps
index c70aa725..38ebec3c 100755
--- a/scripts/view12/generate_eps
+++ b/scripts/view12/generate_eps
@@ -18,7 +18,7 @@ tan ()
 
 
 function print_the_help {
-  echo "USAGE: $0 -i <PRIM_FILE>  "
+  echo "USAGE: $0 -i <PRIM_FILE> <slices ...> "
   echo "  OPTIONS: "
   echo "            -t,--tag           filename tag (default: view1)"
   exit 
@@ -48,12 +48,16 @@ do
       shift # past argument
       shift # past value
       ;;
-    *)    # unknown option
-      #POSITIONAL+=("$1") # save it in an array for later
+    -[a-zA-Z]*) # unknown option
+      POSITIONAL+=("$1") # save it in an array for later
       echo "unknown option $1"
       print_the_help
       shift # past argument
       ;;
+    *)     # positional options
+      POSITIONAL+=("$1") # save it in an array for later
+      shift # past argument
+      ;;
   esac
 done
 set -- "${POSITIONAL[@]}" # restore positional parameters
@@ -90,9 +94,10 @@ make_slice(){
   rm "${FILE_TAG}_temp0.prim"
   rm "${FILE_TAG}.prim"
 }
-for zzz in $(seq 50 50 2000) ;
+
+for zzz in $@ ;
 do
-  make_slice ${zzz} & 
+  make_slice ${zzz}
 done
 
 wait
diff --git a/scripts/view14/generate_eps b/scripts/view14/generate_eps
index f89a18fa..dc86760e 100755
--- a/scripts/view14/generate_eps
+++ b/scripts/view14/generate_eps
@@ -23,7 +23,7 @@
 
 
 function print_the_help {
-  echo "USAGE: $0 -i <PRIM_FILE>  "
+  echo "USAGE: $0 -i <PRIM_FILE> <slices ...> "
   echo "  OPTIONS: "
   echo "            -t,--tag           filename tag (default: view1)"
   exit 
@@ -53,12 +53,16 @@ do
       shift # past argument
       shift # past value
       ;;
-    *)    # unknown option
-      #POSITIONAL+=("$1") # save it in an array for later
+    -[a-zA-Z]*) # unknown option
+      POSITIONAL+=("$1") # save it in an array for later
       echo "unknown option $1"
       print_the_help
       shift # past argument
       ;;
+    *)     # positional options
+      POSITIONAL+=("$1") # save it in an array for later
+      shift # past argument
+      ;;
   esac
 done
 set -- "${POSITIONAL[@]}" # restore positional parameters
@@ -102,7 +106,8 @@ make_slice(){
   rm "${FILE_TAG}_temp0.prim"
   rm "${FILE_TAG}.prim"
 }
-for zzz in $(seq 100 200 2000) ;
+
+for zzz in $@ ;
 do
   make_slice ${zzz} 
 done
diff --git a/scripts/view15/generate_eps b/scripts/view15/generate_eps
index bf1d772e..b1583cf4 100755
--- a/scripts/view15/generate_eps
+++ b/scripts/view15/generate_eps
@@ -23,7 +23,7 @@
 
 
 function print_the_help {
-  echo "USAGE: $0 -i <PRIM_FILE>  "
+  echo "USAGE: $0 -i <PRIM_FILE> <slices ...> "
   echo "  OPTIONS: "
   echo "            -t,--tag           filename tag (default: view1)"
   exit 
@@ -53,12 +53,16 @@ do
       shift # past argument
       shift # past value
       ;;
-    *)    # unknown option
-      #POSITIONAL+=("$1") # save it in an array for later
+    -[a-zA-Z]*) # unknown option
+      POSITIONAL+=("$1") # save it in an array for later
       echo "unknown option $1"
       print_the_help
       shift # past argument
       ;;
+    *)     # positional options
+      POSITIONAL+=("$1") # save it in an array for later
+      shift # past argument
+      ;;
   esac
 done
 set -- "${POSITIONAL[@]}" # restore positional parameters
@@ -104,7 +108,7 @@ make_slice(){
   rm "${FILE_TAG}.prim"
 }
 
-for zzz in $(seq 100 200 2000) ;
+for zzz in $@ ;
 do
   make_slice ${zzz} 
 done
diff --git a/views/view12.yml b/views/view12.yml
index 13316030..b3da026a 100644
--- a/views/view12.yml
+++ b/views/view12.yml
@@ -1,7 +1,13 @@
 dawn_view_12:detector:
   extends: .views
   script:
-    - ./bin/make_dawn_views -t view12 -d scripts/view12 -D
+    - ./bin/make_dawn_views -t view12 -d scripts/view12 -D -- ${SLICE}
+    - ls -lrth *
+    - ls -lrth images/*
+  parallel:
+    matrix:
+      - SLICE: ["100", "300", "500", "700", "900", "1100", "1300", "1500", "1700", "1900"]
+
 
 view_12:
   stage: collect
diff --git a/views/view14.yml b/views/view14.yml
index de135eb0..77b1651d 100644
--- a/views/view14.yml
+++ b/views/view14.yml
@@ -1,7 +1,12 @@
 dawn_view_14:detector:
   extends: .views
   script:
-    - ./bin/make_dawn_views -t view14 -d scripts/view14 -D
+    - ./bin/make_dawn_views -t view14 -d scripts/view14 -D -- ${SLICE}
+    - ls -lrth *
+    - ls -lrth images/*
+  parallel:
+    matrix:
+      - SLICE: ["100", "300", "500", "700", "900", "1100", "1300", "1500", "1700", "1900"]
 
 view_14:
   stage: collect
diff --git a/views/view15.yml b/views/view15.yml
index 8e6bd133..9d24e940 100644
--- a/views/view15.yml
+++ b/views/view15.yml
@@ -1,7 +1,12 @@
 dawn_view_15:detector:
   extends: .views
   script:
-    - ./bin/make_dawn_views -t view15 -d scripts/view15 -D
+    - ./bin/make_dawn_views -t view15 -d scripts/view15 -D -- ${SLICE}
+    - ls -lrth *
+    - ls -lrth images/*
+  parallel:
+    matrix:
+      - SLICE: ["100", "300", "500", "700", "900", "1100", "1300", "1500", "1700", "1900"]
 
 view_15:
   stage: collect
-- 
GitLab