Config
Configuration management for lst_tools.
Functions
read_config
Read a TOML configuration file and return a typed Config dataclass.
lst_tools.config.read_config
Load and return an lst_tools configuration.
This module is the public entry-point for config loading.
The heavy lifting lives in schema.py (dataclasses + coercion).
read_config
Load configuration from a TOML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path | None
|
Explicit TOML path. If omitted, searches
for common config filenames in the CWD ( |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Config |
Config
|
A |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If path is given but does not exist on disk. |
write_config
Write configuration data to a TOML file.
lst_tools.config.write_config
Write a TOML configuration file.
Serialises a config dictionary into a TOML file on disk.
write_config
write_config(path: str | Path = 'lst.cfg', overwrite: bool = False, cfg_data: dict[str, Any] | None = None) -> Path
Write a TOML configuration file to path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Destination path for the config file. |
'lst.cfg'
|
overwrite
|
bool
|
If |
False
|
cfg_data
|
dict
|
Config dictionary to serialise. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The path the config was written to (or already existed at). |
Config
Typed configuration schema and validation.
lst_tools.config.Config
dataclass
Config(input_file: str = 'base_flow.hdf5', lst_exe: str = 'lst.x', flow_conditions: FlowConditions = FlowConditions(), geometry: Geometry = Geometry(), meanflow_conversion: MeanflowConversion = MeanflowConversion(), lst: LstConfig = LstConfig(), hpc: HpcConfig = HpcConfig(), processing: Processing = Processing(), seed_table: SeedTable = SeedTable(), extract: ExtractConfig = ExtractConfig())
Bases: _ConfigBase
Complete lst_tools configuration.
Build from a raw dict::
1 | |
Build directly from a TOML file::
1 | |
Access fields as attributes::
1 2 | |
from_dict
classmethod
Build a validated Config from a plain nested dict.
Each top-level key in d is dispatched to the corresponding
section dataclass (e.g. d["flow_conditions"] is forwarded
to FlowConditions.from_dict). Missing sections get their
default values. The resulting Config is validated before
being returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
dict[str, Any]
|
Raw config dictionary, typically the
output of |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Config |
Config
|
Fully populated and validated configuration. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If validation finds constraint violations. |
from_toml
classmethod
Parse a TOML file into a Config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to a TOML configuration file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Config |
Config
|
Validated configuration object. |
find_config
Search for a configuration file in the current directory and parent directories.
lst_tools.config.find_config
Locate a configuration file by scanning for known filenames.
Fallback routine used when no explicit --cfg path is passed to a
CLI command. Searches search_path for commonly used config file names
(lst.cfg, lst.toml, config.toml) and returns the first match.
find_config
Search search_path for a recognised configuration file.
Iterates over a priority-ordered list of candidate filenames and returns the first one that exists on disk.
Parameters
search_path : str | Path, optional Directory to scan (default: current working directory).
Returns
Path | None
Path to the first matching config file, or None if no
candidates are found.
check_consistency
Check configuration for internal consistency and return a diagnostic report.
lst_tools.config.check_consistency
Validate configuration consistency.
Defines a registry of named checks that inspect a config dictionary
for contradictions (e.g. geometry type vs. solver switch). Results
are returned as typed Issue objects split into errors and warnings.
Issue
dataclass
Single consistency problem found in a configuration.
IssueLevel
Bases: Enum
Severity level for a consistency issue.
check_consistency
check_consistency(cfg: dict[str, Any], *, enabled: Iterable[str] | None = None) -> tuple[list[Issue], list[Issue]]
Run all registered checks and return (errors, warnings).
Parameters
cfg : dict
Configuration dictionary (or Config dataclass with to_dict).
enabled : Iterable[str] | None
If provided, only run checks whose names are in this set.
Returns
tuple[list[Issue], list[Issue]]
(errors, warnings) collected from all executed checks.
format_report
Format errors and warnings into a human-readable string.
get
Retrieve a value from a nested dict using a dotted path.
Parameters
d : dict
Nested dictionary to search.
path : str
Dot-separated key path, e.g. "lst.solver.type".
default : Any
Value returned when any segment is missing.