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
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 -%>
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.