slurmer package

Submodules

slurmer.config module

class slurmer.config.TemplateManager[source]

Bases: object

Manages template file path

add_path(path: str | PathLike)[source]

Add path to config.

Parameters:

path – Directory to find templates in.

Raises:

ValueError – Raised if path already exists in config.

clear()[source]

Reset to default

remove_path(path: str | PathLike)[source]

Remove path from config.

Parameters:

path – Directory to remove.

Raises:

ValueError – Raised if path does not exists in config.

show_dirs()[source]

Show directories for finding template files.

show_templates()[source]

Show full list of template files.

slurmer.job module

class slurmer.job.SlurmJob(workdir: str | PathLike, template_file: str, job_name: str, node_partition: str, num_nodes: int, num_tasks: int, node_list: Sequence[int] | None = None, node_exclude_list: str | None = None, **kwargs)[source]

Bases: object

Slurm job class.

Parameters:
  • workdir – Working directory for slurm jon.

  • template_file – Path of template file.

  • job_name – Name of job.

  • node_partition – Partition of nodes.

  • num_nodes – The number of nodes.

  • num_tasks – The number of tasks(threads).

  • node_list – List of nodes to use. Defaults to None.

  • node_exclude_list – List of nodes to exclude. Defaults to None.

  • kwargs – Optional arguments, which are passed into generate_jobscript.

property job_script: str

Job script.

Returns:

Generated job script from instance attributes.

Return type:

str

submit(write_job_script: bool = False, job_script_name: str = 'job_script.sh')[source]

Submit batch job via slurm workload manager.

Parameters:
  • write_job_script – Whether to write the job script in self.workdir. Defaults to False.

  • job_script_name – Name of the job script. Defaults to “job_script.sh”.

Raises:

RuntimeError – Raised if the working directory does not exist.

slurmer.job.generate_jobscript(template_file: str, job_name: str, node_partition: str, num_nodes: int, num_tasks: int, node_list: Sequence[int] | None = None, node_exclude_list: str | None = None, **kwargs) str[source]

Get slurm job script.

Parameters:
  • template_file – Path of template file.

  • job_name – Name of job.

  • node_partition – Partition of nodes.

  • num_nodes – The number of nodes.

  • num_tasks – The number of tasks(threads).

  • node_list – List of nodes to use. Defaults to None.

  • node_exclude_list – List of nodes to exclude. Defaults to None.

  • kwargs – Optional template identifiers.

Raises:

ValueError – Raised when both node_list and node_exclude_list are specified.

Returns:

Rendered job script as string.

Return type:

str

Module contents

slurmer.list_templates()[source]

Show list of templates. Directory and filename are displayed.