I’m working on shared templates between multiple interactive apps but am running into issues debugging some templating ERB errors with form.yml.erb
and submit.yml.erb
. It would help if I could view the resulting .yml
files but I cannot find where these are stored.
Here is an example of what I’m doing:
<%-
require 'yaml'
require 'open3'
begin
template_root = File.expand_path(File.join(__dir__, '..', 'templates'))
template_submit = YAML.load( ERB.new(File.read(File.join(template_root, 'submit.yml.erb')), trim_mode: '-').result(binding) )
rescue => e
puts e.message.strip
end
-%>
---
batch_connect:
template: basic
conn_params:
- csrftoken
script:
queue_name: <%= template_submit['script']['queue_name'] -%>
native:
<%= YAML.dump(template_submit['script']['native']).gsub("---\n", '').gsub(/^/," ") -%>
Which loads data from a shared template that looks like:
---
script:
queue_name: <%= custom_queue %>
native:
- "--nodes"
- "<%= bc_num_slots.blank? ? 1 : bc_num_slots.to_i %>"
- "--ntasks"
- "<%= bc_num_slots.blank? ? 1 : bc_num_slots.to_i %>"
- "--cpus-per-task"
- "<%= num_cpus.blank? ? 1 : num_cpus.to_i %>"
- "--mem"
- "<%= num_mem.blank? ? 1 : num_mem.to_i %>G"
<%- unless email.blank? -%>
- "--mail-user"
- "<%= email %>"
- "--mail-type"
- "BEGIN,END,FAIL"
<%- end -%>
<%- if num_gpus.to_i >0 -%>
- "--gpus-per-task"
- "<%= num_gpus.to_i %>"
<%- end -%>
<%- if custom_queue.to_s == "backfill" -%>
- "--requeue"
<%- end -%>
<%- unless node_list.blank? -%>
- "--nodelist"
- "<%= node_list %>"
<%- end -%>
<%- unless node_features_constraint.blank? -%>
- "--constraint"
- "<%= node_features_constraint %>"
<%- end -%>
<%- unless node_features_prefer.blank? -%>
- "--prefer"
- "<%= node_features_prefer %>"
<%- end -%>
I’ve validated that the queue and slurm flags are being correctly set on job submission. However, the ‘csrftoken’ from the ‘con_params’ is being mangled somehow as denoted by rserver error logs. The only change I’ve made to the current app was with the submit.yml.erb
which somehow introduced these errors.
2023-12-08T18:37:55.650710Z [rserver] INFO Reading rserver configuration from '/etc/rstudio/rserver.conf'
2023-12-08T18:37:55.654471Z [rserver] INFO Running as server user 'nvonwolf' (without privilege)
2023-12-08T18:37:55.656314Z [rserver] INFO Running without privilege; generating secure key at /tmp/rstudio-server/secure-cookie-key
2023-12-08T18:37:55.656623Z [rserver] INFO Reading database configuration from '/etc/rstudio/database.conf'
2023-12-08T18:37:55.656766Z [rserver] INFO Connecting to sqlite3 database at /var/lib/rstudio-server/rstudio-os.sqlite
2023-12-08T18:37:55.656859Z [rserver] INFO Creating database connection pool of size 20 (source: default maximum with 20 CPUs)
2023-12-08T18:37:55.666737Z [rserver] INFO Database schema has not been created yet. Creating database schema...
2023-12-08T18:37:55.669070Z [rserver] INFO No environment variables found at /etc/rstudio/env-vars
2023-12-08T18:38:11.410641Z [rserver] ERROR Failed to validate sign-in with invalid CSRF form; LOGGED FROM: bool rstudio::server::auth::common::validateSignIn(const rstudio::core::http::Request&, rstudio::core::http::Response*) src/cpp/server/auth/ServerAuthCommon.cpp:132
2023-12-08T18:38:19.421110Z [rserver] ERROR Failed to validate sign-in with invalid CSRF form; LOGGED FROM: bool rstudio::server::auth::common::validateSignIn(const rstudio::core::http::Request&, rstudio::core::http::Response*) src/cpp/server/auth/ServerAuthCommon.cpp:132
2023-12-08T18:39:04.724633Z [rserver] ERROR Failed to validate sign-in with invalid CSRF form; LOGGED FROM: bool rstudio::server::auth::common::validateSignIn(const rstudio::core::http::Request&, rstudio::core::http::Response*) src/cpp/server/auth/ServerAuthCommon.cpp:132
Unfortunately the compiled submit.yml.erb
→ submit.yml
doesn’t get placed in the job data directory or anywhere else that I can find in the user’s home directory or the ondemand server. Where do these files get compiled to?