Issue with Creating custom Desktop configuration

I’m trying to customize my desktop form and submit script for my xfce desktop. But I keep running into and error which I’m not sure why i’m getting it.

The error is

undefined local variable or method `bc_num_slots’ for # BatchConnect::SessionContext:0x000014cde4dff590>

I set a default value for this variable in my beartooth_xfce.yml file. Here’s my file

title: “Beartooth Xfce Desktop”
cluster: “beartooth”

attributes:
desktop: “xfce”
bc_queue: spc-ondemand
bc_num_slots: 1

bc_account:
label: “Project/Account”
help: “Specify the name of your project”

bc_num_hours:
help: “The maximum number of hours your desktop session will run”
value: 1
min: 1
max: 168
required: true

node_type:
label: “Desktop Configuration”
help: “Select the CPU and memory configuration for the desktop”
widget: select
options:
- [ “1 CPU, 4GB memory”, “1:4G” ]
- [ “2 CPU, 8GB memory”, “2:8G” ]
- [ “4 CPU, 16GB memory”, “4:16G” ]

node_cpu:
label: “Desktop CPU Type”
help: “Select the CPU type for the desktop”
widget: select
default: “sandy”
options:
- [ “Sandy Bridge”, “sandy” ]
- [ “Broadwell”, “broadwell” ]
- [ “Ice Lake”, “icelake” ]

form:

  • bc_account
  • bc_num_hours
  • node_type
  • node_cpu

submit: “submit/beartooth.yml.erb”

This form defines the bc_num_slots variable.

and my submit file

<%-
emailcmd=‘ldapsearch -LLL -x -b “cn=users,cn=accounts,dc=arcc,dc=uwyo,dc=edu” uid=’ + ENV[“USER”] + ’ mail | grep “^mail:” | cut -f2 -d\ ’
emailaddr = %x[ #{emailcmd}].split(" ")
-%>


script:
email: <%= emailaddr %>

native:
- “-N”
- “<%= bc_num_slots.blank? ? 1 : bc_num_slots.to_i %>”
- “<%= ‘–cpus-per-task=’+node_type.split(”:“)[0] %>”
- “<%= ‘–mem=’+node_type.split(”:“)[1] %>”
- “<%= ‘–constraint=’+node_cpu %>”

Can anyone provide details on what I’m missing or doing wrong and how to fix it?

Hello and welcome!

Could you do me a favor and either upload the respective forms and config files, or post them in markdown? Knowing you have valid yml is needed when debugging this, and the current output makes that impossible.

There’s also the option of using markdown in the reply:

like this

To keep the formatting of the paste.

Having the correct yml can make this much easier on my end, thank you!

---

title: "Beartooth Xfce Desktop"
cluster: "beartooth"

attributes:
  desktop: "xfce"
  bc_queue: spc-ondemand
  bc_num_slots: 1

  bc_account:
    label: "Project/Account"
    help: "Specify the name of your project"

  bc_num_hours:
    help: "The maximum number of hours your desktop session will run"
    value: 1
    min: 1
    max: 168
    required: true

  node_type:
    label: "Desktop Configuration"
    help: "Select the CPU and memory configuration for the desktop"
    widget: select
    options:
      - [ "1 CPU, 4GB memory", "1:4G" ]
      - [ "2 CPU, 8GB memory", "2:8G" ]
      - [ "4 CPU, 16GB memory", "4:16G" ]

  node_cpu:
    label: "Desktop CPU Type"
    help: "Select the CPU type for the desktop"
    widget: select
    default: "sandy"
    options:
      - [ "Sandy Bridge", "sandy" ]
      - [ "Broadwell", "broadwell" ]
      - [ "Ice Lake", "icelake" ]

form:
  - bc_account
  - bc_num_hours
  - node_type
  - node_cpu

submit: "submit/beartooth.yml.erb"

here the submit file

<%-
  emailcmd='ldapsearch -LLL -x -b "cn=users,cn=accounts,dc=arcc,dc=uwyo,dc=edu" uid=' + ENV["USER"] + ' mail | grep "^mail:" | cut -f2 -d\    '
  emailaddr = %x[ #{emailcmd}].split(" ")
-%>

---
script:
  email: <%= emailaddr %>

  native:
    - "-N"
    - "<%= bc_num_slots.blank? ? 1 : bc_num_slots.to_i %>"
    - "<%= '--cpus-per-task='+node_type.split(":")[0] %>"
    - "<%= '--mem='+node_type.split(":")[1] %>"
    - "<%= '--constraint='+node_cpu %>"

Thanks for doing that!

Add the bc_num_slots to the form block, and then relaunch. That should do the trick.

If the problem persists, what happens if you use session.bc_num_slots when calling the variable and launching?

I added the bc_num_slots to the end of the form. I now get the following error

Failed to stage the template with the following error:

undefined method `desktop’ for #BatchConnect::SessionContext:0x0000563243602658

You have to add desktop to the form. You should probably add bc_num_slots as well. Since you have them both hardcoded, they won’t show up in the form, but I believe you still have to define them for them to be used.

form:
  - bc_account
  - bc_num_hours
  - node_type
  - node_cpu
  - desktop

So I took travis’s and Jeff’s suggestions and update the form file with bc_num_slots and desktop an the fixed the issue.

Are these gottchas documented any where? Can they be?

IDK if they are,but they can be added for sure. I assume you’re somewhere in these docs?

https://osc.github.io/ood-documentation/latest/enable-desktops.html

Yes, I am refering to that document page.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.