Skip to content

HPC

HPC job script generation for cluster environments.

Functions

hpc_configure

1
2
3
from lst_tools import hpc_configure

hpc_cfg = hpc_configure(config, set_defaults=True)

Build an HPC configuration object from the project config.

lst_tools.hpc.hpc_configure

hpc_configure(cfg: dict[str, Any], set_defaults: bool = False, *, nodes_override: int | None = None, ntasks_per_node_override: int | None = None, time_override: float | str | None = None) -> ResolvedJob

Detect environment and build a :class:ResolvedJob.

Parameters

cfg: Full application config (Config dataclass or plain dict). set_defaults: Apply generous defaults (nodes=10, time=1.0). nodes_override, ntasks_per_node_override, time_override: Programmatic overrides — used by callers like tracking_setup that compute optimal values before building the script.

script_build

1
2
3
from lst_tools import script_build

script_build(hpc_cfg)

Generate job submission scripts from the HPC configuration.

lst_tools.hpc.script_build

script_build(cfg: ResolvedJob, fpath: str | Path, *, args: list[str] | None = None, lst_exe: str | None = None, extra_env: dict[str, str] | None = None) -> Path

Render a batch script and write it to fpath.

Parameters

cfg: A :class:ResolvedJob (from :func:hpc_configure). fpath: Path where the script file is created. args: Command-line arguments for the solver. lst_exe: Name or path of the LST executable. extra_env: Additional environment variables to export.

Returns

Path Absolute path to the written script file.

ResolvedJob

from lst_tools import ResolvedJob

Resolved scheduler-specific job settings used by script generation.

lst_tools.hpc.ResolvedJob dataclass

ResolvedJob(nodes: int | None = None, ntasks_per_node: int | None = None, cpus_per_task: int | None = None, time: float | str = 1.0, partition: str | None = None, qos: str | None = None, account: str | None = None, mem_per_cpu: str | None = None, constraint: str | None = None, job_name: str = 'lst', output: str | None = None, workdir: str | None = None, hostname: str | None = None, scheduler: str | None = None, launcher: str | None = None, modules: tuple[str, ...] = (), extra_sbatch: tuple[str, ...] = (), extra_pbs: tuple[str, ...] = (), fname_run_script: str | None = None)

All parameters required to render an HPC batch script.

get

get(key: str, default: Any = None) -> Any

Attribute access with a fallback, like dict.get.

to_dict

to_dict() -> dict[str, Any]

Return a dict of all non-None fields.

detect

1
2
3
from lst_tools.hpc import detect

env = detect()

Detect scheduler/environment information (for example SLURM or PBS context).

lst_tools.hpc.detect cached

detect() -> DetectedEnv

Probe the runtime environment (cached for the process lifetime).