Move SLURM script to jinja template

This commit is contained in:
Benoît Seignovert 2024-03-13 18:38:29 +01:00
parent d091a6fd99
commit 8217d63c41
Signed by: Benoît Seignovert
GPG key ID: F5D8895227D18A0B
7 changed files with 108 additions and 68 deletions

View file

@ -1,4 +1,4 @@
"""Test form templates module."""
"""Test template form module."""
import re
from pathlib import Path

20
tests/test_templates.py Normal file
View file

@ -0,0 +1,20 @@
"""Test Jinja templates module."""
from glicid_spawner.templates import get_template_src, render_template
def test_template_src():
"""Test jinja template source."""
src = get_template_src('slurm_script.jinja')
assert src.startswith('#!/bin/bash\n{#- SLURM batch script for GLiCID spawner #}')
assert src.endswith('} > ${JUPYTER_JOB_LOG} 2>&1\n')
def test_template_render():
"""Test jinja template render."""
src = render_template('slurm_script.jinja', job_name='foo', qos='short', gres='bar', cmd='cmd')
assert src.startswith('#!/bin/bash\n\n#SBATCH --job-name=foo\n')
assert '#SBATCH --export=\n#SBATCH --qos=short\n#SBATCH --gres=bar\n' in src
assert src.endswith('cmd;} > ${JUPYTER_JOB_LOG} 2>&1')