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:
Oleksandr Bezdieniezhnykh
2026-03-27 18:18:30 +02:00
parent b68c07b540
commit 142c6c4de8
106 changed files with 5706 additions and 654 deletions
@@ -0,0 +1,57 @@
# Annotation Class & YAML Tests
**Task**: AZ-159_test_annotation_classes
**Name**: Annotation Class & YAML Tests
**Description**: Implement 4 tests for annotation class loading, weather mode expansion, YAML generation, and total class count
**Complexity**: 2 points
**Dependencies**: AZ-152_test_infrastructure
**Component**: Blackbox Tests
**Jira**: AZ-159
**Epic**: AZ-151
## Problem
The system loads 17 base annotation classes, expands them across 3 weather modes, and generates a data.yaml with 80 class slots. Tests verify the class pipeline.
## Outcome
- 4 passing pytest tests in `tests/test_annotation_classes.py`
## Scope
### Included
- BT-CLS-01: Load 17 base classes from classes.json
- BT-CLS-02: Weather mode expansion (offsets 0, 20, 40)
- BT-CLS-03: YAML generation produces nc: 80 with 17 named + 63 placeholders
- RL-CLS-01: Total class count is exactly 80
### Excluded
- Training configuration (beyond scope)
## Acceptance Criteria
**AC-1: Base classes**
Given classes.json
When AnnotationClass.read_json() is called
Then returns dict with 17 unique base class entries
**AC-2: Weather expansion**
Given classes.json
When classes are read
Then same class exists at offset 0 (Norm), 20 (Wint), 40 (Night)
**AC-3: YAML generation**
Given classes.json + dataset path
When create_yaml() runs with patched paths
Then data.yaml contains nc: 80, 17 named classes + 63 Class-N placeholders
**AC-4: Total count**
Given classes.json
When generating class list
Then exactly 80 entries
## Constraints
- Uses classes.json from project root (fixture_classes_json)
- YAML output goes to tmp_path
- Resource limit test marked: `@pytest.mark.resource_limit`