flow-matching-1 / src /flowfm /config.py
sabertoaster's picture
Add files using upload-large-folder tool
e8deda1 verified
Raw
History Blame Contribute Delete
800 Bytes
"""Configuration loading and output directory setup helpers."""
from pathlib import Path
from omegaconf import DictConfig, OmegaConf
from .constants import DEFAULT_SUBJECTS
def load_config(cfg_path: str | Path) -> DictConfig:
"""Load a YAML config into an OmegaConf DictConfig."""
return OmegaConf.load(cfg_path)
def resolve_subjects(cfg: DictConfig) -> list[int]:
"""Resolve subjects from config or fall back to defaults."""
subjects = cfg.get("subjects", list(DEFAULT_SUBJECTS))
return list(subjects)
def prepare_output_dir(cfg: DictConfig) -> Path:
"""Create output directory and persist an exact config snapshot."""
out_dir = Path(cfg.out_dir)
out_dir.mkdir(parents=True, exist_ok=True)
OmegaConf.save(cfg, out_dir / "config.yaml")
return out_dir