mirror of
https://github.com/azaion/ai-training.git
synced 2026-04-22 08:56:35 +00:00
Refactor constants management to use Pydantic BaseModel for configuration
- Replaced module-level path variables in constants.py with a structured Pydantic Config class. - Updated all relevant modules (train.py, augmentation.py, exports.py, dataset-visualiser.py, manual_run.py) to access paths through the new config structure. - Fixed bugs related to image processing and model saving. - Enhanced test infrastructure to accommodate the new configuration approach. This refactor improves code maintainability and clarity by centralizing configuration management.
This commit is contained in:
@@ -42,9 +42,13 @@ def data_yaml_text(monkeypatch, tmp_path, fixture_classes_json):
|
||||
_stub_train_imports()
|
||||
import train
|
||||
|
||||
monkeypatch.setattr(train, "today_dataset", str(tmp_path))
|
||||
import constants as c
|
||||
monkeypatch.setattr(c, "config", c.Config(dirs=c.DirsConfig(root=str(tmp_path))))
|
||||
monkeypatch.setattr(train, "today_folder", "")
|
||||
from pathlib import Path
|
||||
Path(c.config.datasets_dir).mkdir(parents=True, exist_ok=True)
|
||||
train.create_yaml()
|
||||
return (tmp_path / "data.yaml").read_text(encoding="utf-8")
|
||||
return (Path(c.config.datasets_dir) / "data.yaml").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_bt_cls_01_base_classes(fixture_classes_json):
|
||||
|
||||
Reference in New Issue
Block a user