SUGGESTION: Robustify example template files
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 184
- Forks
- 53
- Avg merge
- 7d 2h
- Merged PRs (30d)
- 1
Description
I'd like to suggest adding a bit of sanity checks to the template files. This will help lower the bar for new comers who are not aware of the various levels of R-to-scheduler orchestration involved.
Issue
In 'inst/templates/slurm-simple.tmpl' we have:
Take for instance the line:
#SBATCH --cpus-per-task=<%= resources$ncpus %>
if resources does not have ncpus set, then resources$ncpus is NULL, and then <%= NULL %> produces an empty string ``. That is, in the rendered job script, we get:
#SBATCH --cpus-per-task=
This in turn will produce a runtime error when Slurm tries to process the job script, e.g.
Error: Fatal error occurred: 101. Command 'sbatch' produced exit code 1. Output: 'sbatch: error: Invalid numeric value "" for cpus-per-task.'
A few suggestions
Avoid outputting the SBATCH directive if resources$ncpus is missing:
<%= if (!is.null(resources$ncpus)) { %>
#SBATCH --cpus-per-task=<%= resources$ncpus %>
<%= } %>
or, simply,
<%= sprintf("#SBATCH --cpus-per-task=%s", resources$ncpus) %>
Alternatively, make ncpus a mandatory field. At the top of the template file, do something like:
<%
if (is.null(resources$ncpus)) stop("Resource parameter 'ncpus' is not set")
%>
Related
The background for this is issue can be found in https://github.com/HenrikBengtsson/future.batchtools/issues/41
cc/ @wlandau-lilly (similar for drake's example templates)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced block in inst/templates/slurm-simple.tmpl, lines 26-34, and inspect how missing resources$ncpus is rendered. Decide whether the affected templates should omit invalid SBATCH directives or reject missing resources, then verify that a missing ncpus value no longer produces a malformed job script.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- hpc
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100