# Extra arguments field in batch connect form

**URL:** <https://discourse.openondemand.org/t/extra-arguments-field-in-batch-connect-form/2426>\
**Category:** Get Help\
**Created:** [January 6, 2023, 10:08pm UTC](https://discourse.openondemand.org/t/extra-arguments-field-in-batch-connect-form/2426 "2023-01-06T22:08:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonleary-umass-edu](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/simonleary-umass-edu/32/1254_2.png) [@simonleary-umass-edu](https://discourse.openondemand.org/u/simonleary-umass-edu)\
**Post date:** [January 6, 2023, 10:08pm UTC](https://discourse.openondemand.org/t/extra-arguments-field-in-batch-connect-form/2426/1 "2023-01-06T22:08:17Z")

</div>

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

form.yml

```auto
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

```auto
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?

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [January 6, 2023, 11:31pm UTC](https://discourse.openondemand.org/t/extra-arguments-field-in-batch-connect-form/2426/2 "2023-01-06T23:31:32Z")

</div>

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.

```ruby

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

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

```

---

<div class="post-metadata">

**Author:** ![simonleary-umass-edu](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/simonleary-umass-edu/32/1254_2.png) [@simonleary-umass-edu](https://discourse.openondemand.org/u/simonleary-umass-edu)\
**Post date:** [January 10, 2023, 8:10pm UTC](https://discourse.openondemand.org/t/extra-arguments-field-in-batch-connect-form/2426/3 "2023-01-10T20:10:49Z")

</div>

This didn’t work for me.

submit:

```auto
<%-
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![simonleary-umass-edu](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/simonleary-umass-edu/32/1254_2.png) [@simonleary-umass-edu](https://discourse.openondemand.org/u/simonleary-umass-edu)\
**Post date:** [January 10, 2023, 8:13pm UTC](https://discourse.openondemand.org/t/extra-arguments-field-in-batch-connect-form/2426/4 "2023-01-10T20:13:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![simonleary-umass-edu](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/simonleary-umass-edu/32/1254_2.png) [@simonleary-umass-edu](https://discourse.openondemand.org/u/simonleary-umass-edu)\
**Post date:** [January 10, 2023, 8:15pm UTC](https://discourse.openondemand.org/t/extra-arguments-field-in-batch-connect-form/2426/5 "2023-01-10T20:15:46Z")

</div>

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.

```auto
  - <%= arg %>

```

rather than

```auto
  - <%= arg -%>

```

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [January 10, 2023, 8:38pm UTC](https://discourse.openondemand.org/t/extra-arguments-field-in-batch-connect-form/2426/6 "2023-01-10T20:38:10Z")

</div>

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

> [@simonleary-umass-edu](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bae70bd0ed39a3ae769c2108155f4cb3e9da8385.png) [@system](https://discourse.openondemand.org/u/system)\
**Post date:** [July 9, 2023, 8:38pm UTC](https://discourse.openondemand.org/t/extra-arguments-field-in-batch-connect-form/2426/7 "2023-07-09T20:38:33Z")

</div>

Closed on July 9, 2023, 8:38pm UTC

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