Spaces:
Running
Running
Project Structure (v2.0)
Root Level Organization
aiBatteryLifecycle/
βββ π api/ FastAPI backend with model registry
βββ π artifacts/ Versioned model artifacts & results
β βββ v1/ Legacy models (cross-battery train/test)
β βββ v2/ Production models (intra-battery split) β ACTIVE
β βββ models/ Trained models: {classical, deep, ensemble}
β βββ scalers/ Feature scalers (StandardScaler for linear models)
β βββ results/ CSV results, feature matrices, metrics
β βββ figures/ Visualizations: PNG charts, HTML reports
β βββ logs/ Training/inference logs
β βββ features/ Feature engineering artifacts
βββ π cleaned_dataset/ Raw battery test data
β βββ data/ CSV files per battery (00001.csv - 00137.csv)
β βββ extra_infos/ Supplementary metadata
β βββ metadata.csv Battery inventory
βββ π docs/ Documentation markdown files
βββ π frontend/ React SPA (TypeScript, Vite)
βββ π notebooks/ Jupyter analysis & training (01-09)
βββ π reference/ External papers & reference notebooks
βββ π scripts/ Organized utility scripts
β βββ data/ Data processing (write_nb03_v2, patch_dl_notebooks_v2)
β βββ models/ Model training (retrain_classical)
β βββ __init__.py Package marker
β βββ README (in data/models/)
βββ π src/ Core Python library
β βββ data/ Data loading & preprocessing
β βββ evaluation/ Metrics & validation
β βββ models/ Model architectures
β βββ utils/ Config, logging, helpers
β βββ __init__.py
βββ π tests/ β NEW: Test & validation scripts
β βββ test_v2_models.py Comprehensive v2 validation
β βββ test_predictions.py Quick endpoint test
β βββ __init__.py
β βββ README.md
βββ π CHANGELOG.md Version history & updates
βββ π VERSION.md β NEW: Versioning & versioning guide
βββ π README.md Project overview
βββ π requirements.txt Python dependencies
βββ π package.json Node.js dependencies (frontend)
βββ π Dockerfile Docker configuration
βββ π docker-compose.yml Multi-container orchestration
βββ π tsconfig.json TypeScript config (frontend)
βββ π vite.config.ts Vite bundler config (frontend)
Key Changes in V2 Reorganization
β Completed
Versioned Artifacts
- Moved
artifacts/models/βartifacts/v2/models/ - Moved
artifacts/scalers/βartifacts/v2/scalers/ - Moved
artifacts/figures/βartifacts/v2/figures/ - All result CSVs β
artifacts/v2/results/ - Clean
artifacts/root (only v1 and v2 subdirs)
- Moved
Organized Scripts
- Created
scripts/data/for data processing utilities - Created
scripts/models/for model training scripts - All scripts now using
get_version_paths('v2') - Path:
scripts/retrain_classical.pyβscripts/models/retrain_classical.py
- Created
Centralized Tests
- Created
tests/folder at project root - Moved
test_v2_models.pyβtests/ - Moved
test_predictions.pyβtests/ - Added
tests/README.mdwith usage guide - All tests now using
artifacts/v2/paths
- Created
Updated Imports & Paths
test_v2_models.py: Usesv2['results']for data loadingretrain_classical.py: Usesget_version_paths('v2')for artifact saving- API: Already defaults to
registry_v2 - Notebooks NB03-09: Already use
get_version_paths()
Code Changes Summary
| File | Change | Result |
|---|---|---|
tests/test_v2_models.py |
Updated artifact paths to use v2 | Output β artifacts/v2/{results,figures} |
scripts/models/retrain_classical.py |
Uses get_version_paths('v2') |
Models saved to artifacts/v2/models/classical/ |
api/model_registry.py |
Already has versioning support | No changes needed |
src/utils/config.py |
Already supports versioning | No changes needed |
| Notebooks NB03-09 | Already use get_version_paths() |
No changes needed |
Running Tests After Reorganization
# From project root
python tests/test_v2_models.py # Full v2 validation
python tests/test_predictions.py # Quick endpoint test
python scripts/models/retrain_classical.py # Retrain models
Artifact Access in Code
Before (V1 - hardcoded paths)
model_path = "artifacts/models/classical/rf.joblib"
results_csv = "artifacts/results.csv"
After (V2 - versioned paths via config)
from src.utils.config import get_version_paths
v2 = get_version_paths('v2')
model_path = v2['models_classical'] / 'rf.joblib'
results_csv = v2['results'] / 'results.csv'
Production Readiness
| Aspect | Status | Notes |
|---|---|---|
| Versioning | β Complete | All artifacts under v2/ |
| Structure | β Organized | Scripts, tests, notebooks organized |
| Configuration | β Active | ACTIVE_VERSION = 'v2' in config |
| API | β Ready | Defaults to registry_v2 |
| Tests | β Available | tests/test_v2_models.py for validation |
| Documentation | β Added | VERSION.md and README files created |
Forward Compatibility
For Future Versions (v3, v4, etc.)
Simply copy the v2 folder structure and update:
# In src/utils/config.py
ACTIVE_VERSION: str = "v3"
# In scripts
v3 = get_version_paths('v3')
ensure_version_dirs('v3')
The system will automatically create versioned paths and maintain backward compatibility.