add some change twice

This commit is contained in:
Jiao77
2025-09-25 20:30:31 +08:00
parent 09f513686d
commit 8c6c5592b6
2 changed files with 161 additions and 0 deletions

23
utils/config_loader.py Normal file
View File

@@ -0,0 +1,23 @@
"""Configuration loading utilities using OmegaConf."""
from __future__ import annotations
from pathlib import Path
from typing import Union
from omegaconf import DictConfig, OmegaConf
def load_config(config_path: Union[str, Path]) -> DictConfig:
"""Load a YAML configuration file into a DictConfig."""
path = Path(config_path)
if not path.exists():
raise FileNotFoundError(f"Config file not found: {path}")
return OmegaConf.load(path)
def to_absolute_path(path_str: str, base_dir: Union[str, Path]) -> Path:
"""Resolve a possibly relative path against the configuration file directory."""
path = Path(path_str).expanduser()
if path.is_absolute():
return path.resolve()
return (Path(base_dir) / path).resolve()