Utilities API¶
Small helpers in ecgen.utils.
Config¶
resolve_config
¶
resolve_config(config_cls: Type[T], config: Optional[T | dict[str, Any]], flat_kwargs: dict[str, Any]) -> T
Build a config dataclass for a LightningModule constructor.
Wrappers save their config as flat hyperparameters, so
load_from_checkpoint calls __init__(**hparams) with one keyword per
config field instead of config=.... This accepts either form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_cls
|
Type[T]
|
Config dataclass type. |
required |
config
|
Optional[T | dict[str, Any]]
|
A config instance, a dict of its fields, or None. |
required |
flat_kwargs
|
dict[str, Any]
|
Extra keyword arguments passed to |
required |
Returns:
| Type | Description |
|---|---|
T
|
A |
T
|
|
T
|
|
Source code in src/ecgen/utils/config.py
Seed¶
set_global_seed
¶
Set seeds for Python, NumPy, and PyTorch (if available).
Source code in src/ecgen/utils/seed.py
I/O¶
Logging¶
get_logger
¶
Get a logger with a simple, consistent format.
Source code in src/ecgen/utils/logging.py
Run metadata¶
collect_run_metadata
¶
collect_run_metadata(*, config_path: Path | None, cfg: Dict[str, Any], run_dir: Path, argv: list[str] | None = None) -> Dict[str, Any]
Collect lightweight metadata about the current run.