Skip to content

Commit

Permalink
Allow for injecting arbitrary sbatch headers
Browse files Browse the repository at this point in the history
  • Loading branch information
linsword13 committed Dec 6, 2024
1 parent ffe0dd1 commit 349fb4e
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Slurm(WorkflowManagerBase):
def _slurm_execute_script(self):
headers = ["#!/bin/bash"]
expander = self.app_inst.expander
# Adding pre-defined sets of headers
pragmas = [
("#SBATCH -N {}", "n_nodes"),
("#SBATCH -p {}", "partition"),
Expand All @@ -82,6 +83,18 @@ def _slurm_execute_script(self):
# Skip a particular header if any of the vars are not defined
continue
headers.append(tpl.format(*vals))
# Adding extra arbitrary headers
try:
extra_sbatch_headers_raw = expander.expand_var_name(
"extra_sbatch_headers", allow_passthrough=False
)
extra_sbatch_headers = extra_sbatch_headers_raw.strip().split("\n")
extra_headers = [
expander.expand_var(h) for h in extra_sbatch_headers
]
headers = headers + extra_headers
except ExpanderError:
pass
header_str = "\n".join(headers)
content = rf"""
{header_str}
Expand Down

0 comments on commit 349fb4e

Please sign in to comment.