message_ix_models.model.transport.slurm.Template

class message_ix_models.model.transport.slurm.Template[source]

Bases: JinjaTemplate

Template for use with mix-models sbatch.

Example usage:

mix-models sbatch -m model.transport --go         -v branch=branch-to-run -v model_extra=debug         --         --from="" "SSP2 reported" -- go

The script performs the following actions, tailored for the IIASA ‘UnICC’ cluster and SLURM:

  1. Load necessary modules.

  2. Use uv to install message_ix_models and dependencies.

  3. Run mix-models transport run --go with additional arguments.

  4. Copy output files (e.g. reporting) to a shared drive.

__init__() → None[source]

Methods

__init__()

format([as_directives])

Prepare arguments and standard input from the template and parameters.

from_module(module_name)

Return the first instance of Template found in module_name.

prepare_parameters(parameters)

Attributes

argv

A list of str in which:

default_parameters

Default values for any parameters or substitution values used to format the argv.

file

Relative path of a file in message_ix_models/data/.

argv: list[str] = ['sbatch', '--job-name={job_name}', '--mem=64G', '--output=/home/{username}/slurm/{job_name}-%J.out', '--time=2:00:00'][source]

A list of str in which:

  • The first entry should be the name or path of a program, for instance sbatch.

  • The final entry should be a script body to be passed as standard input to the program.

  • Any intermediate entries should be command-line arguments to the program.

default_parameters: dict[str, str] = {'branch': 'main', 'job_name': 'MixT', 'model_extra': 'dev', 'nodes': 'R12', 'platform_dest': 'message-jdbc-pg', 'platform_src': 'ixmp-dev', 'python_version': '3.14', 'source': 'gitlab'}[source]

Default values for any parameters or substitution values used to format the argv.

file: PurePosixPath = PurePosixPath('transport/slurm.sh')[source]

Relative path of a file in message_ix_models/data/. The documentation for jinja.Environment.get_template() states “‘/’ is used as the file system separator, even on Windows.”

format(as_directives: bool = False, **parameters: Any) → tuple[list[str], bytes][source]

Prepare arguments and standard input from the template and parameters.

Parameters:

as_directives – If True, options to sbatch are formatted as #SBATCH lines, immediately after the first line of the template body. If False (default), they are returned as part of the arguments.

Returns:

with 2 elements:

  1. A list of command arguments, length 1 or greater. The first is the name or path of an program, for instance “sbatch”. The remainder are parameters or options to the same program.

  2. bytes with the formatted script body to be passed as standard input to the program.

Return type:

tuple

classmethod from_module(module_name: str) → Template[source]

Return the first instance of Template found in module_name.