Extra arguments field in batch connect form

For my JupyterLab app, I want a text field for extra Slurm arguments. Here’s what I did:

form.yml

attributes:
  extra_slurm_args:
    label: Extra arguments for Slurm
    widget: text_field
    help: |
      arguments documented in the [sbatch manual](https://slurm.schedmd.com/sbatch.html)

form:
  - extra_slurm_args

submit.yml

script:
  native:
  - <%= extra_slurm_args.blank? ? "--clusters=unity" : extra_slurm_args.to_s %>  

using clusters=unity as my default value because an empty string doesn’t work, and this OOD instance will only ever serve the “unity” cluster.

This works with one argument. I can use -w <hostname> in that text field and it works as expected. It breaks when I try to use multiple arguments. -w <hostname> --export=EDITOR fails like this: slurm_allocate_resources error opening file. The Slurm source code prints that error when it fails to open a “host-file”, so it seems that my export has become part of the -w --nodelist argument. I think it’s because both arguments are one entry in the native list, which I assume translates to argv.

So I need a way to take a text field, split it into an array by spaces, and append each element in the resulting array to my native list.

It seems like a difficult problem, but surely I’m not the first to try and implement custom slurm arguments in a batch connect form; Right?

You can put them in an array. I believe it’s coming from Linux argument separators. We’re passing that string as 1 Linux command line argument, when it should be many.


<%-
args = if extra_slurm_args.emtpy?
         ['--clusters=unity']
       else
         extra_slurm_args.split(' ')
       end
-%>

script:
  native:
  <%- args.each do |arg| -%>
    - <%= arg -%>
  <%- end -%>

This didn’t work for me.

submit:

<%-
extra_slurm_args_array = if extra_slurm_args.blank?
        ['--clusters=unity']
    else
        extra_slurm_args.split(' ')
    end
-%>

script:
  native:
  <%- extra_slurm_args_array.each do |arg| -%>
  - <%= arg -%>
  <%- end -%>

my string:
-w login-build001 --export EDITOR=/usr/bin/mousepad

result:

sbatch: error: slurm_allocate_resources error opening file   - login-build001  - --export  - EDITOR=/usr/bin/mousepad, No such file or directory

Maybe each - <%= arg -%> was concatenated onto the same line?

On a side note, is there a way for me to see what Slurm command OOD tried to submit? I don’t see it anywhere in the staged root directory.

There’s one extra - that needs to be removed. Once removed, my job is submitted successfully, so I would assume that the arguments were processed correctly.

  - <%= arg %>

rather than

  - <%= arg -%>

Sorry about that, I wrote that from memory instead of linking to an app that uses it.

Yes, you can see every command we issue in your /var/log/ondemand-nginx/$USER/error.log when you search for execve.

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