Open OnDemand BatchConnect app fails with undefined method 'modules' and later port: unbound variable

Hi everyone,

I’m working on a custom Open OnDemand BatchConnect app for Ollama + Open WebUI and ran into two issues while staging and launching the app.

The first error during staging was:

Failed to stage the template with the following error:
undefined method `modules' for an instance of BatchConnect::SessionContext

I tracked that down to these references in the app templates:

MODS="<%= context.modules.to_s.strip %>"

which appeared in template/before.sh.erb and template/script.sh.erb.

After removing that older context.modules usage, the app stages and launches further, but now the job fails during startup with:

/var/spool/slurm/job.../slurm_script: line 15: port: unbound variable

Relevant details:

  • OOD app: custom dev app for Ollama/Open WebUI

  • Ports are generated in before.sh.erb and written to:

    • .port_webui

    • .port_ollama

  • Then loaded in script.sh.erb with:

port_webui="$(cat "${PWD}/.port_webui")"
port_ollama="$(cat "${PWD}/.port_ollama")"

I also found that the app had older port-style logic mixed with newer port_webui logic, for example:

port="${port_webui}"
export host port

and an old backup template:

---
host: "<%= host %>"
port: <%= port %>
scheme: "http"
path: "/"

The app now writes connection.yml using:

cat > "${PWD}/connection.yml" << EOF
---
host: "${host_fqdn}"
port: "${port_webui}"
scheme: "http"
path: "/"
EOF

What I’m trying to confirm is:

  1. In older OOD versions, is context.modules unsupported in BatchConnect SessionContext?

  2. Is the recommended approach to avoid context.modules entirely and load modules directly in before.sh.erb / script.sh.erb?

  3. For connection handling, should I rely on a template/connect.yml.erb file instead of writing connection.yml manually?

  4. Does anyone know if OOD may still be picking up an old connect.yml.erb / stale staged template that references bare port?

My current suspicion is that I still have a stale port-based connection template being rendered somewhere, even though the main script now uses port_webui.

Any guidance on the cleanest modern structure for:

  • form.yml.erb

  • submit.yml.erb

  • before.sh.erb

  • script.sh.erb

  • connect.yml.erb

would be greatly appreciated.

Thanks.

view.html.erb.txt (27.7 KB)

submit.yml.erb.txt (1019 Bytes)

script.sh.erb.txt (5.1 KB)

form.yml.erb.txt (2.1 KB)

before.sh.erb.txt (1.3 KB)

after.sh.erb.txt (1.1 KB)

Hello and welcome!

This is a custom app being built from scratch? Or is this being built from something else? Some of the wording has me confused here.

For your question around the context object, that is going to depend on what you defined in your form.yml.erb file. The context is something OOD provides to access data from that front-end on the backend in your scripts is all. So, if you didn’t define a modules in the form.yml then the context.modules return an error of modules does not exist because it was not defined (I don’t see it defined in the attached form.yml.

Here’s a doc entry on context: Render Template — Open OnDemand 4.1.0 documentation

And here’s a deeper dev from the contributor guide to show a more complete example: contributor_guide/contributor_jam_guide.md at main · OSC/contributor_guide · GitHub

You should not write the connection file manually, OOD is doing that for a reason and their are things happening in the session card that depend on that file being written out, but only after the job has started and relevant data has been shared to make the connection.

You can read more here: Connection Parameters conn_params — Open OnDemand 4.1.0 documentation