mirror of
https://github.com/SikongJueluo/Mini-Nav.git
synced 2026-03-12 12:25:32 +08:00
refactor(configs, data_loading): improve code clarity and add docstrings
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user