feat: add project base path and template path handling in report generation

- Introduced PROJECT_BASE_PATH constant for consistent project directory reference.
- Updated Reports class to require template_path for loading HTML templates.
- Modified DataManagerRepository to pass the new template_path when generating reports.
This commit is contained in:
vitor-aignosi
2026-04-16 14:43:25 -03:00
parent b2458ec354
commit de2d7712e8
3 changed files with 18 additions and 6 deletions

View File

@@ -28,7 +28,7 @@ from sientia_do.observability.sientia_monitoring import SientiaMonitoring
from sientia_do.temporal.constants import DATETIME_FORMAT_WITH_TZ
from sientia_model.wrappers.sientia_model import SientiaModel
from model_manager.runtime_paths import REPORTS_ROOT
from model_manager.runtime_paths import REPORTS_ROOT, PROJECT_BASE_PATH
from model_manager.sientia.metrics import mae, mse, r2
from model_manager.sientia.reports import Reports # type: ignore[import-untyped]
from model_manager.utils.models.train_model_params import TrainModelParams
@@ -473,8 +473,7 @@ class DataManagerRepository(SientiaMonitoring):
OSError: If directory creation fails for any other reason.
"""
# Use microsecond precision to reduce collision probability
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S_%f')
run_dir = path.join(base_path, 'temp', f'{run_name}_{timestamp}')
run_dir = path.join(base_path, 'temp', f'{run_name}')
try:
makedirs(run_dir, exist_ok=True)
@@ -534,11 +533,17 @@ class DataManagerRepository(SientiaMonitoring):
current_data_float = current_data.astype(np.float64)
# Initialize report generator
data.run_dir = self._create_run_directory(self._get_reports_directory(), data.run_name)
base_path = self._get_reports_directory()
data.run_dir = self._create_run_directory(base_path, data.run_name)
# Template path is the code path of the model_manager package
template_path = path.join(PROJECT_BASE_PATH, 'reports')
report = Reports(
reference_data=reference_data_float,
current_data=current_data_float,
base_path=data.run_dir,
template_path=template_path,
target_name=data.params.target_variable,
)