refactor(configs, data_loading): improve code clarity and add docstrings

This commit is contained in:
2026-02-28 22:07:25 +08:00
parent 88d1d0790d
commit f0479cc69b
6 changed files with 201 additions and 59 deletions

View File

@@ -1,3 +1,5 @@
"""Configuration management module for unified config."""
from .config import (
ConfigManager,
cfg_manager,
@@ -8,7 +10,6 @@ from .models import (
DatasetConfig,
ModelConfig,
OutputConfig,
PoolingType,
)
__all__ = [
@@ -17,7 +18,6 @@ __all__ = [
"OutputConfig",
"DatasetConfig",
"Config",
"PoolingType",
# Loader
"load_yaml",
"save_yaml",

View File

@@ -28,7 +28,7 @@ class ConfigManager:
"""Load configuration from config.yaml file.
Returns:
Loaded and validated FeatureCompressorConfig instance
Loaded and validated Config instance
"""
config = load_yaml(self.config_path, Config)
self._config = config
@@ -38,7 +38,7 @@ class ConfigManager:
"""Get loaded configuration, auto-loading if not already loaded.
Returns:
FeatureCompressorConfig instance
Config instance
Note:
Automatically loads config if not already loaded

View File

@@ -26,8 +26,8 @@ class OutputConfig(BaseModel):
@field_validator("directory", mode="after")
def convert_to_absolute(cls, v: Path) -> Path:
"""
Converts the path to an absolute path relative to the current working directory.
"""Converts the path to an absolute path relative to the project root.
This works even if the path doesn't exist on disk.
"""
if v.is_absolute():
@@ -55,8 +55,8 @@ class DatasetConfig(BaseModel):
@field_validator("dataset_root", "output_dir", mode="after")
def convert_to_absolute(cls, v: Path) -> Path:
"""
Converts the path to an absolute path relative to the project root.
"""Converts the path to an absolute path relative to the project root.
This works even if the path doesn't exist on disk.
"""
if v.is_absolute():