Skip to content

Commit

Permalink
fix: raise explicit error if config is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
IamGianluca committed Mar 23, 2024
1 parent 0170e0b commit 529d97b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions blazingai/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@


def load_cfg(fpath: Path, cfg_name: str) -> DictConfig:
cfg = load_hparams_from_yaml(config_yaml=fpath, use_omegaconf=True)
cfg = cfg.get(cfg_name)
if hasattr(cfg, "lr"):
all_configs = load_hparams_from_yaml(config_yaml=fpath, use_omegaconf=True)
cfg = all_configs.get(cfg_name)
if cfg is None:
raise ValueError(f"Could not find config {cfg_name} in {fpath}")

if hasattr(cfg, "lr"): # convert exponential notation to float
cfg.lr = float(cfg.lr) # type: ignore

return cfg

0 comments on commit 529d97b

Please sign in to comment.