Through a lot of trial and error, looking at job_script_options.json
results, i’ve figured it out. ERB.new
combined with .result(binding)
was leaking and somehow causing everything else in the submit.json.erb
file to be ignored.
Here is the fixed code that now works:
submit.yml.erb
<%-
require 'yaml'
require 'open3'
template_root = File.expand_path(File.join(__dir__, '..', 'templates'))
file_content = File.read(File.join(template_root, 'test.yml.erb'))
erb_content = ""
ERB.new(file_content, trim_mode: '-', eoutvar: "erb_content").result(binding)
yaml_content = YAML.load(erb_content)
-%>
---
batch_connect:
template: basic
script:
queue_name: <%= yaml_content['script']['queue_name'] %>
native:
<%= YAML.dump(yaml_content['script']['native']).gsub("---\n", '').gsub(/^/," ") %>
- "--hint"
- "nomultithread"
job_script_options.json
{
"job_name": "sys/dashboard/dev/matlab-web",
"workdir": "/fs1/home/nvonwolf/ondemand/data/sys/dashboard/batch_connect/dev/matlab-web/output/62e4e042-61bb-46ad-98af-3121cb73abc1",
"output_path": "/fs1/home/nvonwolf/ondemand/data/sys/dashboard/batch_connect/dev/matlab-web/output/62e4e042-61bb-46ad-98af-3121cb73abc1/output.log",
"shell_path": "/bin/bash",
"wall_time": 3600,
"native": [
"--nodes",
"1",
"--ntasks",
"1",
"--cpus-per-task",
"4",
"--mem",
"4G",
"--hint",
"nomultithread"
],
"queue_name": "interactive"
}
Looking at the native
value you can see that the nomultithread
flag is now showing up where previously it did not.
While I split up the ruby code to more easily troubleshoot, the fix was using eoutvar
with ERB.new
. This stopped the unexpected behavior and fixed my issues with both this matlab example and the initial rstudio example.