Show error in a messagebox during submit.yml.erb exec

Hello,

My purpose is to share a VNC session per user, with no time limit, to allow differents graphical jobs to use it. one user = one display = several graphical jobs. simple.

so i would like to verifiy some prerequites before submit to slurm :

  • is there a graphical VNC session running ?
  • what is the DISPLAY variable assigned to this VNC session

in case of error, i would like to open a messagebox to tell the user to open a VNC session first.

as this is a recurrent task, how to put this code into an external function script, working as a library ?

for the moment, i have realized this topic into the script.sh.erb by copying the same section of verifications. not very nice, not comprehensive for the user, because the error is logged into the output.log file after submission.

i’m working on ood 1.6.7. some ideas, please ?

note : the top would be to launch automaticaly the VNC session if missing.

thanks a lot

jean-marie

In the submit.yml.erb you can raise an exception with a message, and the message will appear in an error message to the user and no (this was fixed in the 1.6 release as before that files would be copied unnecessarily when an error occurred).

For example, in erb tags I do raise "This is an error message" and when I submit the form I get this error:

  • Note I do realize after seeing this that the footnote in the error message is no longer helpful because files are not copied if the error takes place.

As for having code in a function you can call from your erb in interactive apps, one way is to add this to the Rails initializer for the Dashboard app. See https://listsprd.osu.edu/pipermail/ood-users/2018-November/000297.html for an example of how to do this. It is important to create a module with your institution name or something that would never conflict with another module.

The idea is the initizializer defines a module and a class with the methods you want (and can even memoize return values using instance variables as a simple cache) and then you can use these in the interactive app erb files.

Hi,
To follow your proposal, my colleague and I have tried to implement this process on a PARAVIEW example :

if no vnc motif session is launched by the user, the PARAVIEW template has to stop on a raise message before starting the slurm job.

in fact, it goes on and it’s failed into the job, of course.

why. because the “vnc_display” stays with the previous good value.

here is a trap on the different files done at the same times :

Every 10,0s: cat /tmp/disp_jms.log /tmp/form.log /t… Sun Jul 21 09:18:29 2019

display : date Sun Jul 21 09:18:20 CEST 2019
display : user jms
display : myFile /home/jms/.vnc/motif.log
display : ligne
display : display none

form : date Sun Jul 21 09:18:20 CEST 2019
form : none

submit : date Sun Jul 21 09:17:07 CEST 2019
submit : DISPLAY=nodeSu-001:1

QUESTION : what’s going wrong ?

here are the files implemented :

cat /etc/ood/config/apps/dashboard/initializers/display.rb

def qdisplay
@DISPLAY = “none”
@myFile = ENV[‘HOME’] + “/.vnc/motif.log”
@myLogFile = “/tmp/disp_”+ENV[‘USER’]+".log"
system ("rm -f "+@myLogFile)
system ("touch "+@myLogFile)
@date = %x[date]
@ligne = %x[squeue -u USER -n MOTIF|tail -1f | grep MOTIF] if ?.exitstatus == 0 then
aFile = File.open(@myFile, “r”)
if aFile then

@DISPLAY = aFile.sysread(80)

  		@DISPLAY = aFile.read()
	end	 
   	aFile.close
end

aFile = File.open(@myLogFile, "w")
aFile.puts("display : date "+@date)
aFile.puts("display : user "+ENV['USER'])
aFile.puts("display : myFile "+@myFile)
aFile.puts("display : ligne "+@ligne)
aFile.puts("display : display "+@DISPLAY)
aFile.puts()
aFile.close

return @DISPLAY

end

cat /var/www/ood/apps/sys/VIEW/form.yml.erb

<%-
projects = OodAppkit.clusters[:verhpc].custom_config[:projects]
vnc_disp = qdisplay
@date = %x[date]
aFile = File.new("/tmp/form.log", “w”)
aFile.puts("form : date "+@date)
aFile.puts("form : "+vnc_disp)
aFile.puts()
aFile.close
-%>

cluster: “verhpc”
form:

  • version
  • work_dir
  • project
  • num_cores
  • memory_by_core
  • vnc_disp
  • bc_vnc_resolution
    attributes:
    version:
    widget: select
    label: “Paraview version”
    help: “This defines the version of PARAVIEW you want to load.”
    options:
    • [ “5.3.0”, “software/paraview/5.3.0” ]
      work_dir:
      widget: “text_field”
      label: “Working Directory”
      help: “Type the name of the directory you want to working in”
      project:
      widget: select
      label: “Project”
      help: “You can leave this blank if not in multiple projects.”
      options:
      <%- projects.each do |p| -%>
    • [ “<%= p %>”, “<%= p %>” ]
      <%- end -%>

num_cores:
widget: “number_field”
label: “Number of cores”
help: |
Number of cores on node type (4 GB per core unless requesting whole
node). Leave blank if requesting full node.
min: 0 # This is treated as requesting the max allowable
max: 1 # This will be updated by form.js
step: 1
id: num_cores
memory_by_core:
widget: “number_field”
label: “Memory by core”
help: |
Number of memory by core. Leave blank if requesting anything.
min: 0 # This is treated as requesting the max allowable
max: 2 # This will be updated by form.js
step: 1
id: memory_by_core

vnc_disp:
widget: “hidden_field”

widget: “text_field”

value: <%= vnc_disp %>
id: vnc_disp

bc_vnc_resolution:
required: true

cat /var/www/ood/apps/sys/VIEW/submit.yml.erb

<%-
nb_cores = num_cores.blank? ? 1 : num_cores
memory = memory_by_core.blank? ? 1 : memory_by_core
vnc_display = vnc_disp
@date = %x[date]
aFile = File.new("/tmp/submit.log", “w”)
aFile.puts("submit : date "+@date)
aFile.puts("submit : “+vnc_display)
aFile.puts()
aFile.close
if vnc_display == “none” then
raise " Error : the display is not defined, please launch a motif desktop first”
end

-%>

batch_connect:
template: “basic”
script:
native: [ “-JPARAVIEW” , “-N” , “<%= nb_cores %>” , --mem-per-cpu=<%= memory %> , “-pinter” ]