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,72 @@
# Augmentation Performance, Resilience & Resource Tests
**Task**: AZ-154_test_augmentation_nonfunc
**Name**: Augmentation Non-Functional Tests
**Description**: Implement performance, resilience, and resource limit tests for augmentation — throughput, parallel speedup, error handling, output bounds
**Complexity**: 2 points
**Dependencies**: AZ-152_test_infrastructure
**Component**: Blackbox Tests
**Jira**: AZ-154
**Epic**: AZ-151
## Problem
Augmentation must perform within time thresholds, handle corrupted/missing inputs gracefully, and respect output count bounds.
## Outcome
- 6 passing pytest tests across performance and resilience categories
- Performance tests in `tests/performance/test_augmentation_perf.py`
- Resilience and resource limit tests in `tests/test_augmentation.py` with markers
## Scope
### Included
- PT-AUG-01: Augmentation throughput (10 images ≤ 60s)
- PT-AUG-02: Parallel augmentation speedup (≥ 1.5× faster)
- RT-AUG-01: Handles corrupted image gracefully
- RT-AUG-02: Handles missing label file
- RT-AUG-03: Transform failure produces fewer variants (no crash)
- RL-AUG-01: Output count bounded to exactly 8
### Excluded
- Blackbox functional tests (separate task 02)
## Acceptance Criteria
**AC-1: Throughput**
Given 10 images from fixture dataset
When augment_annotations() runs
Then completes within 60 seconds
**AC-2: Parallel speedup**
Given 10 images from fixture dataset
When run with ThreadPoolExecutor vs sequential
Then parallel is ≥ 1.5× faster
**AC-3: Corrupted image**
Given 1 valid + 1 corrupted image (truncated JPEG)
When augment_annotations() runs
Then valid image produces 8 outputs, corrupted skipped, no crash
**AC-4: Missing label**
Given 1 image with no matching label file
When augment_annotation() runs on it
Then exception caught per-thread, pipeline continues
**AC-5: Transform failure**
Given 1 image + label with extremely narrow bbox
When augment_inner() runs
Then 1-8 ImageLabel objects returned, no crash
**AC-6: Output count bounded**
Given 1 image
When augment_inner() runs
Then exactly 8 outputs returned (never more)
## Constraints
- Performance tests require pytest markers: `@pytest.mark.performance`
- Resilience tests marked: `@pytest.mark.resilience`
- Resource limit tests marked: `@pytest.mark.resource_limit`
- Performance thresholds are generous (CPU-bound, no GPU requirement)