From f2d87e17968ff4f58fa952cbf2522e474be5a04e Mon Sep 17 00:00:00 2001
From: Krish Moodbidri <krish94@uab.edu>
Date: Wed, 10 Aug 2022 16:01:54 -0500
Subject: [PATCH] feat add version v1 for cod cluster

---
 form.yml       | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
 manifest.yml   |  4 ++--
 script.sh.erb  | 36 +++++++++++++++++++++++++++++++++
 submit.yml.erb | 30 +++++++++------------------
 4 files changed, 103 insertions(+), 22 deletions(-)
 create mode 100644 form.yml
 create mode 100644 script.sh.erb

diff --git a/form.yml b/form.yml
new file mode 100644
index 0000000..07ca419
--- /dev/null
+++ b/form.yml
@@ -0,0 +1,55 @@
+---
+cluster: "SLURM_CLUSTER"  
+attributes:
+  bc_num_hours:
+    value: 1
+
+  bc_num_slots:
+    label: Number of CPU
+    value: 1
+    min: 1
+    max: 24
+    step: 1
+
+  bc_num_mems:
+    widget: "number_field"
+    label: Memory per CPU (GB)
+    value: 4
+    min: 1
+    max: 128
+    step: 1
+
+  bc_partition:
+    widget: select
+    label: Partition
+    options:
+      - [ "express", "express" ]
+      - [ "short", "short" ]
+      - [ "medium", "medium" ]
+      - [ "long", "long" ]
+      - [ "interactive", "interactive" ]
+      - [ "pascalnodes", "pascalnodes" ]
+      - [ "pascalnodes-medium", "pascalnodes-medium" ]
+      - [ "largemem", "largemem" ]
+      - [ "largemem-long", "largemem-long" ]
+      - [ "amd-hdr100", "amd-hdr100" ]
+
+  version:
+    widget: select
+    label: "MATLAB version"
+    help: "This defines the version of MATLAB you want to load."
+    options:
+{% for ver in matlab_vers %}
+      - [ "{{ ver }}", "{{ matlab_module_name }}/{{ ver }}"]
+{% endfor %}
+
+  cuda_toolkit: "{{ cuda_toolkit_module }}"
+
+form:
+  - version
+  - bc_num_hours
+  - bc_partition
+  - bc_num_slots
+  - bc_num_mems
+  - bc_email_on_started
+  - cuda_toolkit
diff --git a/manifest.yml b/manifest.yml
index 0841d1e..c2232c5 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -4,8 +4,8 @@ category: Interactive Apps
 subcategory: GUIs
 role: batch_connect
 description: |
-  This app will launch a [MATLAB] GUI on the [Owens cluster]. You will be able
+  This app will launch a [MATLAB] GUI on the [Cheaha cluster]. You will be able
   to interact with the MATLAB GUI through a VNC session.
 
   [MATLAB]: https://www.mathworks.com/products/matlab.html
-  [Owens cluster]: https://www.osc.edu/resources/technical_support/supercomputers/owens
+  [Cheaha cluster]: https://uabrc.github.io
diff --git a/script.sh.erb b/script.sh.erb
new file mode 100644
index 0000000..8884fa8
--- /dev/null
+++ b/script.sh.erb
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+# Set working directory to home directory
+cd "${HOME}"
+
+#
+# Launch Xfce Window Manager and Panel
+#
+
+(
+  export SEND_256_COLORS_TO_REMOTE=1
+  export XDG_CONFIG_HOME="<%= session.staged_root.join("config") %>"
+  export XDG_DATA_HOME="<%= session.staged_root.join("share") %>"
+  export XDG_CACHE_HOME="$(mktemp -d)"
+  module reset
+  set -x
+  xfwm4 --compositor=off --daemon --sm-client-disable
+  xsetroot -solid "#D3D3D3"
+  xfsettingsd --sm-client-disable
+  xfce4-panel --sm-client-disable
+) &
+
+#
+# Start MATLAB
+#
+
+<%- if context.bc_partition == "pascalnodes" -%>
+# Load CUDA toolkit
+module load <%= context.cuda_toolkit %>
+<%- end -%>
+# Load the required environment
+module load <%= context.version %>
+# Launch MATLAB
+module list
+set -x
+matlab -desktop
diff --git a/submit.yml.erb b/submit.yml.erb
index e89017d..2521f4a 100644
--- a/submit.yml.erb
+++ b/submit.yml.erb
@@ -1,24 +1,14 @@
-<%-
-  ppn = num_cores.blank? ? 28 : num_cores.to_i
-  nodes = bc_num_slots.blank? ? 1 : bc_num_slots.to_i
-
-  case node_type
-  when "hugemem"
-    ppn = 48
-    partition = bc_num_slots.to_i > 1 ? "hugemem-parallel" : "hugemem"
-    slurm_args = [ "--nodes", "#{nodes}", "--ntasks-per-node", "#{ppn}", "--partition", partition ]
-  when "vis"
-    slurm_args = ["--nodes", "#{nodes}", "--ntasks-per-node", "#{ppn}", "--gpus-per-node", "1", "--gres", "vis" ]
-  else
-    slurm_args = ["--nodes", "#{nodes}", "--ntasks-per-node", "#{ppn}" ]
-  end
-%>
 ---
 batch_connect:
-  template: vnc
+  template: "vnc"
 script:
-  accounting_id: "<%= account %>"
   native:
-  <%- slurm_args.each do |arg| %>
-    - "<%= arg %>"
-  <%- end %>
+    - "-N 1"
+    - "-n <%= bc_num_slots.blank? ? 1 : bc_num_slots.to_i %>"
+    - "--mem-per-cpu=<%= bc_num_mems.blank? ? 4 : bc_num_mems.to_i %>G"
+    - "--partition=<%= bc_partition %>"
+    - "--time=<%= bc_num_hours.blank? ? 1 : bc_num_hours.to_i %>:00:00"
+    - "--job-name=ood-matlab-<%= version.split("/")[-1] %>"
+<%- if bc_partition.include? "pascalnodes" -%>
+    - "--gres=gpu:1"
+<%- end -%>
-- 
GitLab