# Problems defining "submit:"/using a custom script w/MATLAB form.yml

**URL:** <https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929>\
**Category:** Get Help\
**Tags:** ondemand2, question\
**Created:** [February 22, 2022, 6:29pm UTC](https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929 "2022-02-22T18:29:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![novosirj](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/novosirj/32/339_2.png) [@novosirj](https://discourse.openondemand.org/u/novosirj)\
**Post date:** [February 22, 2022, 6:29pm UTC](https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929/1 "2022-02-22T18:29:22Z")

</div>

Hi there. I’m attempting to configure a new MATLAB app in much the same way I set up the Desktop app, integrating a Singularity container to provide the MATE desktop environment. Here’s what I’m referring to:

> [@Need some help with custom submission and custom script files together with bc\_desktop app](https://discourse.openondemand.org/t/need-some-help-with-custom-submission-and-custom-script-files-together-with-bc-desktop-app/680):
>
> Hi there. New to maintaining an Open OnDemand instance (we’ve currently got 3). The person who did our initial install did something similar to what the poster here did. modifying files in /var/www/ood/apps to make customizations: …which bit me on upgrade is it did the poster in the other thread. I’ve since seen that what should have been done is for /etc/ood/config/apps to be where customizations should be made. To that end, I’ve added a “submit: submit/submit.yml.erb” to the various /etc/oo…

> [@Mate Desktop in a Singularity container?](https://discourse.openondemand.org/t/mate-desktop-in-a-singularity-container/696):
>
> At the moment, we have allocated a number of the compute nodes in our cluster as “desktop nodes” for running Mate Desktop sessions and have created custom images for them that include all of the desktop packages. We normally do not install such packages on our compute nodes in order to avoid “bloat” and ensure higher performance. What we would like to do, though, is to allow our users to run the Mate Desktop as a Singularity container so that it could, at least in theory, run on any compute node…

At the top of my form, I include:

```auto
submit: submit/container.yml.erb

```

Where I run into a snag I guess is where to place a modified version of `script.sh.erb` in `/etc`. When I go to launch the app, it fails because I don’t have a module called `xalt/latest`. I have my own copy of `script.sh.erb` in `/etc/ood/config/apps/bc_osc_matlab/submit/template`, and have also tried it in `/etc/ood/config/apps/bc_osc_matlab/template`. Am I misunderstanding how this works?

I’m attempting to use the MATLAB app as-is and modify it via configs overlayed in `/etc/ood/config/apps/bc_osc_matlab`, in essence, so that if there’s a new version, I don’t need to merge code together, etc.

The docs explain how to sandbox one of the example apps, but from what I’ve noticed, not really the best practices for installing/configuring one that goes into `/var/www/ood/apps/sys`.

Thanks in advance for the help.

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [February 22, 2022, 7:25pm UTC](https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929/2 "2022-02-22T19:25:07Z")

</div>

Hello and welcome!

Those posts are quite long so I apologize ahead of time if I’m missing something. The locations to set and place the files should be covered here: [4. Custom Job Submission — Open OnDemand 2.0.20 documentation](https://osc.github.io/ood-documentation/latest/enable-desktops/custom-job-submission.html)

So you could use whatever path you like, it just needs to match what your `cluster.yml` has for the location in that root app location you are working in, here `bc_osc_matlab`.

Is the `script.sh.erb` set to install that `xalt/latest` module?

---

<div class="post-metadata">

**Author:** ![novosirj](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/novosirj/32/339_2.png) [@novosirj](https://discourse.openondemand.org/u/novosirj)\
**Post date:** [February 22, 2022, 7:42pm UTC](https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929/3 "2022-02-22T19:42:31Z")

</div>

No, it doesn’t install that module. So what I did:

Set up `/etc/ood/config/apps/bc_osc_matlab`, and include a `form.yml`, which has `submit: submit/container.yml.erb` and then reused that file from my `bc_desktop` instance, which works great for that app. After discovering this problem, I also copied script.sh.erb to where I thought it needed to go under the app directory above – trying the root of that directory, and `submit` and `templates` and removed the reference to `xalt/latest` because we don’t currently have it installed.

What’s very unclear to me is where OOD will look for `script.sh.erb`. The only reference to it anyplace is the `%s` in my `container.yml.erb` (at least that’s what I assume `%s` does):

```auto
[root@amarel-test2 bc_osc_matlab]# cat submit/container.yml.erb 
<%
  image="/projects/community/containers/mate_desktop-centos-7.9-login.sif"
%>
---
script:
  <%-
     extra_slurm_args = extra_slurm_options.split
  -%>
  reservation_id: "<%= reservation_id %>"
  native:
    - "-c"
    - "<%= num_cores.blank? ? 1 : num_cores.to_i %>"
    - "--mem=<%= memory_gigs %>G"
  <%- unless extra_slurm_options.empty? -%>
    <%- extra_slurm_args.each do |slurm_arg| -%>
    - "<%= slurm_arg %>"
    <%- end -%>
  <%- end -%>
  template: "vnc"
batch_connect:
  script_wrapper: |
    cat << "CTRSCRIPT" > container.sh
    export PATH="$PATH:/opt/TurboVNC/bin"
    %s  
    CTRSCRIPT
 
    module purge
    module load singularity/3.8.5

    #export SINGULARITY_BINDPATH="/run/munge:/run/munge,/tmp/$ID:/run/user,/projects,/scratch,/cache/sw:/opt/sw,/cache,/cache/home:/home,/projectsp,/projectsn,/projectsc,/etc/slurm"
    export SINGULARITY_BINDPATH="/run,/projects,/scratch,/cache/sw:/opt/sw,/cache,/cache/home:/home,/projectsp,/projectsn,/projectsc,/etc/slurm"

    singularity exec <%= image %> /bin/bash container.sh

```

This question is about the MATLAB app in particular, but is very similar to:

[https://discourse.openondemand.org/t/reusing-singularity-vnc-bc-desktop-configuration-in-apps/1882/7](https://discourse.openondemand.org/t/reusing-singularity-vnc-bc-desktop-configuration-in-apps/1882/7)

…because that’s really what I’m trying to do.

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [February 22, 2022, 8:34pm UTC](https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929/4 "2022-02-22T20:34:35Z")

</div>

You should place the `script.sh.erb` in the `bc_osc_matlab/template` directory, but you mentioned you had tried that already.

But, looking at that post, it seems like it did run, and threw an error about the `xalt/latest` module missing? Sorry, I’m still trying to piece the sequence together you are describing.

So, you at one point had the script in `bc_osc_matlab/template/script.sh.erb` and when you clicked the launch button, it threw an error about missing the `xalt/latest` module?

What happens now that you removed that `xalt/latest` reference with the file in that `template` directory and you try to launch?

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [February 22, 2022, 8:41pm UTC](https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929/5 "2022-02-22T20:41:36Z")

</div>

Hey sorry, I just realized you are trying to do a sub app and not a straight install.

You won’t be able to override that `script.sh.erb` that is already in the main matlab app, so that’s why you haven’t been able to get that to work. You can override the `submit` and `form` but the script can’t be.

The other thing to note is I believe that `etc/ood/config/app` path should be `/etc/ood/config/apps`.

---

<div class="post-metadata">

**Author:** ![novosirj](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/novosirj/32/339_2.png) [@novosirj](https://discourse.openondemand.org/u/novosirj)\
**Post date:** [February 22, 2022, 8:53pm UTC](https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929/6 "2022-02-22T20:53:38Z")

</div>

It seems to me that it’s still using the `/var/www/ood/apps/sys/bc_osc_matlab/script.sh.erb`, since my copy does not contain the `xalt/latest` module. Maybe I’ll put something in the scripts that makes it very clear which one is in use.

Now that I know at least where it’s supposed to go, that is going to help. Can I, in general, put any given file in the exact same place in `/var/www/ood/apps/sys/<app_dir>` or `/etc/ood/config/apps/<app_dir>` and expect that to work?

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [February 22, 2022, 9:05pm UTC](https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929/7 "2022-02-22T21:05:21Z")

</div>

Sorry for the confusion, please see my correction above.

You are correct that it will only use that `script.sh.erb` from the main matlab app, I apologize for any confusion.

You can override the `submit` and `form` using the `/etc/ood/config/apps` as you said, but that `script` from the main app you are trying to sub-app won’t work.

I hope that makes it more clear, and again I’m very sorry about the confusion.

---

<div class="post-metadata">

**Author:** ![novosirj](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/novosirj/32/339_2.png) [@novosirj](https://discourse.openondemand.org/u/novosirj)\
**Post date:** [February 22, 2022, 10:11pm UTC](https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929/8 "2022-02-22T22:11:11Z")

</div>

OK, thanks! That clears it up.

Yeah, re: `apps` my S key has been flaky lately; the typo is in the message, not the actual config (fixed it above).

Sorry about my shoddy description too – I started to post all of my config and by the time I redacted what I didn’t need to put in a public forum, it seemed easier to just describe.

What I’m primarily after is to have it be easier to do local modifications without changing the code of the app much. I can do it with patches or something instead, but so far I’ve gotten lucky I guess with the desktop app and have been able to deal with it entirely through `script_wrapper` or the like.

---

<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:** [August 21, 2022, 10:11pm UTC](https://discourse.openondemand.org/t/problems-defining-submit-using-a-custom-script-w-matlab-form-yml/1929/9 "2022-08-21T22:11:33Z")

</div>

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