feat: update values.yaml and refactor cleanup paths
- Changed project name in values.yaml from "sientia-dataops-model-manager" to "sientia-model-manager". - Added new environment variables for GitHub repository and branch configuration. - Refactored cleanup paths to use a centralized REPORTS_TEMP_DIR constant for consistency. - Updated runtime configurations and adjusted volume mounts for better resource management. - Enabled SSH access for the model manager and disabled Grafana dashboard creation. - Updated tests to reflect changes in directory paths and environment variable usage.
This commit is contained in:
@@ -23,6 +23,7 @@ with workflow.unsafe.imports_passed_through():
|
||||
from sientia_do.observability.sientia_monitoring import SientiaMonitoring
|
||||
|
||||
from model_manager.metrics import ACTIVITY_EXECUTION_TOTAL, WORKFLOW_EXECUTION_TOTAL
|
||||
from model_manager.runtime_paths import REPORTS_TEMP_DIR
|
||||
|
||||
RETENTION_HOURS = int(os.getenv('CLEANUP_RETENTION_HOURS', '24'))
|
||||
DRY_RUN = os.getenv('CLEANUP_DRY_RUN', 'false').lower() == 'true'
|
||||
@@ -82,7 +83,7 @@ class Cleanup(SientiaMonitoring):
|
||||
Exception: If cleanup fails (after sending notification)
|
||||
"""
|
||||
metadata = input_data.get('metadata', {})
|
||||
temp_path = input_data.get('temp_path', 'model_manager/reports/temp')
|
||||
temp_path = input_data.get('temp_path', REPORTS_TEMP_DIR)
|
||||
metrics_status = 'success'
|
||||
|
||||
cutoff_time = datetime.now() - timedelta(hours=self.retention_hours)
|
||||
|
||||
26
model_manager/runtime_paths.py
Normal file
26
model_manager/runtime_paths.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Filesystem layout for worker runtime data outside the application package tree."""
|
||||
|
||||
from os import makedirs
|
||||
from os.path import join
|
||||
|
||||
# Root for all mutable runtime data (not under /app; avoids clashing with git clone under /app).
|
||||
RUNTIME_DATA_ROOT = '/var/lib/model-manager'
|
||||
|
||||
# Training reports (HTML, CSV exports, etc.) and related outputs.
|
||||
REPORTS_ROOT = join(RUNTIME_DATA_ROOT, 'reports')
|
||||
|
||||
# Per-training run folders (name + timestamp); cleanup cron deletes stale entries here.
|
||||
REPORTS_TEMP_DIR = join(REPORTS_ROOT, 'temp')
|
||||
|
||||
# Worker log files when file logging is wired; stdout remains primary until then.
|
||||
LOGS_DIR = join(RUNTIME_DATA_ROOT, 'logs')
|
||||
|
||||
|
||||
def ensure_runtime_directories() -> None:
|
||||
"""Create runtime directories expected by the worker process."""
|
||||
# REPORTS_ROOT: base directory for report artifacts; remove if all outputs move elsewhere.
|
||||
makedirs(REPORTS_ROOT, exist_ok=True)
|
||||
# REPORTS_TEMP_DIR: transient run subdirs; remove after retention/cleanup is centralized.
|
||||
makedirs(REPORTS_TEMP_DIR, exist_ok=True)
|
||||
# LOGS_DIR: on-disk logs; remove if logging stays stdout-only forever.
|
||||
makedirs(LOGS_DIR, exist_ok=True)
|
||||
@@ -27,6 +27,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.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
|
||||
@@ -394,14 +395,9 @@ class DataManagerRepository(SientiaMonitoring):
|
||||
Get the absolute path to the reports directory.
|
||||
|
||||
Returns:
|
||||
str: Absolute path to model_manager/reports directory.
|
||||
str: Absolute path to the runtime reports root.
|
||||
"""
|
||||
# Get the directory where this file is located (model_manager/utils/repository/)
|
||||
current_file_dir = path.dirname(path.abspath(__file__))
|
||||
# Navigate up to model_manager/ and then to reports/
|
||||
model_manager_dir = path.dirname(path.dirname(current_file_dir))
|
||||
reports_dir = path.join(model_manager_dir, 'reports')
|
||||
return reports_dir
|
||||
return REPORTS_ROOT
|
||||
|
||||
def _create_run_directory(
|
||||
self, base_path: str, run_name: str, metadata: dict[str, Any] | None = None
|
||||
|
||||
@@ -43,6 +43,7 @@ with workflow.unsafe.imports_passed_through():
|
||||
|
||||
from model_manager import metrics
|
||||
from model_manager.activities.activities import Activities
|
||||
from model_manager.runtime_paths import ensure_runtime_directories
|
||||
from model_manager.schedules.cleanup_schedule import create_cleanup_schedule
|
||||
from model_manager.utils.connectors_config import (
|
||||
build_minio_config,
|
||||
@@ -97,6 +98,8 @@ async def main():
|
||||
|
||||
runtime = _get_runtime(RUNTIME)
|
||||
|
||||
ensure_runtime_directories()
|
||||
|
||||
host = os.getenv('TEMPORAL_HOST', 'localhost:7233')
|
||||
use_tls = os.getenv('TEMPORAL_USE_TLS', 'false').lower() == 'true'
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@@ -13,6 +13,7 @@ with workflow.unsafe.imports_passed_through():
|
||||
from typing import Any
|
||||
|
||||
from model_manager.activities.activities import Activities
|
||||
from model_manager.runtime_paths import REPORTS_TEMP_DIR
|
||||
from model_manager.workflows.train_model import no_retry_policy
|
||||
|
||||
TIMEOUT_CLEANUP_LOCAL = int(os.getenv('TIMEOUT_CLEANUP_LOCAL', '120'))
|
||||
@@ -39,8 +40,7 @@ class CleanupFiles:
|
||||
in sequence. No exception handling is needed as activities handle their
|
||||
own errors and notifications.
|
||||
"""
|
||||
# Default temp path for local cleanup
|
||||
temp_path = 'model_manager/reports/temp'
|
||||
temp_path = REPORTS_TEMP_DIR
|
||||
|
||||
# Metadata for tracking
|
||||
metadata = {
|
||||
|
||||
Reference in New Issue
Block a user